blob: ef1c80d67ac73307957e308a879eca1e556874fb [file] [log] [blame]
Shuah Khan7fb2c3e2014-10-03 09:04:23 -06001/*
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 Hart4100e672015-05-12 21:07:56 -070016/* 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 Khan7fb2c3e2014-10-03 09:04:23 -060023/* counters */
24struct 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
32static struct ksft_count ksft_cnt;
33
34static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; }
35static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; }
36static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; }
37static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; }
38static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; }
39
40static 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
48static inline int ksft_exit_pass(void)
49{
Darren Hart4100e672015-05-12 21:07:56 -070050 exit(KSFT_PASS);
Shuah Khan7fb2c3e2014-10-03 09:04:23 -060051}
52static inline int ksft_exit_fail(void)
53{
Darren Hart4100e672015-05-12 21:07:56 -070054 exit(KSFT_FAIL);
Shuah Khan7fb2c3e2014-10-03 09:04:23 -060055}
56static inline int ksft_exit_xfail(void)
57{
Darren Hart4100e672015-05-12 21:07:56 -070058 exit(KSFT_XFAIL);
Shuah Khan7fb2c3e2014-10-03 09:04:23 -060059}
60static inline int ksft_exit_xpass(void)
61{
Darren Hart4100e672015-05-12 21:07:56 -070062 exit(KSFT_XPASS);
Shuah Khan7fb2c3e2014-10-03 09:04:23 -060063}
64static inline int ksft_exit_skip(void)
65{
Darren Hart4100e672015-05-12 21:07:56 -070066 exit(KSFT_SKIP);
Shuah Khan7fb2c3e2014-10-03 09:04:23 -060067}
68
69#endif /* __KSELFTEST_H */