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 16 /* counters */ 17 struct ksft_count { 18 unsigned int ksft_pass; 19 unsigned int ksft_fail; 20 unsigned int ksft_xfail; 21 unsigned int ksft_xpass; 22 unsigned int ksft_xskip; 23 }; 24 25 static struct ksft_count ksft_cnt; 26 27 static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; } 28 static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; } 29 static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; } 30 static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; } 31 static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; } 32 33 static inline void ksft_print_cnts(void) 34 { 35 printf("Pass: %d Fail: %d Xfail: %d Xpass: %d, Xskip: %d\n", 36 ksft_cnt.ksft_pass, ksft_cnt.ksft_fail, 37 ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass, 38 ksft_cnt.ksft_xskip); 39 } 40 41 static inline int ksft_exit_pass(void) 42 { 43 exit(0); 44 } 45 static inline int ksft_exit_fail(void) 46 { 47 exit(1); 48 } 49 static inline int ksft_exit_xfail(void) 50 { 51 exit(2); 52 } 53 static inline int ksft_exit_xpass(void) 54 { 55 exit(3); 56 } 57 static inline int ksft_exit_skip(void) 58 { 59 exit(4); 60 } 61 62 #endif /* __KSELFTEST_H */ 63