]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
selftests: kselftest_harness: separate diagnostic message with # in ksft_test_result_...
authorJakub Kicinski <kuba@kernel.org>
Thu, 29 Feb 2024 00:59:16 +0000 (16:59 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Mar 2024 10:30:29 +0000 (10:30 +0000)
According to the spec we should always print a # if we add
a diagnostic message. Having the caller pass in the new line
as part of diagnostic message makes handling this a bit
counter-intuitive, so append the new line in the helper.

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.h
tools/testing/selftests/kselftest_harness.h

index 25e29626566eca44c9a55132783e4956d20ebda9..541bf192e30e6bcec377908643d41d1d1dbf765a 100644 (file)
@@ -287,10 +287,15 @@ void ksft_test_result_code(int exit_code, const char *test_name,
                break;
        }
 
+       /* Docs seem to call for double space if directive is absent */
+       if (!directive[0] && msg[0])
+               directive = " #  ";
+
        va_start(args, msg);
        printf("%s %u %s%s", tap_code, ksft_test_num(), test_name, directive);
        errno = saved_errno;
        vprintf(msg, args);
+       printf("\n");
        va_end(args);
 }
 
index 82377051aa54135136c36ff105bf23ad6ba4923c..5b0592e4b7a47fb2978cf4f67f2938ba58a964e9 100644 (file)
@@ -1148,7 +1148,7 @@ void __run_test(struct __fixture_metadata *f,
 
        if (t->exit_code == KSFT_SKIP)
                ksft_test_result_code(t->exit_code, test_name,
-                                     "%s\n", diagnostic);
+                                     "%s", diagnostic);
        else
                ksft_test_result(__test_passed(t), "%s\n", test_name);
 }