Shuah Khan | 7fb2c3e | 2014-10-03 09:04:23 -0600 | [diff] [blame] | 1 | /* |
| 2 | * kselftest.h: kselftest framework return codes to include from |
| 3 | * selftests. |
| 4 | * |
| 5 | * Copyright (c) 2014 Shuah Khan <shuahkh@osg.samsung.com> |
| 6 | * Copyright (c) 2014 Samsung Electronics Co., Ltd. |
| 7 | * |
| 8 | * This file is released under the GPLv2. |
| 9 | */ |
| 10 | #ifndef __KSELFTEST_H |
| 11 | #define __KSELFTEST_H |
| 12 | |
| 13 | #include <stdlib.h> |
| 14 | #include <unistd.h> |
| 15 | |
Darren Hart | 4100e67 | 2015-05-12 21:07:56 -0700 | [diff] [blame] | 16 | /* define kselftest exit codes */ |
| 17 | #define KSFT_PASS 0 |
| 18 | #define KSFT_FAIL 1 |
| 19 | #define KSFT_XFAIL 2 |
| 20 | #define KSFT_XPASS 3 |
| 21 | #define KSFT_SKIP 4 |
| 22 | |
Shuah Khan | 7fb2c3e | 2014-10-03 09:04:23 -0600 | [diff] [blame] | 23 | /* counters */ |
| 24 | struct ksft_count { |
| 25 | unsigned int ksft_pass; |
| 26 | unsigned int ksft_fail; |
| 27 | unsigned int ksft_xfail; |
| 28 | unsigned int ksft_xpass; |
| 29 | unsigned int ksft_xskip; |
| 30 | }; |
| 31 | |
| 32 | static struct ksft_count ksft_cnt; |
| 33 | |
| 34 | static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; } |
| 35 | static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; } |
| 36 | static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; } |
| 37 | static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; } |
| 38 | static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; } |
| 39 | |
| 40 | static inline void ksft_print_cnts(void) |
| 41 | { |
| 42 | printf("Pass: %d Fail: %d Xfail: %d Xpass: %d, Xskip: %d\n", |
| 43 | ksft_cnt.ksft_pass, ksft_cnt.ksft_fail, |
| 44 | ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass, |
| 45 | ksft_cnt.ksft_xskip); |
| 46 | } |
| 47 | |
| 48 | static inline int ksft_exit_pass(void) |
| 49 | { |
Darren Hart | 4100e67 | 2015-05-12 21:07:56 -0700 | [diff] [blame] | 50 | exit(KSFT_PASS); |
Shuah Khan | 7fb2c3e | 2014-10-03 09:04:23 -0600 | [diff] [blame] | 51 | } |
| 52 | static inline int ksft_exit_fail(void) |
| 53 | { |
Darren Hart | 4100e67 | 2015-05-12 21:07:56 -0700 | [diff] [blame] | 54 | exit(KSFT_FAIL); |
Shuah Khan | 7fb2c3e | 2014-10-03 09:04:23 -0600 | [diff] [blame] | 55 | } |
| 56 | static inline int ksft_exit_xfail(void) |
| 57 | { |
Darren Hart | 4100e67 | 2015-05-12 21:07:56 -0700 | [diff] [blame] | 58 | exit(KSFT_XFAIL); |
Shuah Khan | 7fb2c3e | 2014-10-03 09:04:23 -0600 | [diff] [blame] | 59 | } |
| 60 | static inline int ksft_exit_xpass(void) |
| 61 | { |
Darren Hart | 4100e67 | 2015-05-12 21:07:56 -0700 | [diff] [blame] | 62 | exit(KSFT_XPASS); |
Shuah Khan | 7fb2c3e | 2014-10-03 09:04:23 -0600 | [diff] [blame] | 63 | } |
| 64 | static inline int ksft_exit_skip(void) |
| 65 | { |
Darren Hart | 4100e67 | 2015-05-12 21:07:56 -0700 | [diff] [blame] | 66 | exit(KSFT_SKIP); |
Shuah Khan | 7fb2c3e | 2014-10-03 09:04:23 -0600 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | #endif /* __KSELFTEST_H */ |