Skip to content

Commit 732e203

Browse files
kuba-moodavem330
authored andcommitted
selftests: kselftest_harness: print test name for SKIP
Jakub points out that for parsers it's rather useful to always have the test name on the result line. Currently if we SKIP (or soon XFAIL or XPASS), we will print: ok 17 # SKIP SCTP doesn't support IP_BIND_ADDRESS_NO_PORT ^ no test name Always print the test name. KTAP format seems to allow or even call for it, per: https://docs.kernel.org/dev-tools/ktap.html Suggested-by: Jakub Sitnicki <jakub@cloudflare.com> Link: https://lore.kernel.org/all/87jzn6lnou.fsf@cloudflare.com/ Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fa1a53d commit 732e203

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

tools/testing/selftests/kselftest.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,9 @@ static inline __printf(1, 2) void ksft_test_result_error(const char *msg, ...)
255255
va_end(args);
256256
}
257257

258-
static inline __printf(2, 3)
259-
void ksft_test_result_code(int exit_code, const char *msg, ...)
258+
static inline __printf(3, 4)
259+
void ksft_test_result_code(int exit_code, const char *test_name,
260+
const char *msg, ...)
260261
{
261262
const char *tap_code = "ok";
262263
const char *directive = "";
@@ -287,7 +288,7 @@ void ksft_test_result_code(int exit_code, const char *msg, ...)
287288
}
288289

289290
va_start(args, msg);
290-
printf("%s %u%s", tap_code, ksft_test_num(), directive);
291+
printf("%s %u %s%s", tap_code, ksft_test_num(), test_name, directive);
291292
errno = saved_errno;
292293
vprintf(msg, args);
293294
va_end(args);

tools/testing/selftests/kselftest_harness.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,8 @@ void __run_test(struct __fixture_metadata *f,
11471147
diagnostic = "unknown";
11481148

11491149
if (t->exit_code == KSFT_SKIP)
1150-
ksft_test_result_code(t->exit_code, "%s\n", diagnostic);
1150+
ksft_test_result_code(t->exit_code, test_name,
1151+
"%s\n", diagnostic);
11511152
else
11521153
ksft_test_result(__test_passed(t), "%s\n", test_name);
11531154
}

0 commit comments

Comments
 (0)