From: Jakub Kicinski Date: Thu, 29 Feb 2024 00:59:17 +0000 (-0800) Subject: selftests: kselftest_harness: let PASS / FAIL provide diagnostic X-Git-Tag: v6.9-rc1~159^2~137^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=378193eff3399acb8529d0b553709e8f91d34fe3;p=thirdparty%2Fkernel%2Flinux.git selftests: kselftest_harness: let PASS / FAIL provide diagnostic 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 Signed-off-by: Jakub Kicinski Signed-off-by: David S. Miller --- diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h index 5b0592e4b7a47..b643a577f9e17 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -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)