]> git.saurik.com Git - apple/xnu.git/blob - osfmk/tests/ktest.h
xnu-4903.241.1.tar.gz
[apple/xnu.git] / osfmk / tests / ktest.h
1 /*
2 * Copyright (c) 2015 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #ifndef _TESTS_KTEST_H
30 #define _TESTS_KTEST_H
31
32 /* Symbol name prefix */
33 #define T_SYM(sym) ktest_ ## sym
34
35 #include <stdarg.h>
36
37 extern unsigned int T_SYM(current_line);
38 extern const char * T_SYM(current_file);
39 extern const char * T_SYM(current_func);
40 extern int T_SYM(testcase_mode);
41 extern int T_SYM(testcase_result);
42 extern int T_SYM(test_result);
43 extern int T_SYM(quiet);
44
45 void T_SYM(start)(void);
46 void T_SYM(finish)(void);
47 void T_SYM(testbegin)(const char * test_name);
48 void T_SYM(testend)(void);
49 void T_SYM(testskip)(const char * msg, ...);
50 void T_SYM(testcase)(int expr);
51 void T_SYM(log)(const char * msg, ...);
52 void T_SYM(perf)(const char * metric, const char * unit, double value, const char * desc);
53 void T_SYM(update_test_result_state)(void);
54 void T_SYM(assertion_check)(void);
55
56 void T_SYM(set_current_msg)(const char * msg, ...);
57 void T_SYM(set_current_expr)(const char * expr_fmt, ...);
58 void T_SYM(set_current_var)(const char * name, const char * value_fmt, ...);
59
60 typedef union {
61 char _char;
62 unsigned char _uchar;
63
64 short _short;
65 unsigned short _ushort;
66
67 int _int;
68 unsigned int _uint;
69
70 long _long;
71 unsigned long _ulong;
72
73 long long _llong;
74 unsigned long long _ullong;
75
76 float _float;
77
78 double _double;
79
80 long double _ldouble;
81
82 void* _ptr;
83 } T_SYM(temp);
84
85 extern T_SYM(temp) T_SYM(temp1), T_SYM(temp2), T_SYM(temp3);
86
87 #define T_SUCCESS 1
88 #define T_FAILURE 0
89
90 /* Testcase modes */
91 #define T_MAIN 0
92 #define T_SETUP 1
93
94 /* Testcase result states */
95 #define T_RESULT_PASS 0
96 #define T_RESULT_FAIL 1
97 #define T_RESULT_UXPASS 2
98 #define T_RESULT_XFAIL 3
99
100 /* Test result states */
101 #define T_STATE_UNRESOLVED 0
102 #define T_STATE_PASS 1
103 #define T_STATE_FAIL 2
104 #define T_STATE_SETUPFAIL 3
105
106 /*
107 * Helpers
108 */
109
110 #define T_TOSTRING_HELPER(x) #x
111 #define T_TOSTRING(x) T_TOSTRING_HELPER(x)
112
113 #define T_SAVEINFO do {\
114 T_SYM(current_line) = __LINE__;\
115 T_SYM(current_func) = (const char *)__func__;\
116 T_SYM(current_file) = (const char *)__FILE__;\
117 } while(0)
118
119 #define T_SET_AUX_VARS do {\
120 /* Only used in userspace lib for now */\
121 } while(0)
122
123 #define T_ASSERTION_CHECK do {\
124 T_SYM(assertion_check)();\
125 } while(0)
126
127 #define T_EXPECT_BLOCK2(type, fmt, cmp, lhs, rhs, msg, ...) do {\
128 T_SAVEINFO;\
129 T_SYM(temp1).type = (lhs);\
130 T_SYM(temp2).type = (rhs);\
131 T_SYM(set_current_expr)(T_TOSTRING(lhs) " "\
132 T_TOSTRING(cmp) " "\
133 T_TOSTRING(rhs));\
134 T_SYM(set_current_var)(T_TOSTRING(lhs), fmt, T_SYM(temp1).type);\
135 T_SYM(set_current_var)(T_TOSTRING(rhs), fmt, T_SYM(temp2).type);\
136 T_SET_AUX_VARS;\
137 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
138 T_SYM(testcase)(T_SYM(temp1).type cmp T_SYM(temp2).type);\
139 } while(0)
140
141 #define T_ASSERT_BLOCK2(type, fmt, cmp, lhs, rhs, msg, ...) do {\
142 T_EXPECT_BLOCK2(type, fmt, cmp, lhs, rhs, msg, ## __VA_ARGS__);\
143 T_ASSERTION_CHECK;\
144 } while(0)
145
146 /*
147 * Core functions
148 */
149
150 /* Denotes start of testing. All prior output is ignored. */
151 #define T_START do {\
152 T_SAVEINFO;\
153 T_SYM(start)();\
154 } while(0)
155
156 /* Denotes end of testing. All subsequent output is ignored. */
157 #define T_FINISH do {\
158 T_SAVEINFO;\
159 T_SYM(finish)();\
160 } while(0)
161
162 /* Denotes beginning of a test. */
163 #define T_BEGIN(name) do {\
164 T_SAVEINFO;\
165 T_SYM(testbegin)(name);\
166 } while(0)
167
168 /* Denotes end of current test. */
169 #define T_END do {\
170 T_SAVEINFO;\
171 T_SYM(testend)();\
172 } while(0)
173
174 /* Denotes beginning of a setup section of the current test. */
175 #define T_SETUPBEGIN do {\
176 T_SYM(testcase_mode) = T_SETUP;\
177 } while(0)
178
179 /* Denotes end of the current setup section of the current test. */
180 #define T_SETUPEND do {\
181 T_SYM(testcase_mode) = T_MAIN;\
182 } while(0)
183
184 /* Denotes end of current test because test was skipped. */
185 #define T_SKIP(msg, ...) do {\
186 T_SAVEINFO;\
187 T_SYM(testskip)(msg, ## __VA_ARGS__);\
188 } while(0)
189
190 /* Returns result of latest testrun. */
191 #define T_TESTRESULT (T_SYM(test_result))
192
193 /* Return result of latest testcase. */
194 #define T_TESTCASERESULT (T_SYM(testcase_result))
195
196 /* Flags the next testcase as expected failure. */
197 #define T_EXPECTFAIL do {\
198 T_SYM(expectfail) = 1;\
199 } while(0)
200
201 /* Only emit output for next testcase if it is a FAIL or UXPASS. */
202 #define T_QUIET do {\
203 T_SYM(quiet) = 1;\
204 } while(0)
205
206 /* Logs a message. */
207 #define T_LOG(msg, ...) do {\
208 T_SAVEINFO;\
209 T_SYM(log)(msg, ## __VA_ARGS__);\
210 } while(0)
211
212 /* Explicit pass. */
213 #define T_PASS(msg, ...) do {\
214 T_SAVEINFO;\
215 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
216 T_SYM(testcase)(T_SUCCESS);\
217 } while(0)
218
219 /* Explicit fail. */
220 #define T_FAIL(msg, ...) do {\
221 T_SAVEINFO;\
222 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
223 T_SYM(testcase)(T_FAILURE);\
224 } while(0)
225
226 /* Explicit assert fail. */
227 #define T_ASSERT_FAIL(msg, ...) do {\
228 T_SAVEINFO;\
229 T_SET_AUX_VARS;\
230 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
231 T_SYM(testcase)(T_FAILURE);\
232 T_SYM(assertion_fail)();\
233 } while(0)
234
235 /* Generic expect. */
236 #define T_EXPECT(expr, msg, ...) do {\
237 T_SAVEINFO;\
238 T_SYM(temp1)._int = (int)(!!(expr));\
239 T_SYM(set_current_expr)(T_TOSTRING(expr));\
240 T_SET_AUX_VARS;\
241 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
242 T_SYM(testcase)(T_SYM(temp1)._int);\
243 } while(0)
244
245 /* Generic assert. */
246 #define T_ASSERT(expr, msg, ...) do {\
247 T_EXPECT(expr, msg, ## __VA_ARGS__);\
248 T_ASSERTION_CHECK;\
249 } while(0)
250
251 /*
252 * Convenience functions
253 */
254
255 /* null */
256
257 #define T_EXPECT_NOTNULL(expr, msg, ...) do {\
258 T_SAVEINFO;\
259 T_SYM(temp1)._int = (int)(!!(expr));\
260 T_SYM(set_current_expr)(T_TOSTRING(expr) " != NULL");\
261 T_SYM(set_current_var)(T_TOSTRING(expr),\
262 "%s",\
263 T_SYM(temp1)._int ? "<NOTNULL>" : "NULL");\
264 T_SET_AUX_VARS;\
265 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
266 T_SYM(testcase)(T_SYM(temp1)._int);\
267 } while(0)
268
269 #define T_EXPECT_NULL(expr, msg, ...) do {\
270 T_SAVEINFO;\
271 T_SYM(temp1)._int = (int)(!(expr));\
272 T_SYM(set_current_expr)(T_TOSTRING(expr) " == NULL");\
273 T_SYM(set_current_var)(T_TOSTRING(expr),\
274 "%s",\
275 T_SYM(temp1)._int ? "NULL" : "<NOTNULL>");\
276 T_SET_AUX_VARS;\
277 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
278 T_SYM(testcase)(T_SYM(temp1)._int);\
279 } while(0)
280
281 #define T_ASSERT_NOTNULL(expr, msg, ...) do {\
282 T_EXPECT_NOTNULL(expr, msg, ## __VA_ARGS__);\
283 T_ASSERTION_CHECK;\
284 } while(0)
285
286 #define T_ASSERT_NULL(expr, msg, ...) do {\
287 T_EXPECT_NULL(expr, msg, ## __VA_ARGS__);\
288 T_ASSERTION_CHECK;\
289 } while(0)
290
291 /* string */
292
293 // TODO: check/truncate inputs
294 #define T_EXPECT_EQ_STR(lhs, rhs, msg, ...) do {\
295 T_SAVEINFO;\
296 T_SYM(temp1)._ptr = (lhs);\
297 T_SYM(temp2)._ptr = (rhs);\
298 T_SYM(set_current_expr)(T_TOSTRING(lhs) " == " T_TOSTRING(rhs));\
299 T_SYM(set_current_var)(T_TOSTRING(lhs), "%s", T_SYM(temp1)._ptr);\
300 T_SYM(set_current_var)(T_TOSTRING(rhs), "%s", T_SYM(temp2)._ptr);\
301 T_SET_AUX_VARS;\
302 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
303 T_SYM(testcase)(strcmp(T_SYM(temp1)._ptr, T_SYM(temp2)._ptr) == 0);\
304 } while(0)
305
306 #define T_EXPECT_NE_STR(lhs, rhs, msg, ...) do {\
307 T_SAVEINFO;\
308 T_SYM(temp1)._ptr = (lhs);\
309 T_SYM(temp2)._ptr = (rhs);\
310 T_SYM(set_current_expr)(T_TOSTRING(lhs) " == " T_TOSTRING(rhs));\
311 T_SYM(set_current_var)(T_TOSTRING(lhs), "%s", T_SYM(temp1)._ptr);\
312 T_SYM(set_current_var)(T_TOSTRING(rhs), "%s", T_SYM(temp2)._ptr);\
313 T_SET_AUX_VARS;\
314 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
315 T_SYM(testcase)(strcmp(T_SYM(temp1)._ptr, T_SYM(temp2)._ptr) != 0);\
316 } while(0)
317
318 #define T_ASSERT_EQ_STR(lhs, rhs, msg, ...) do {\
319 T_EXPECT_EQ_STR(lhs, rhs, msg, # __VA_ARGS__);\
320 T_ASSERTION_CHECK;\
321 } while(0)
322
323 #define T_ASSERT_NE_STR(lhs, rhs, msg, ...) do {\
324 T_EXPECT_NE_STR(lhs, rhs, msg, # __VA_ARGS__);\
325 T_ASSERTION_CHECK;\
326 } while(0)
327
328 /* char */
329
330 #define T_EXPECT_EQ_CHAR(lhs, rhs, msg, ...)\
331 T_EXPECT_BLOCK2(_char, "%c", ==, lhs, rhs, msg, ## __VA_ARGS__)
332 #define T_EXPECT_NE_CHAR(lhs, rhs, msg, ...)\
333 T_EXPECT_BLOCK2(_char, "%c", !=, lhs, rhs, msg, ## __VA_ARGS__)
334 #define T_EXPECT_LT_CHAR(lhs, rhs, msg, ...)\
335 T_EXPECT_BLOCK2(_char, "%c", <, lhs, rhs, msg, ## __VA_ARGS__)
336 #define T_EXPECT_GT_CHAR(lhs, rhs, msg, ...)\
337 T_EXPECT_BLOCK2(_char, "%c", >, lhs, rhs, msg, ## __VA_ARGS__)
338 #define T_EXPECT_LE_CHAR(lhs, rhs, msg, ...)\
339 T_EXPECT_BLOCK2(_char, "%c", <=, lhs, rhs, msg, ## __VA_ARGS__)
340 #define T_EXPECT_GE_CHAR(lhs, rhs, msg, ...)\
341 T_EXPECT_BLOCK2(_char, "%c", >=, lhs, rhs, msg, ## __VA_ARGS__)
342
343 #define T_ASSERT_EQ_CHAR(lhs, rhs, msg, ...)\
344 T_ASSERT_BLOCK2(_char, "%c", ==, lhs, rhs, msg, ## __VA_ARGS__)
345 #define T_ASSERT_NE_CHAR(lhs, rhs, msg, ...)\
346 T_ASSERT_BLOCK2(_char, "%c", !=, lhs, rhs, msg, ## __VA_ARGS__)
347 #define T_ASSERT_LT_CHAR(lhs, rhs, msg, ...)\
348 T_ASSERT_BLOCK2(_char, "%c", <, lhs, rhs, msg, ## __VA_ARGS__)
349 #define T_ASSERT_GT_CHAR(lhs, rhs, msg, ...)\
350 T_ASSERT_BLOCK2(_char, "%c", >, lhs, rhs, msg, ## __VA_ARGS__)
351 #define T_ASSERT_LE_CHAR(lhs, rhs, msg, ...)\
352 T_ASSERT_BLOCK2(_char, "%c", <=, lhs, rhs, msg, ## __VA_ARGS__)
353 #define T_ASSERT_GE_CHAR(lhs, rhs, msg, ...)\
354 T_ASSERT_BLOCK2(_char, "%c", >=, lhs, rhs, msg, ## __VA_ARGS__)
355
356 /* unsigned char */
357
358 #define T_EXPECT_EQ_UCHAR(lhs, rhs, msg, ...)\
359 T_EXPECT_BLOCK2(_uchar, "%c", ==, lhs, rhs, msg, ## __VA_ARGS__)
360 #define T_EXPECT_NE_UCHAR(lhs, rhs, msg, ...)\
361 T_EXPECT_BLOCK2(_uchar, "%c", !=, lhs, rhs, msg, ## __VA_ARGS__)
362 #define T_EXPECT_LT_UCHAR(lhs, rhs, msg, ...)\
363 T_EXPECT_BLOCK2(_uchar, "%c", <, lhs, rhs, msg, ## __VA_ARGS__)
364 #define T_EXPECT_GT_UCHAR(lhs, rhs, msg, ...)\
365 T_EXPECT_BLOCK2(_uchar, "%c", >, lhs, rhs, msg, ## __VA_ARGS__)
366 #define T_EXPECT_LE_UCHAR(lhs, rhs, msg, ...)\
367 T_EXPECT_BLOCK2(_uchar, "%c", <=, lhs, rhs, msg, ## __VA_ARGS__)
368 #define T_EXPECT_GE_UCHAR(lhs, rhs, msg, ...)\
369 T_EXPECT_BLOCK2(_uchar, "%c", >=, lhs, rhs, msg, ## __VA_ARGS__)
370
371 #define T_ASSERT_EQ_UCHAR(lhs, rhs, msg, ...)\
372 T_ASSERT_BLOCK2(_uchar, "%c", ==, lhs, rhs, msg, ## __VA_ARGS__)
373 #define T_ASSERT_NE_UCHAR(lhs, rhs, msg, ...)\
374 T_ASSERT_BLOCK2(_uchar, "%c", !=, lhs, rhs, msg, ## __VA_ARGS__)
375 #define T_ASSERT_LT_UCHAR(lhs, rhs, msg, ...)\
376 T_ASSERT_BLOCK2(_uchar, "%c", <, lhs, rhs, msg, ## __VA_ARGS__)
377 #define T_ASSERT_GT_UCHAR(lhs, rhs, msg, ...)\
378 T_ASSERT_BLOCK2(_uchar, "%c", >, lhs, rhs, msg, ## __VA_ARGS__)
379 #define T_ASSERT_LE_UCHAR(lhs, rhs, msg, ...)\
380 T_ASSERT_BLOCK2(_uchar, "%c", <=, lhs, rhs, msg, ## __VA_ARGS__)
381 #define T_ASSERT_GE_UCHAR(lhs, rhs, msg, ...)\
382 T_ASSERT_BLOCK2(_uchar, "%c", >=, lhs, rhs, msg, ## __VA_ARGS__)
383
384 /* short */
385
386 #define T_EXPECT_EQ_SHORT(lhs, rhs, msg, ...)\
387 T_EXPECT_BLOCK2(_short, "%hi", ==, lhs, rhs, msg, ## __VA_ARGS__)
388 #define T_EXPECT_NE_SHORT(lhs, rhs, msg, ...)\
389 T_EXPECT_BLOCK2(_short, "%hi", !=, lhs, rhs, msg, ## __VA_ARGS__)
390 #define T_EXPECT_LT_SHORT(lhs, rhs, msg, ...)\
391 T_EXPECT_BLOCK2(_short, "%hi", <, lhs, rhs, msg, ## __VA_ARGS__)
392 #define T_EXPECT_GT_SHORT(lhs, rhs, msg, ...)\
393 T_EXPECT_BLOCK2(_short, "%hi", >, lhs, rhs, msg, ## __VA_ARGS__)
394 #define T_EXPECT_LE_SHORT(lhs, rhs, msg, ...)\
395 T_EXPECT_BLOCK2(_short, "%hi", <=, lhs, rhs, msg, ## __VA_ARGS__)
396 #define T_EXPECT_GE_SHORT(lhs, rhs, msg, ...)\
397 T_EXPECT_BLOCK2(_short, "%hi", >=, lhs, rhs, msg, ## __VA_ARGS__)
398
399 #define T_ASSERT_EQ_SHORT(lhs, rhs, msg, ...)\
400 T_ASSERT_BLOCK2(_short, "%hi", ==, lhs, rhs, msg, ## __VA_ARGS__)
401 #define T_ASSERT_NE_SHORT(lhs, rhs, msg, ...)\
402 T_ASSERT_BLOCK2(_short, "%hi", !=, lhs, rhs, msg, ## __VA_ARGS__)
403 #define T_ASSERT_LT_SHORT(lhs, rhs, msg, ...)\
404 T_ASSERT_BLOCK2(_short, "%hi", <, lhs, rhs, msg, ## __VA_ARGS__)
405 #define T_ASSERT_GT_SHORT(lhs, rhs, msg, ...)\
406 T_ASSERT_BLOCK2(_short, "%hi", >, lhs, rhs, msg, ## __VA_ARGS__)
407 #define T_ASSERT_LE_SHORT(lhs, rhs, msg, ...)\
408 T_ASSERT_BLOCK2(_short, "%hi", <=, lhs, rhs, msg, ## __VA_ARGS__)
409 #define T_ASSERT_GE_SHORT(lhs, rhs, msg, ...)\
410 T_ASSERT_BLOCK2(_short, "%hi", >=, lhs, rhs, msg, ## __VA_ARGS__)
411
412 /* unsigned short */
413
414 #define T_EXPECT_EQ_USHORT(lhs, rhs, msg, ...)\
415 T_EXPECT_BLOCK2(_ushort, "%hu", ==, lhs, rhs, msg, ## __VA_ARGS__)
416 #define T_EXPECT_NE_USHORT(lhs, rhs, msg, ...)\
417 T_EXPECT_BLOCK2(_ushort, "%hu", !=, lhs, rhs, msg, ## __VA_ARGS__)
418 #define T_EXPECT_LT_USHORT(lhs, rhs, msg, ...)\
419 T_EXPECT_BLOCK2(_ushort, "%hu", <, lhs, rhs, msg, ## __VA_ARGS__)
420 #define T_EXPECT_GT_USHORT(lhs, rhs, msg, ...)\
421 T_EXPECT_BLOCK2(_ushort, "%hu", >, lhs, rhs, msg, ## __VA_ARGS__)
422 #define T_EXPECT_LE_USHORT(lhs, rhs, msg, ...)\
423 T_EXPECT_BLOCK2(_ushort, "%hu", <=, lhs, rhs, msg, ## __VA_ARGS__)
424 #define T_EXPECT_GE_USHORT(lhs, rhs, msg, ...)\
425 T_EXPECT_BLOCK2(_ushort, "%hu", >=, lhs, rhs, msg, ## __VA_ARGS__)
426
427 #define T_ASSERT_EQ_USHORT(lhs, rhs, msg, ...)\
428 T_ASSERT_BLOCK2(_ushort, "%hu", ==, lhs, rhs, msg, ## __VA_ARGS__)
429 #define T_ASSERT_NE_USHORT(lhs, rhs, msg, ...)\
430 T_ASSERT_BLOCK2(_ushort, "%hu", !=, lhs, rhs, msg, ## __VA_ARGS__)
431 #define T_ASSERT_LT_USHORT(lhs, rhs, msg, ...)\
432 T_ASSERT_BLOCK2(_ushort, "%hu", <, lhs, rhs, msg, ## __VA_ARGS__)
433 #define T_ASSERT_GT_USHORT(lhs, rhs, msg, ...)\
434 T_ASSERT_BLOCK2(_ushort, "%hu", >, lhs, rhs, msg, ## __VA_ARGS__)
435 #define T_ASSERT_LE_USHORT(lhs, rhs, msg, ...)\
436 T_ASSERT_BLOCK2(_ushort, "%hu", <=, lhs, rhs, msg, ## __VA_ARGS__)
437 #define T_ASSERT_GE_USHORT(lhs, rhs, msg, ...)\
438 T_ASSERT_BLOCK2(_ushort, "%hu", >=, lhs, rhs, msg, ## __VA_ARGS__)
439
440 /* int */
441
442 #define T_EXPECT_EQ_INT(lhs, rhs, msg, ...)\
443 T_EXPECT_BLOCK2(_int, "%d", ==, lhs, rhs, msg, ## __VA_ARGS__)
444 #define T_EXPECT_NE_INT(lhs, rhs, msg, ...)\
445 T_EXPECT_BLOCK2(_int, "%d", !=, lhs, rhs, msg, ## __VA_ARGS__)
446 #define T_EXPECT_LT_INT(lhs, rhs, msg, ...)\
447 T_EXPECT_BLOCK2(_int, "%d", <, lhs, rhs, msg, ## __VA_ARGS__)
448 #define T_EXPECT_GT_INT(lhs, rhs, msg, ...)\
449 T_EXPECT_BLOCK2(_int, "%d", >, lhs, rhs, msg, ## __VA_ARGS__)
450 #define T_EXPECT_LE_INT(lhs, rhs, msg, ...)\
451 T_EXPECT_BLOCK2(_int, "%d", <=, lhs, rhs, msg, ## __VA_ARGS__)
452 #define T_EXPECT_GE_INT(lhs, rhs, msg, ...)\
453 T_EXPECT_BLOCK2(_int, "%d", >=, lhs, rhs, msg, ## __VA_ARGS__)
454
455 #define T_ASSERT_EQ_INT(lhs, rhs, msg, ...)\
456 T_ASSERT_BLOCK2(_int, "%d", ==, lhs, rhs, msg, ## __VA_ARGS__)
457 #define T_ASSERT_NE_INT(lhs, rhs, msg, ...)\
458 T_ASSERT_BLOCK2(_int, "%d", !=, lhs, rhs, msg, ## __VA_ARGS__)
459 #define T_ASSERT_LT_INT(lhs, rhs, msg, ...)\
460 T_ASSERT_BLOCK2(_int, "%d", <, lhs, rhs, msg, ## __VA_ARGS__)
461 #define T_ASSERT_GT_INT(lhs, rhs, msg, ...)\
462 T_ASSERT_BLOCK2(_int, "%d", >, lhs, rhs, msg, ## __VA_ARGS__)
463 #define T_ASSERT_LE_INT(lhs, rhs, msg, ...)\
464 T_ASSERT_BLOCK2(_int, "%d", <=, lhs, rhs, msg, ## __VA_ARGS__)
465 #define T_ASSERT_GE_INT(lhs, rhs, msg, ...)\
466 T_ASSERT_BLOCK2(_int, "%d", >=, lhs, rhs, msg, ## __VA_ARGS__)
467
468 /* unsigned int */
469
470 #define T_EXPECT_EQ_UINT(lhs, rhs, msg, ...)\
471 T_EXPECT_BLOCK2(_uint, "%u", ==, lhs, rhs, msg, ## __VA_ARGS__)
472 #define T_EXPECT_NE_UINT(lhs, rhs, msg, ...)\
473 T_EXPECT_BLOCK2(_uint, "%u", !=, lhs, rhs, msg, ## __VA_ARGS__)
474 #define T_EXPECT_LT_UINT(lhs, rhs, msg, ...)\
475 T_EXPECT_BLOCK2(_uint, "%u", <, lhs, rhs, msg, ## __VA_ARGS__)
476 #define T_EXPECT_GT_UINT(lhs, rhs, msg, ...)\
477 T_EXPECT_BLOCK2(_uint, "%u", >, lhs, rhs, msg, ## __VA_ARGS__)
478 #define T_EXPECT_LE_UINT(lhs, rhs, msg, ...)\
479 T_EXPECT_BLOCK2(_uint, "%u", <=, lhs, rhs, msg, ## __VA_ARGS__)
480 #define T_EXPECT_GE_UINT(lhs, rhs, msg, ...)\
481 T_EXPECT_BLOCK2(_uint, "%u", >=, lhs, rhs, msg, ## __VA_ARGS__)
482
483 #define T_ASSERT_EQ_UINT(lhs, rhs, msg, ...)\
484 T_ASSERT_BLOCK2(_uint, "%u", ==, lhs, rhs, msg, ## __VA_ARGS__)
485 #define T_ASSERT_NE_UINT(lhs, rhs, msg, ...)\
486 T_ASSERT_BLOCK2(_uint, "%u", !=, lhs, rhs, msg, ## __VA_ARGS__)
487 #define T_ASSERT_LT_UINT(lhs, rhs, msg, ...)\
488 T_ASSERT_BLOCK2(_uint, "%u", <, lhs, rhs, msg, ## __VA_ARGS__)
489 #define T_ASSERT_GT_UINT(lhs, rhs, msg, ...)\
490 T_ASSERT_BLOCK2(_uint, "%u", >, lhs, rhs, msg, ## __VA_ARGS__)
491 #define T_ASSERT_LE_UINT(lhs, rhs, msg, ...)\
492 T_ASSERT_BLOCK2(_uint, "%u", <=, lhs, rhs, msg, ## __VA_ARGS__)
493 #define T_ASSERT_GE_UINT(lhs, rhs, msg, ...)\
494 T_ASSERT_BLOCK2(_uint, "%u", >=, lhs, rhs, msg, ## __VA_ARGS__)
495
496 /* long */
497
498 #define T_EXPECT_EQ_LONG(lhs, rhs, msg, ...)\
499 T_EXPECT_BLOCK2(_long, "%li", ==, lhs, rhs, msg, ## __VA_ARGS__)
500 #define T_EXPECT_NE_LONG(lhs, rhs, msg, ...)\
501 T_EXPECT_BLOCK2(_long, "%li", !=, lhs, rhs, msg, ## __VA_ARGS__)
502 #define T_EXPECT_LT_LONG(lhs, rhs, msg, ...)\
503 T_EXPECT_BLOCK2(_long, "%li", <, lhs, rhs, msg, ## __VA_ARGS__)
504 #define T_EXPECT_GT_LONG(lhs, rhs, msg, ...)\
505 T_EXPECT_BLOCK2(_long, "%li", >, lhs, rhs, msg, ## __VA_ARGS__)
506 #define T_EXPECT_LE_LONG(lhs, rhs, msg, ...)\
507 T_EXPECT_BLOCK2(_long, "%li", <=, lhs, rhs, msg, ## __VA_ARGS__)
508 #define T_EXPECT_GE_LONG(lhs, rhs, msg, ...)\
509 T_EXPECT_BLOCK2(_long, "%li", >=, lhs, rhs, msg, ## __VA_ARGS__)
510
511 #define T_ASSERT_EQ_LONG(lhs, rhs, msg, ...)\
512 T_ASSERT_BLOCK2(_long, "%li", ==, lhs, rhs, msg, ## __VA_ARGS__)
513 #define T_ASSERT_NE_LONG(lhs, rhs, msg, ...)\
514 T_ASSERT_BLOCK2(_long, "%li", !=, lhs, rhs, msg, ## __VA_ARGS__)
515 #define T_ASSERT_LT_LONG(lhs, rhs, msg, ...)\
516 T_ASSERT_BLOCK2(_long, "%li", <, lhs, rhs, msg, ## __VA_ARGS__)
517 #define T_ASSERT_GT_LONG(lhs, rhs, msg, ...)\
518 T_ASSERT_BLOCK2(_long, "%li", >, lhs, rhs, msg, ## __VA_ARGS__)
519 #define T_ASSERT_LE_LONG(lhs, rhs, msg, ...)\
520 T_ASSERT_BLOCK2(_long, "%li", <=, lhs, rhs, msg, ## __VA_ARGS__)
521 #define T_ASSERT_GE_LONG(lhs, rhs, msg, ...)\
522 T_ASSERT_BLOCK2(_long, "%li", >=, lhs, rhs, msg, ## __VA_ARGS__)
523
524 /* unsigned long */
525
526 #define T_EXPECT_EQ_ULONG(lhs, rhs, msg, ...)\
527 T_EXPECT_BLOCK2(_ulong, "%lu", ==, lhs, rhs, msg, ## __VA_ARGS__)
528 #define T_EXPECT_NE_ULONG(lhs, rhs, msg, ...)\
529 T_EXPECT_BLOCK2(_ulong, "%lu", !=, lhs, rhs, msg, ## __VA_ARGS__)
530 #define T_EXPECT_LT_ULONG(lhs, rhs, msg, ...)\
531 T_EXPECT_BLOCK2(_ulong, "%lu", <, lhs, rhs, msg, ## __VA_ARGS__)
532 #define T_EXPECT_GT_ULONG(lhs, rhs, msg, ...)\
533 T_EXPECT_BLOCK2(_ulong, "%lu", >, lhs, rhs, msg, ## __VA_ARGS__)
534 #define T_EXPECT_LE_ULONG(lhs, rhs, msg, ...)\
535 T_EXPECT_BLOCK2(_ulong, "%lu", <=, lhs, rhs, msg, ## __VA_ARGS__)
536 #define T_EXPECT_GE_ULONG(lhs, rhs, msg, ...)\
537 T_EXPECT_BLOCK2(_ulong, "%lu", >=, lhs, rhs, msg, ## __VA_ARGS__)
538
539 #define T_ASSERT_EQ_ULONG(lhs, rhs, msg, ...)\
540 T_ASSERT_BLOCK2(_ulong, "%lu", ==, lhs, rhs, msg, ## __VA_ARGS__)
541 #define T_ASSERT_NE_ULONG(lhs, rhs, msg, ...)\
542 T_ASSERT_BLOCK2(_ulong, "%lu", !=, lhs, rhs, msg, ## __VA_ARGS__)
543 #define T_ASSERT_LT_ULONG(lhs, rhs, msg, ...)\
544 T_ASSERT_BLOCK2(_ulong, "%lu", <, lhs, rhs, msg, ## __VA_ARGS__)
545 #define T_ASSERT_GT_ULONG(lhs, rhs, msg, ...)\
546 T_ASSERT_BLOCK2(_ulong, "%lu", >, lhs, rhs, msg, ## __VA_ARGS__)
547 #define T_ASSERT_LE_ULONG(lhs, rhs, msg, ...)\
548 T_ASSERT_BLOCK2(_ulong, "%lu", <=, lhs, rhs, msg, ## __VA_ARGS__)
549 #define T_ASSERT_GE_ULONG(lhs, rhs, msg, ...)\
550 T_ASSERT_BLOCK2(_ulong, "%lu", >=, lhs, rhs, msg, ## __VA_ARGS__)
551
552 /* long long */
553
554 #define T_EXPECT_EQ_LLONG(lhs, rhs, msg, ...)\
555 T_EXPECT_BLOCK2(_llong, "%lli", ==, lhs, rhs, msg, ## __VA_ARGS__)
556 #define T_EXPECT_NE_LLONG(lhs, rhs, msg, ...)\
557 T_EXPECT_BLOCK2(_llong, "%lli", !=, lhs, rhs, msg, ## __VA_ARGS__)
558 #define T_EXPECT_LT_LLONG(lhs, rhs, msg, ...)\
559 T_EXPECT_BLOCK2(_llong, "%lli", <, lhs, rhs, msg, ## __VA_ARGS__)
560 #define T_EXPECT_GT_LLONG(lhs, rhs, msg, ...)\
561 T_EXPECT_BLOCK2(_llong, "%lli", >, lhs, rhs, msg, ## __VA_ARGS__)
562 #define T_EXPECT_LE_LLONG(lhs, rhs, msg, ...)\
563 T_EXPECT_BLOCK2(_llong, "%lli", <=, lhs, rhs, msg, ## __VA_ARGS__)
564 #define T_EXPECT_GE_LLONG(lhs, rhs, msg, ...)\
565 T_EXPECT_BLOCK2(_llong, "%lli", >=, lhs, rhs, msg, ## __VA_ARGS__)
566
567 #define T_ASSERT_EQ_LLONG(lhs, rhs, msg, ...)\
568 T_ASSERT_BLOCK2(_llong, "%lli", ==, lhs, rhs, msg, ## __VA_ARGS__)
569 #define T_ASSERT_NE_LLONG(lhs, rhs, msg, ...)\
570 T_ASSERT_BLOCK2(_llong, "%lli", !=, lhs, rhs, msg, ## __VA_ARGS__)
571 #define T_ASSERT_LT_LLONG(lhs, rhs, msg, ...)\
572 T_ASSERT_BLOCK2(_llong, "%lli", <, lhs, rhs, msg, ## __VA_ARGS__)
573 #define T_ASSERT_GT_LLONG(lhs, rhs, msg, ...)\
574 T_ASSERT_BLOCK2(_llong, "%lli", >, lhs, rhs, msg, ## __VA_ARGS__)
575 #define T_ASSERT_LE_LLONG(lhs, rhs, msg, ...)\
576 T_ASSERT_BLOCK2(_llong, "%lli", <=, lhs, rhs, msg, ## __VA_ARGS__)
577 #define T_ASSERT_GE_LLONG(lhs, rhs, msg, ...)\
578 T_ASSERT_BLOCK2(_llong, "%lli", >=, lhs, rhs, msg, ## __VA_ARGS__)
579
580 /* unsigned long long */
581
582 #define T_EXPECT_EQ_ULLONG(lhs, rhs, msg, ...)\
583 T_EXPECT_BLOCK2(_ullong, "%llu", ==, lhs, rhs, msg, ## __VA_ARGS__)
584 #define T_EXPECT_NE_ULLONG(lhs, rhs, msg, ...)\
585 T_EXPECT_BLOCK2(_ullong, "%llu", !=, lhs, rhs, msg, ## __VA_ARGS__)
586 #define T_EXPECT_LT_ULLONG(lhs, rhs, msg, ...)\
587 T_EXPECT_BLOCK2(_ullong, "%llu", <, lhs, rhs, msg, ## __VA_ARGS__)
588 #define T_EXPECT_GT_ULLONG(lhs, rhs, msg, ...)\
589 T_EXPECT_BLOCK2(_ullong, "%llu", >, lhs, rhs, msg, ## __VA_ARGS__)
590 #define T_EXPECT_LE_ULLONG(lhs, rhs, msg, ...)\
591 T_EXPECT_BLOCK2(_ullong, "%llu", <=, lhs, rhs, msg, ## __VA_ARGS__)
592 #define T_EXPECT_GE_ULLONG(lhs, rhs, msg, ...)\
593 T_EXPECT_BLOCK2(_ullong, "%llu", >=, lhs, rhs, msg, ## __VA_ARGS__)
594
595 #define T_ASSERT_EQ_ULLONG(lhs, rhs, msg, ...)\
596 T_ASSERT_BLOCK2(_ullong, "%llu", ==, lhs, rhs, msg, ## __VA_ARGS__)
597 #define T_ASSERT_NE_ULLONG(lhs, rhs, msg, ...)\
598 T_ASSERT_BLOCK2(_ullong, "%llu", !=, lhs, rhs, msg, ## __VA_ARGS__)
599 #define T_ASSERT_LT_ULLONG(lhs, rhs, msg, ...)\
600 T_ASSERT_BLOCK2(_ullong, "%llu", <, lhs, rhs, msg, ## __VA_ARGS__)
601 #define T_ASSERT_GT_ULLONG(lhs, rhs, msg, ...)\
602 T_ASSERT_BLOCK2(_ullong, "%llu", >, lhs, rhs, msg, ## __VA_ARGS__)
603 #define T_ASSERT_LE_ULLONG(lhs, rhs, msg, ...)\
604 T_ASSERT_BLOCK2(_ullong, "%llu", <=, lhs, rhs, msg, ## __VA_ARGS__)
605 #define T_ASSERT_GE_ULLONG(lhs, rhs, msg, ...)\
606 T_ASSERT_BLOCK2(_ullong, "%llu", >=, lhs, rhs, msg, ## __VA_ARGS__)
607
608 /* pointer */
609
610 #define T_EXPECT_EQ_PTR(lhs, rhs, msg, ...)\
611 T_EXPECT_BLOCK2(_ptr, "%p", ==, lhs, rhs, msg, ## __VA_ARGS__)
612 #define T_EXPECT_NE_PTR(lhs, rhs, msg, ...)\
613 T_EXPECT_BLOCK2(_ptr, "%p", !=, lhs, rhs, msg, ## __VA_ARGS__)
614 #define T_EXPECT_LT_PTR(lhs, rhs, msg, ...)\
615 T_EXPECT_BLOCK2(_ptr, "%p", <, lhs, rhs, msg, ## __VA_ARGS__)
616 #define T_EXPECT_GT_PTR(lhs, rhs, msg, ...)\
617 T_EXPECT_BLOCK2(_ptr, "%p", >, lhs, rhs, msg, ## __VA_ARGS__)
618 #define T_EXPECT_LE_PTR(lhs, rhs, msg, ...)\
619 T_EXPECT_BLOCK2(_ptr, "%p", <=, lhs, rhs, msg, ## __VA_ARGS__)
620 #define T_EXPECT_GE_PTR(lhs, rhs, msg, ...)\
621 T_EXPECT_BLOCK2(_ptr, "%p", >=, lhs, rhs, msg, ## __VA_ARGS__)
622
623 #define T_ASSERT_EQ_PTR(lhs, rhs, msg, ...)\
624 T_ASSERT_BLOCK2(_ptr, "%p", ==, lhs, rhs, msg, ## __VA_ARGS__)
625 #define T_ASSERT_NE_PTR(lhs, rhs, msg, ...)\
626 T_ASSERT_BLOCK2(_ptr, "%p", !=, lhs, rhs, msg, ## __VA_ARGS__)
627 #define T_ASSERT_LT_PTR(lhs, rhs, msg, ...)\
628 T_ASSERT_BLOCK2(_ptr, "%p", <, lhs, rhs, msg, ## __VA_ARGS__)
629 #define T_ASSERT_GT_PTR(lhs, rhs, msg, ...)\
630 T_ASSERT_BLOCK2(_ptr, "%p", >, lhs, rhs, msg, ## __VA_ARGS__)
631 #define T_ASSERT_LE_PTR(lhs, rhs, msg, ...)\
632 T_ASSERT_BLOCK2(_ptr, "%p", <=, lhs, rhs, msg, ## __VA_ARGS__)
633 #define T_ASSERT_GE_PTR(lhs, rhs, msg, ...)\
634 T_ASSERT_BLOCK2(_ptr, "%p", >=, lhs, rhs, msg, ## __VA_ARGS__)
635
636 /*
637 * Log a perfdata measurement. For example:
638 * T_PERF("name_of_metric", 3234, "nsec", "time since first test run")
639 */
640 #define T_PERF(metric, value, unit, desc) \
641 do { \
642 T_SAVEINFO; \
643 T_SYM(perf)(metric, unit, value, desc); \
644 } while (0)
645
646 #endif /* _TESTS_KTEST_H */