]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
selftests: kselftest_harness: let PASS / FAIL provide diagnostic
authorJakub Kicinski <kuba@kernel.org>
Thu, 29 Feb 2024 00:59:17 +0000 (16:59 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Mar 2024 10:30:29 +0000 (10:30 +0000)
Switch to printing KTAP line for PASS / FAIL with ksft_test_result_code(),
this gives us the ability to report diagnostic messages.

Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/kselftest_harness.h

index 5b0592e4b7a47fb2978cf4f67f2938ba58a964e9..b643a577f9e17168d384f75bbb25c7e8cf2c9ccb 100644 (file)
@@ -1143,14 +1143,13 @@ void __run_test(struct __fixture_metadata *f,
 
        if (t->results->reason[0])
                diagnostic = t->results->reason;
+       else if (t->exit_code == KSFT_PASS || t->exit_code == KSFT_FAIL)
+               diagnostic = NULL;
        else
                diagnostic = "unknown";
 
-       if (t->exit_code == KSFT_SKIP)
-               ksft_test_result_code(t->exit_code, test_name,
-                                     "%s", diagnostic);
-       else
-               ksft_test_result(__test_passed(t), "%s\n", test_name);
+       ksft_test_result_code(t->exit_code, test_name,
+                             diagnostic ? "%s" : "", diagnostic);
 }
 
 static int test_harness_run(int argc, char **argv)