Skip to content

Commit e8731ec

Browse files
Steffo99shuahkh
authored andcommitted
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/[email protected] Signed-off-by: Stefano Pigozzi <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent e0746bd commit e8731ec

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tools/testing/selftests/kselftest.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
* ksft_print_msg(fmt, ...);
1919
* ksft_perror(msg);
2020
*
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:
2223
*
2324
* ksft_test_result(condition, fmt, ...);
2425
* ksft_test_result_report(result, fmt, ...);
2526
* ksft_test_result_pass(fmt, ...);
2627
* ksft_test_result_fail(fmt, ...);
2728
* ksft_test_result_skip(fmt, ...);
2829
* ksft_test_result_xfail(fmt, ...);
30+
* ksft_test_result_xpass(fmt, ...);
2931
* ksft_test_result_error(fmt, ...);
3032
* ksft_test_result_code(exit_code, test_name, fmt, ...);
3133
*
@@ -227,6 +229,20 @@ static inline __printf(1, 2) void ksft_test_result_xfail(const char *msg, ...)
227229
va_end(args);
228230
}
229231

232+
static inline __printf(1, 2) void ksft_test_result_xpass(const char *msg, ...)
233+
{
234+
int saved_errno = errno;
235+
va_list args;
236+
237+
ksft_cnt.ksft_xpass++;
238+
239+
va_start(args, msg);
240+
printf("ok %u # XPASS ", ksft_test_num());
241+
errno = saved_errno;
242+
vprintf(msg, args);
243+
va_end(args);
244+
}
245+
230246
static inline __printf(1, 2) void ksft_test_result_skip(const char *msg, ...)
231247
{
232248
int saved_errno = errno;
@@ -318,6 +334,9 @@ void ksft_test_result_code(int exit_code, const char *test_name,
318334
case KSFT_XFAIL: \
319335
ksft_test_result_xfail(fmt, ##__VA_ARGS__); \
320336
break; \
337+
case KSFT_XPASS: \
338+
ksft_test_result_xpass(fmt, ##__VA_ARGS__); \
339+
break; \
321340
case KSFT_SKIP: \
322341
ksft_test_result_skip(fmt, ##__VA_ARGS__); \
323342
break; \

0 commit comments

Comments
 (0)