]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/tests/ktest.h
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 #ifndef _TESTS_KTEST_H
30 #define _TESTS_KTEST_H
32 /* Symbol name prefix */
33 #define T_SYM(sym) ktest_ ## sym
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
);
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);
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
, ...);
65 unsigned short _ushort
;
74 unsigned long long _ullong
;
85 extern T_SYM(temp
) T_SYM(temp1
), T_SYM(temp2
), T_SYM(temp3
);
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
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
110 #define T_TOSTRING_HELPER(x) #x
111 #define T_TOSTRING(x) T_TOSTRING_HELPER(x)
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__;\
119 #define T_SET_AUX_VARS do {\
120 /* Only used in userspace lib for now */ \
123 #define T_ASSERTION_CHECK do {\
124 T_SYM(assertion_check)();\
127 #define T_EXPECT_BLOCK2(type, fmt, cmp, lhs, rhs, msg, ...) do {\
129 T_SYM(temp1).type = (lhs);\
130 T_SYM(temp2).type = (rhs);\
131 T_SYM(set_current_expr)(T_TOSTRING(lhs) " "\
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);\
137 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
138 T_SYM(testcase)(T_SYM(temp1).type cmp T_SYM(temp2).type);\
141 #define T_ASSERT_BLOCK2(type, fmt, cmp, lhs, rhs, msg, ...) do {\
142 T_EXPECT_BLOCK2(type, fmt, cmp, lhs, rhs, msg, ## __VA_ARGS__);\
150 /* Denotes start of testing. All prior output is ignored. */
151 #define T_START do {\
156 /* Denotes end of testing. All subsequent output is ignored. */
157 #define T_FINISH do {\
162 /* Denotes beginning of a test. */
163 #define T_BEGIN(name) do {\
165 T_SYM(testbegin)(name);\
168 /* Denotes end of current test. */
174 /* Denotes beginning of a setup section of the current test. */
175 #define T_SETUPBEGIN do {\
176 T_SYM(testcase_mode) = T_SETUP;\
179 /* Denotes end of the current setup section of the current test. */
180 #define T_SETUPEND do {\
181 T_SYM(testcase_mode) = T_MAIN;\
184 /* Denotes end of current test because test was skipped. */
185 #define T_SKIP(msg, ...) do {\
187 T_SYM(testskip)(msg, ## __VA_ARGS__);\
190 /* Returns result of latest testrun. */
191 #define T_TESTRESULT (T_SYM(test_result))
193 /* Return result of latest testcase. */
194 #define T_TESTCASERESULT (T_SYM(testcase_result))
196 /* Flags the next testcase as expected failure. */
197 #define T_EXPECTFAIL do {\
198 T_SYM(expectfail) = 1;\
201 /* Only emit output for next testcase if it is a FAIL or UXPASS. */
202 #define T_QUIET do {\
206 /* Logs a message. */
207 #define T_LOG(msg, ...) do {\
209 T_SYM(log)(msg, ## __VA_ARGS__);\
213 #define T_PASS(msg, ...) do {\
215 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
216 T_SYM(testcase)(T_SUCCESS);\
220 #define T_FAIL(msg, ...) do {\
222 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
223 T_SYM(testcase)(T_FAILURE);\
226 /* Explicit assert fail. */
227 #define T_ASSERT_FAIL(msg, ...) do {\
230 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
231 T_SYM(testcase)(T_FAILURE);\
232 T_SYM(assertion_fail)();\
235 /* Generic expect. */
236 #define T_EXPECT(expr, msg, ...) do {\
238 T_SYM(temp1)._int = (int)(!!(expr));\
239 T_SYM(set_current_expr)(T_TOSTRING(expr));\
241 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
242 T_SYM(testcase)(T_SYM(temp1)._int);\
245 /* Generic assert. */
246 #define T_ASSERT(expr, msg, ...) do {\
247 T_EXPECT(expr, msg, ## __VA_ARGS__);\
252 * Convenience functions
257 #define T_EXPECT_NOTNULL(expr, msg, ...) do {\
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),\
263 T_SYM(temp1)._int ? "<NOTNULL>" : "NULL");\
265 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
266 T_SYM(testcase)(T_SYM(temp1)._int);\
269 #define T_EXPECT_NULL(expr, msg, ...) do {\
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),\
275 T_SYM(temp1)._int ? "NULL" : "<NOTNULL>");\
277 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
278 T_SYM(testcase)(T_SYM(temp1)._int);\
281 #define T_ASSERT_NOTNULL(expr, msg, ...) do {\
282 T_EXPECT_NOTNULL(expr, msg, ## __VA_ARGS__);\
286 #define T_ASSERT_NULL(expr, msg, ...) do {\
287 T_EXPECT_NULL(expr, msg, ## __VA_ARGS__);\
293 // TODO: check/truncate inputs
294 #define T_EXPECT_EQ_STR(lhs, rhs, msg, ...) do {\
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);\
302 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
303 T_SYM(testcase)(strcmp(T_SYM(temp1)._ptr, T_SYM(temp2)._ptr) == 0);\
306 #define T_EXPECT_NE_STR(lhs, rhs, msg, ...) do {\
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);\
314 T_SYM(set_current_msg)(msg, ## __VA_ARGS__);\
315 T_SYM(testcase)(strcmp(T_SYM(temp1)._ptr, T_SYM(temp2)._ptr) != 0);\
318 #define T_ASSERT_EQ_STR(lhs, rhs, msg, ...) do {\
319 T_EXPECT_EQ_STR(lhs, rhs, msg, # __VA_ARGS__);\
323 #define T_ASSERT_NE_STR(lhs, rhs, msg, ...) do {\
324 T_EXPECT_NE_STR(lhs, rhs, msg, # __VA_ARGS__);\
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
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__)
580 /* unsigned long long */
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__)
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__)
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__)
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__)
637 * Log a perfdata measurement. For example:
638 * T_PERF("name_of_metric", 3234, "nsec", "time since first test run")
640 #define T_PERF(metric, value, unit, desc) \
643 T_SYM(perf)(metric, unit, value, desc); \
646 #endif /* _TESTS_KTEST_H */