kselftest/arm64: signal: Allow tests to be incompatible with features
authorMark Brown <broonie@kernel.org>
Mon, 7 Feb 2022 15:20:34 +0000 (15:20 +0000)
committerWill Deacon <will@kernel.org>
Fri, 25 Feb 2022 14:38:29 +0000 (14:38 +0000)
Some features may invalidate some tests, for example by supporting an
operation which would trap otherwise. Allow tests to list features that
they are incompatible with so we can cover the case where a signal will
be generated without disruption on systems where that won't happen.

Signed-off-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20220207152109.197566-6-broonie@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
tools/testing/selftests/arm64/signal/test_signals.h
tools/testing/selftests/arm64/signal/test_signals_utils.c
tools/testing/selftests/arm64/signal/test_signals_utils.h

index ebe8694..f909b70 100644 (file)
@@ -53,6 +53,7 @@ struct tdescr {
        char                    *name;
        char                    *descr;
        unsigned long           feats_required;
+       unsigned long           feats_incompatible;
        /* bitmask of effectively supported feats: populated at run-time */
        unsigned long           feats_supported;
        bool                    initialized;
index 2f8c23a..5743897 100644 (file)
@@ -36,6 +36,8 @@ static inline char *feats_to_string(unsigned long feats)
 {
        size_t flen = MAX_FEATS_SZ - 1;
 
+       feats_string[0] = '\0';
+
        for (int i = 0; i < FMAX_END; i++) {
                if (feats & (1UL << i)) {
                        size_t tlen = strlen(feats_names[i]);
@@ -256,7 +258,7 @@ int test_init(struct tdescr *td)
                td->minsigstksz = MINSIGSTKSZ;
        fprintf(stderr, "Detected MINSTKSIGSZ:%d\n", td->minsigstksz);
 
-       if (td->feats_required) {
+       if (td->feats_required || td->feats_incompatible) {
                td->feats_supported = 0;
                /*
                 * Checking for CPU required features using both the
@@ -267,15 +269,29 @@ int test_init(struct tdescr *td)
                if (getauxval(AT_HWCAP) & HWCAP_SVE)
                        td->feats_supported |= FEAT_SVE;
                if (feats_ok(td)) {
-                       fprintf(stderr,
-                               "Required Features: [%s] supported\n",
-                               feats_to_string(td->feats_required &
-                                               td->feats_supported));
+                       if (td->feats_required & td->feats_supported)
+                               fprintf(stderr,
+                                       "Required Features: [%s] supported\n",
+                                       feats_to_string(td->feats_required &
+                                                       td->feats_supported));
+                       if (!(td->feats_incompatible & td->feats_supported))
+                               fprintf(stderr,
+                                       "Incompatible Features: [%s] absent\n",
+                                       feats_to_string(td->feats_incompatible));
                } else {
-                       fprintf(stderr,
-                               "Required Features: [%s] NOT supported\n",
-                               feats_to_string(td->feats_required &
-                                               ~td->feats_supported));
+                       if ((td->feats_required & td->feats_supported) !=
+                           td->feats_supported)
+                               fprintf(stderr,
+                                       "Required Features: [%s] NOT supported\n",
+                                       feats_to_string(td->feats_required &
+                                                       ~td->feats_supported));
+                       if (td->feats_incompatible & td->feats_supported)
+                               fprintf(stderr,
+                                       "Incompatible Features: [%s] supported\n",
+                                       feats_to_string(td->feats_incompatible &
+                                                       ~td->feats_supported));
+
+
                        td->result = KSFT_SKIP;
                        return 0;
                }
index 6772b5c..f3aa99b 100644 (file)
@@ -18,6 +18,8 @@ void test_result(struct tdescr *td);
 
 static inline bool feats_ok(struct tdescr *td)
 {
+       if (td->feats_incompatible & td->feats_supported)
+               return false;
        return (td->feats_required & td->feats_supported) == td->feats_required;
 }