Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: kselftest: Add ksft_test_result_xpass

The functions ksft_test_result_pass, ksft_test_result_fail,
ksft_test_result_xfail, and ksft_test_result_skip already exist and are
available for use in selftests, but no XPASS equivalent is
available.

This adds a new function to that family that outputs XPASS, so that it's
available for future test writers.

Link: https://lore.kernel.org/r/20241207012325.56611-1-me@steffo.eu
Signed-off-by: Stefano Pigozzi <me@steffo.eu>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Stefano Pigozzi and committed by
Shuah Khan
e8731ecd e0746bde

+20 -1
+20 -1
tools/testing/selftests/kselftest.h
··· 18 18 * ksft_print_msg(fmt, ...); 19 19 * ksft_perror(msg); 20 20 * 21 - * and finally report the pass/fail/skip/xfail state of the test with one of: 21 + * and finally report the pass/fail/skip/xfail/xpass state of the test 22 + * with one of: 22 23 * 23 24 * ksft_test_result(condition, fmt, ...); 24 25 * ksft_test_result_report(result, fmt, ...); ··· 27 26 * ksft_test_result_fail(fmt, ...); 28 27 * ksft_test_result_skip(fmt, ...); 29 28 * ksft_test_result_xfail(fmt, ...); 29 + * ksft_test_result_xpass(fmt, ...); 30 30 * ksft_test_result_error(fmt, ...); 31 31 * ksft_test_result_code(exit_code, test_name, fmt, ...); 32 32 * ··· 229 227 va_end(args); 230 228 } 231 229 230 + static inline __printf(1, 2) void ksft_test_result_xpass(const char *msg, ...) 231 + { 232 + int saved_errno = errno; 233 + va_list args; 234 + 235 + ksft_cnt.ksft_xpass++; 236 + 237 + va_start(args, msg); 238 + printf("ok %u # XPASS ", ksft_test_num()); 239 + errno = saved_errno; 240 + vprintf(msg, args); 241 + va_end(args); 242 + } 243 + 232 244 static inline __printf(1, 2) void ksft_test_result_skip(const char *msg, ...) 233 245 { 234 246 int saved_errno = errno; ··· 333 317 break; \ 334 318 case KSFT_XFAIL: \ 335 319 ksft_test_result_xfail(fmt, ##__VA_ARGS__); \ 320 + break; \ 321 + case KSFT_XPASS: \ 322 + ksft_test_result_xpass(fmt, ##__VA_ARGS__); \ 336 323 break; \ 337 324 case KSFT_SKIP: \ 338 325 ksft_test_result_skip(fmt, ##__VA_ARGS__); \