]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: Warn about skipped tests in result summary
authorLaura Nao <laura.nao@collabora.com>
Tue, 26 Nov 2024 09:37:10 +0000 (10:37 +0100)
committerShuah Khan <skhan@linuxfoundation.org>
Wed, 15 Jan 2025 00:06:31 +0000 (17:06 -0700)
Update the functions that print the test totals at the end of a selftest
to include a warning message when skipped tests are detected. The
message advises users that skipped tests may indicate missing
configuration options and suggests enabling them to improve coverage.

Link: https://lore.kernel.org/r/20241126093710.13314-1-laura.nao@collabora.com
Signed-off-by: Laura Nao <laura.nao@collabora.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/kselftest.h
tools/testing/selftests/kselftest/ksft.py
tools/testing/selftests/kselftest/ktap_helpers.sh

index 685d9f9554fcb383e8a5de1138a011eebbc615aa..5263961db51f92fb8acac5a92bd0fdc4e9b2fd8b 100644 (file)
@@ -149,6 +149,11 @@ static inline void ksft_set_plan(unsigned int plan)
 
 static inline void ksft_print_cnts(void)
 {
+       if (ksft_cnt.ksft_xskip > 0)
+               printf(
+                       "# %u skipped test(s) detected. Consider enabling relevant config options to improve coverage.\n",
+                       ksft_cnt.ksft_xskip
+               );
        if (ksft_plan != ksft_test_num())
                printf("# Planned tests != run tests (%u != %u)\n",
                        ksft_plan, ksft_test_num());
index bf215790a89d739e0df9bdc111e808d51e385af3..0e030837fc1752388ada473e877a6aecddd6dcc8 100644 (file)
@@ -27,6 +27,9 @@ def set_plan(num_tests):
 
 
 def print_cnts():
+    if ksft_cnt['skip'] > 0:
+        print(f"# {ksft_cnt['skip']} skipped test(s) detected. Consider enabling relevant config options to improve coverage.")
+
     print(
         f"# Totals: pass:{ksft_cnt['pass']} fail:{ksft_cnt['fail']} xfail:0 xpass:0 skip:{ksft_cnt['skip']} error:0"
     )
index 79a125eb24c2e8a0539a367a05f46d996d9164f0..531094d81f03d980069796e99b9bcb5289e401c0 100644 (file)
@@ -107,5 +107,9 @@ ktap_finished() {
 }
 
 ktap_print_totals() {
+       if [ "$KTAP_CNT_SKIP" -gt 0 ]; then
+               echo "# $KTAP_CNT_SKIP skipped test(s) detected. " \
+                       "Consider enabling relevant config options to improve coverage."
+       fi
        echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
 }