2 * Copyright (c) 2015 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #include <tests/ktest.h>
31 #include <kern/misc_protos.h>
32 #include <tests/ktest_internal.h>
34 unsigned int ktest_current_line
= 0;
35 const char * ktest_current_file
= NULL
;
36 const char * ktest_current_func
= NULL
;
37 uint64_t ktest_current_time
= 0;
39 const char * ktest_test_name
= "";
41 char ktest_current_msg
[KTEST_MAXLEN
] = "";
42 char ktest_current_expr
[KTEST_MAXOUTLEN
] = "";
43 char ktest_current_var_names
[KTEST_MAXVARS
][KTEST_MAXLEN
] = { "", "", "" };
44 char ktest_current_var_values
[KTEST_MAXVARS
][KTEST_MAXLEN
] = { "", "", "" };
45 unsigned int ktest_expression_index
= 0;
46 unsigned int ktest_current_var_index
= 0;
47 unsigned int ktest_test_index
= 0;
48 unsigned int ktest_passcount
= 0;
49 unsigned int ktest_failcount
= 0;
50 unsigned int ktest_xpasscount
= 0;
51 unsigned int ktest_xfailcount
= 0;
52 int ktest_expectfail
= 0;
55 int ktest_testcase_result
= T_RESULT_FAIL
;
56 int ktest_test_result
= T_STATE_UNRESOLVED
;
57 int ktest_testcase_mode
= T_MAIN
;
59 ktest_temp ktest_temp1
, ktest_temp2
, ktest_temp3
;
61 char ktest_output_buf
[KTEST_MAXLEN
] = "";
64 ktest_test_result_statetab
[KTEST_NUM_TEST_STATES
]
65 [KTEST_NUM_TESTCASE_STATES
]
66 [KTEST_NUM_TESTCASE_MODES
] = {
67 [T_STATE_UNRESOLVED
][T_RESULT_PASS
][T_MAIN
] = T_STATE_PASS
,
68 [T_STATE_UNRESOLVED
][T_RESULT_FAIL
][T_MAIN
] = T_STATE_FAIL
,
69 [T_STATE_UNRESOLVED
][T_RESULT_UXPASS
][T_MAIN
] = T_STATE_FAIL
,
70 [T_STATE_UNRESOLVED
][T_RESULT_XFAIL
][T_MAIN
] = T_STATE_PASS
,
72 [T_STATE_PASS
][T_RESULT_PASS
][T_MAIN
] = T_STATE_PASS
,
73 [T_STATE_PASS
][T_RESULT_FAIL
][T_MAIN
] = T_STATE_FAIL
,
74 [T_STATE_PASS
][T_RESULT_UXPASS
][T_MAIN
] = T_STATE_FAIL
,
75 [T_STATE_PASS
][T_RESULT_XFAIL
][T_MAIN
] = T_STATE_PASS
,
77 [T_STATE_FAIL
][T_RESULT_PASS
][T_MAIN
] = T_STATE_FAIL
,
78 [T_STATE_FAIL
][T_RESULT_FAIL
][T_MAIN
] = T_STATE_FAIL
,
79 [T_STATE_FAIL
][T_RESULT_UXPASS
][T_MAIN
] = T_STATE_FAIL
,
80 [T_STATE_FAIL
][T_RESULT_XFAIL
][T_MAIN
] = T_STATE_FAIL
,
82 [T_STATE_SETUPFAIL
][T_RESULT_PASS
][T_MAIN
] = T_STATE_SETUPFAIL
,
83 [T_STATE_SETUPFAIL
][T_RESULT_FAIL
][T_MAIN
] = T_STATE_SETUPFAIL
,
84 [T_STATE_SETUPFAIL
][T_RESULT_UXPASS
][T_MAIN
] = T_STATE_SETUPFAIL
,
85 [T_STATE_SETUPFAIL
][T_RESULT_XFAIL
][T_MAIN
] = T_STATE_SETUPFAIL
,
87 [T_STATE_UNRESOLVED
][T_RESULT_PASS
][T_SETUP
] = T_STATE_UNRESOLVED
,
88 [T_STATE_UNRESOLVED
][T_RESULT_FAIL
][T_SETUP
] = T_STATE_SETUPFAIL
,
89 [T_STATE_UNRESOLVED
][T_RESULT_UXPASS
][T_SETUP
] = T_STATE_SETUPFAIL
,
90 [T_STATE_UNRESOLVED
][T_RESULT_XFAIL
][T_SETUP
] = T_STATE_UNRESOLVED
,
92 [T_STATE_PASS
][T_RESULT_PASS
][T_SETUP
] = T_STATE_PASS
,
93 [T_STATE_PASS
][T_RESULT_FAIL
][T_SETUP
] = T_STATE_SETUPFAIL
,
94 [T_STATE_PASS
][T_RESULT_UXPASS
][T_SETUP
] = T_STATE_SETUPFAIL
,
95 [T_STATE_PASS
][T_RESULT_XFAIL
][T_SETUP
] = T_STATE_PASS
,
97 [T_STATE_FAIL
][T_RESULT_PASS
][T_SETUP
] = T_STATE_FAIL
,
98 [T_STATE_FAIL
][T_RESULT_FAIL
][T_SETUP
] = T_STATE_FAIL
,
99 [T_STATE_FAIL
][T_RESULT_UXPASS
][T_SETUP
] = T_STATE_FAIL
,
100 [T_STATE_FAIL
][T_RESULT_XFAIL
][T_SETUP
] = T_STATE_FAIL
,
102 [T_STATE_SETUPFAIL
][T_RESULT_PASS
][T_SETUP
] = T_STATE_SETUPFAIL
,
103 [T_STATE_SETUPFAIL
][T_RESULT_FAIL
][T_SETUP
] = T_STATE_SETUPFAIL
,
104 [T_STATE_SETUPFAIL
][T_RESULT_UXPASS
][T_SETUP
] = T_STATE_SETUPFAIL
,
105 [T_STATE_SETUPFAIL
][T_RESULT_XFAIL
][T_SETUP
] = T_STATE_SETUPFAIL
,
108 const char * ktest_testcase_result_tokens
[KTEST_NUM_TESTCASE_MODES
]
109 [KTEST_NUM_TESTCASE_STATES
] = {
110 [T_MAIN
][T_RESULT_PASS
] = "PASS",
111 [T_MAIN
][T_RESULT_FAIL
] = "FAIL",
112 [T_MAIN
][T_RESULT_UXPASS
] = "UXPASS",
113 [T_MAIN
][T_RESULT_XFAIL
] = "XFAIL",
114 [T_SETUP
][T_RESULT_PASS
] = "SETUP_PASS",
115 [T_SETUP
][T_RESULT_FAIL
] = "SETUP_FAIL",
116 [T_SETUP
][T_RESULT_UXPASS
] = "SETUP_UXPASS",
117 [T_SETUP
][T_RESULT_XFAIL
] = "SETUP_XFAIL",