mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
kselftest: Add mechanism for reporting a KSFT_ result code
Currently there's no helper which a test can use to report it's result as
a KSFT_ result code, we can report a boolean pass/fail but not a skip. This
is sometimes a useful idiom so let's add a helper ksft_test_result_report()
which translates into the relevant report types.
Due to the use of va_args in the result reporting functions this is done as
a macro rather than an inline function as one might expect, none of the
alternatives looked particularly great.
Resolved merge conflict in next betwwen the following commits:
f7d5bcd35d
("selftests: kselftest: Mark functions that unconditionally call exit() as __noreturn")
5d3a9274f0d1 ("kselftest: Add mechanism for reporting a KSFT_ result code")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
parent
dd5a440a31
commit
6d75d75d77
1 changed files with 22 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
* and finally report the pass/fail/skip/xfail state of the test with one of:
|
||||
*
|
||||
* ksft_test_result(condition, fmt, ...);
|
||||
* ksft_test_result_report(result, fmt, ...);
|
||||
* ksft_test_result_pass(fmt, ...);
|
||||
* ksft_test_result_fail(fmt, ...);
|
||||
* ksft_test_result_skip(fmt, ...);
|
||||
|
@ -305,6 +306,27 @@ void ksft_test_result_code(int exit_code, const char *test_name,
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* ksft_test_result() - Report test success based on truth of condition
|
||||
*
|
||||
* @condition: if true, report test success, otherwise failure.
|
||||
*/
|
||||
#define ksft_test_result_report(result, fmt, ...) do { \
|
||||
switch (result) { \
|
||||
case KSFT_PASS: \
|
||||
ksft_test_result_pass(fmt, ##__VA_ARGS__); \
|
||||
break; \
|
||||
case KSFT_FAIL: \
|
||||
ksft_test_result_fail(fmt, ##__VA_ARGS__); \
|
||||
break; \
|
||||
case KSFT_XFAIL: \
|
||||
ksft_test_result_xfail(fmt, ##__VA_ARGS__); \
|
||||
break; \
|
||||
case KSFT_SKIP: \
|
||||
ksft_test_result_skip(fmt, ##__VA_ARGS__); \
|
||||
break; \
|
||||
} } while (0)
|
||||
|
||||
static inline __noreturn int ksft_exit_pass(void)
|
||||
{
|
||||
ksft_print_cnts();
|
||||
|
|
Loading…
Add table
Reference in a new issue