Lines Matching full:test
3 * Base unit test (KUnit) API.
55 * enum kunit_status - Type of result for a test or test suite
56 * @KUNIT_SUCCESS: Denotes the test suite has not failed nor been skipped
57 * @KUNIT_FAILURE: Denotes the test has failed.
58 * @KUNIT_SKIPPED: Denotes the test has been skipped.
83 /* Holds attributes for each test case and suite */
89 * struct kunit_case - represents an individual test case.
91 * @run_case: the function representing the actual test case.
92 * @name: the name of the test case.
94 * @attr: the attributes associated with the test
95 * @param_init: The init function to run before a parameterized test.
96 * @param_exit: The exit function to run after a parameterized test.
98 * A test case is a function with the signature,
101 * KUNIT_ASSERT_TRUE()) about code under test. Each test case is associated
105 * A test case should be static and should only be created with the
106 * KUNIT_CASE() macro; additionally, every array of test cases should be
107 * terminated with an empty test case.
113 * void add_test_basic(struct kunit *test)
115 * KUNIT_EXPECT_EQ(test, 1, add(1, 0));
116 * KUNIT_EXPECT_EQ(test, 2, add(1, 1));
117 * KUNIT_EXPECT_EQ(test, 0, add(-1, 1));
118 * KUNIT_EXPECT_EQ(test, INT_MAX, add(0, INT_MAX));
119 * KUNIT_EXPECT_EQ(test, -1, add(INT_MAX, INT_MIN));
129 void (*run_case)(struct kunit *test);
131 const void* (*generate_params)(struct kunit *test,
134 int (*param_init)(struct kunit *test);
135 void (*param_exit)(struct kunit *test);
158 * @test_name: a reference to a test case function.
160 * Takes a symbol for a function representing a test case and creates a
172 * @test_name: a reference to a test case function.
174 * test attributes
184 * @test_name: a reference to a test case function.
194 * @test_name: a reference to a test case function.
216 * @test_name: a reference to a test case function.
219 * test attributes
227 * KUNIT_CASE_PARAM_WITH_INIT - Define a parameterized KUnit test case with custom
229 * @test_name: The function implementing the test case.
230 * @gen_params: The function to generate parameters for the test case.
231 * @init: A reference to the param_init() function to run before a parameterized test.
232 * @exit: A reference to the param_exit() function to run after a parameterized test.
235 * param_init/exit will be passed the parameterized test context and run once
236 * before and once after the parameterized test. The init function can be used
239 * that were not managed by the parameterized test, and any other teardown logic.
254 * @name: the name of the test. Purely informational.
255 * @suite_init: called once per test suite before the test cases.
256 * @suite_exit: called once per test suite after all test cases.
257 * @init: called before every test case.
258 * @exit: called after every test case.
259 * @test_cases: a null terminated array of test cases.
260 * @attr: the attributes associated with the test suite
263 * @init is called before every test case and @exit is called after every
264 * test case, similar to the notion of a *test fixture* or a *test class*
277 int (*init)(struct kunit *test);
278 void (*exit)(struct kunit *test);
299 * Reference to the parameter array for a parameterized test. This
301 * parameterized test context struct kunit via kunit_register_params_array().
305 void (*get_description)(struct kunit *test, const void *param, char *desc);
311 * struct kunit - represents a running instance of a test.
319 * Used to store information about the current context under which the test
322 * @params_array which can be used by the test writer to store arbitrary data,
334 /* param_value is the current parameter value for a test case. */
340 * test case; thus, it is safe to update this across multiple
342 * be read after the test case finishes once all threads associated
343 * with the test case have terminated.
345 spinlock_t lock; /* Guards all mutable test state. */
349 * new resources) from any thread associated with a test case, we must
355 /* Saves the last seen test. Useful to help with faults. */
359 static inline void kunit_set_failure(struct kunit *test)
361 WRITE_ONCE(test->status, KUNIT_FAILURE);
371 void kunit_init_test(struct kunit *test, const char *name, struct string_stream *log);
399 const void *kunit_array_gen_params(struct kunit *test, const void *prev, char *desc);
421 * Registers @suites with the test framework.
457 * Also, do not mark the suite or test case structs with __initdata because
473 * kunit_kmalloc_array() - Like kmalloc_array() except the allocation is *test managed*.
474 * @test: The test context object.
479 * Just like `kmalloc_array(...)`, except the allocation is managed by the test case
480 * and is automatically cleaned up after the test case concludes. See kunit_add_action()
486 void *kunit_kmalloc_array(struct kunit *test, size_t n, size_t size, gfp_t gfp);
489 * kunit_kmalloc() - Like kmalloc() except the allocation is *test managed*.
490 * @test: The test context object.
499 static inline void *kunit_kmalloc(struct kunit *test, size_t size, gfp_t gfp)
501 return kunit_kmalloc_array(test, 1, size, gfp);
506 * @test: The test case to which the resource belongs.
509 void kunit_kfree(struct kunit *test, const void *ptr);
513 * @test: The test context object.
519 static inline void *kunit_kzalloc(struct kunit *test, size_t size, gfp_t gfp)
521 return kunit_kmalloc(test, size, gfp | __GFP_ZERO);
526 * @test: The test context object.
533 static inline void *kunit_kcalloc(struct kunit *test, size_t n, size_t size, gfp_t gfp)
535 return kunit_kmalloc_array(test, n, size, gfp | __GFP_ZERO);
540 * kunit_kfree_const() - conditionally free test managed memory
541 * @test: The test context object.
547 void kunit_kfree_const(struct kunit *test, const void *x);
550 * kunit_kstrdup() - Duplicates a string into a test managed allocation.
552 * @test: The test context object.
558 static inline char *kunit_kstrdup(struct kunit *test, const char *str, gfp_t gfp)
567 buf = kunit_kmalloc(test, len, gfp);
574 * kunit_kstrdup_const() - Conditionally duplicates a string into a test managed allocation.
576 * @test: The test context object.
584 const char *kunit_kstrdup_const(struct kunit *test, const char *str, gfp_t gfp);
591 * code under test accesses the mm before executing the mmap (e.g., to perform
600 * @test: The test context object.
610 unsigned long kunit_vm_mmap(struct kunit *test, struct file *file,
615 void kunit_cleanup(struct kunit *test);
621 * kunit_mark_skipped() - Marks @test as skipped
623 * @test: The test context object.
626 * Marks the test as skipped. @fmt is given output as the test status
627 * comment, typically the reason the test was skipped.
629 * Test execution continues after kunit_mark_skipped() is called.
631 #define kunit_mark_skipped(test, fmt, ...) \
633 WRITE_ONCE((test)->status, KUNIT_SKIPPED); \
634 scnprintf((test)->status_comment, \
640 * kunit_skip() - Marks @test as skipped
642 * @test: The test context object.
645 * Skips the test. @fmt is given output as the test status
646 * comment, typically the reason the test was skipped.
648 * Test execution is halted after kunit_skip() is called.
650 #define kunit_skip(test, fmt, ...) \
652 kunit_mark_skipped((test), fmt, ##__VA_ARGS__); \
653 kunit_try_catch_throw(&((test)->try_catch)); \
657 * printk and log to per-test or per-suite log buffer. Logging only done
667 #define kunit_printk(lvl, test, fmt, ...) \
668 kunit_log(lvl, test, KUNIT_SUBTEST_INDENT "# %s: " fmt, \
669 (test)->name, ##__VA_ARGS__)
672 * kunit_info() - Prints an INFO level message associated with @test.
674 * @test: The test context object.
677 * Prints an info level message associated with the test suite being run.
680 #define kunit_info(test, fmt, ...) \
681 kunit_printk(KERN_INFO, test, fmt, ##__VA_ARGS__)
684 * kunit_warn() - Prints a WARN level message associated with @test.
686 * @test: The test context object.
691 #define kunit_warn(test, fmt, ...) \
692 kunit_printk(KERN_WARNING, test, fmt, ##__VA_ARGS__)
695 * kunit_err() - Prints an ERROR level message associated with @test.
697 * @test: The test context object.
702 #define kunit_err(test, fmt, ...) \
703 kunit_printk(KERN_ERR, test, fmt, ##__VA_ARGS__)
709 #define _KUNIT_SAVE_LOC(test) do { \
710 WRITE_ONCE(test->last_seen.file, __FILE__); \
711 WRITE_ONCE(test->last_seen.line, __LINE__); \
716 * @test: The test context object.
722 #define KUNIT_SUCCEED(test) _KUNIT_SAVE_LOC(test)
724 void __noreturn __kunit_abort(struct kunit *test);
726 void __printf(6, 7) __kunit_do_failed_assertion(struct kunit *test,
733 #define _KUNIT_FAILED(test, assert_type, assert_class, assert_format, INITIALIZER, fmt, ...) do { \
736 __kunit_do_failed_assertion(test, \
744 __kunit_abort(test); \
748 #define KUNIT_FAIL_ASSERTION(test, assert_type, fmt, ...) do { \
749 _KUNIT_SAVE_LOC(test); \
750 _KUNIT_FAILED(test, \
760 * KUNIT_FAIL() - Always causes a test to fail when evaluated.
761 * @test: The test context object.
767 * always causes the test case to fail when evaluated. See KUNIT_EXPECT_TRUE()
770 #define KUNIT_FAIL(test, fmt, ...) \
771 KUNIT_FAIL_ASSERTION(test, \
779 #define KUNIT_UNARY_ASSERTION(test, \
786 _KUNIT_SAVE_LOC(test); \
790 _KUNIT_FAILED(test, \
800 #define KUNIT_TRUE_MSG_ASSERTION(test, assert_type, condition, fmt, ...) \
801 KUNIT_UNARY_ASSERTION(test, \
808 #define KUNIT_FALSE_MSG_ASSERTION(test, assert_type, condition, fmt, ...) \
809 KUNIT_UNARY_ASSERTION(test, \
830 #define KUNIT_BASE_BINARY_ASSERTION(test, \
848 _KUNIT_SAVE_LOC(test); \
852 _KUNIT_FAILED(test, \
863 #define KUNIT_BINARY_INT_ASSERTION(test, \
870 KUNIT_BASE_BINARY_ASSERTION(test, \
878 #define KUNIT_BINARY_PTR_ASSERTION(test, \
885 KUNIT_BASE_BINARY_ASSERTION(test, \
893 #define KUNIT_BINARY_STR_ASSERTION(test, \
909 _KUNIT_SAVE_LOC(test); \
915 _KUNIT_FAILED(test, \
926 #define KUNIT_MEM_ASSERTION(test, \
944 _KUNIT_SAVE_LOC(test); \
949 _KUNIT_FAILED(test, \
961 #define KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test, \
969 _KUNIT_SAVE_LOC(test); \
973 _KUNIT_FAILED(test, \
983 * KUNIT_EXPECT_TRUE() - Causes a test failure when the expression is not true.
984 * @test: The test context object.
985 * @condition: an arbitrary boolean expression. The test fails when this does
988 * This and expectations of the form `KUNIT_EXPECT_*` will cause the test case
990 * the test case from continuing to run; this is otherwise known as an
993 #define KUNIT_EXPECT_TRUE(test, condition) \
994 KUNIT_EXPECT_TRUE_MSG(test, condition, NULL)
996 #define KUNIT_EXPECT_TRUE_MSG(test, condition, fmt, ...) \
997 KUNIT_TRUE_MSG_ASSERTION(test, \
1004 * KUNIT_EXPECT_FALSE() - Makes a test failure when the expression is not false.
1005 * @test: The test context object.
1006 * @condition: an arbitrary boolean expression. The test fails when this does
1012 #define KUNIT_EXPECT_FALSE(test, condition) \
1013 KUNIT_EXPECT_FALSE_MSG(test, condition, NULL)
1015 #define KUNIT_EXPECT_FALSE_MSG(test, condition, fmt, ...) \
1016 KUNIT_FALSE_MSG_ASSERTION(test, \
1024 * @test: The test context object.
1030 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
1033 #define KUNIT_EXPECT_EQ(test, left, right) \
1034 KUNIT_EXPECT_EQ_MSG(test, left, right, NULL)
1036 #define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...) \
1037 KUNIT_BINARY_INT_ASSERTION(test, \
1045 * @test: The test context object.
1051 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
1054 #define KUNIT_EXPECT_PTR_EQ(test, left, right) \
1055 KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, NULL)
1057 #define KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, fmt, ...) \
1058 KUNIT_BINARY_PTR_ASSERTION(test, \
1066 * @test: The test context object.
1072 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
1075 #define KUNIT_EXPECT_NE(test, left, right) \
1076 KUNIT_EXPECT_NE_MSG(test, left, right, NULL)
1078 #define KUNIT_EXPECT_NE_MSG(test, left, right, fmt, ...) \
1079 KUNIT_BINARY_INT_ASSERTION(test, \
1087 * @test: The test context object.
1093 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
1096 #define KUNIT_EXPECT_PTR_NE(test, left, right) \
1097 KUNIT_EXPECT_PTR_NE_MSG(test, left, right, NULL)
1099 #define KUNIT_EXPECT_PTR_NE_MSG(test, left, right, fmt, ...) \
1100 KUNIT_BINARY_PTR_ASSERTION(test, \
1108 * @test: The test context object.
1114 * KUNIT_EXPECT_TRUE(@test, (@left) < (@right)). See KUNIT_EXPECT_TRUE() for
1117 #define KUNIT_EXPECT_LT(test, left, right) \
1118 KUNIT_EXPECT_LT_MSG(test, left, right, NULL)
1120 #define KUNIT_EXPECT_LT_MSG(test, left, right, fmt, ...) \
1121 KUNIT_BINARY_INT_ASSERTION(test, \
1129 * @test: The test context object.
1135 * to KUNIT_EXPECT_TRUE(@test, (@left) <= (@right)). See KUNIT_EXPECT_TRUE() for
1138 #define KUNIT_EXPECT_LE(test, left, right) \
1139 KUNIT_EXPECT_LE_MSG(test, left, right, NULL)
1141 #define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...) \
1142 KUNIT_BINARY_INT_ASSERTION(test, \
1150 * @test: The test context object.
1156 * KUNIT_EXPECT_TRUE(@test, (@left) > (@right)). See KUNIT_EXPECT_TRUE() for
1159 #define KUNIT_EXPECT_GT(test, left, right) \
1160 KUNIT_EXPECT_GT_MSG(test, left, right, NULL)
1162 #define KUNIT_EXPECT_GT_MSG(test, left, right, fmt, ...) \
1163 KUNIT_BINARY_INT_ASSERTION(test, \
1171 * @test: The test context object.
1177 * KUNIT_EXPECT_TRUE(@test, (@left) >= (@right)). See KUNIT_EXPECT_TRUE() for
1180 #define KUNIT_EXPECT_GE(test, left, right) \
1181 KUNIT_EXPECT_GE_MSG(test, left, right, NULL)
1183 #define KUNIT_EXPECT_GE_MSG(test, left, right, fmt, ...) \
1184 KUNIT_BINARY_INT_ASSERTION(test, \
1192 * @test: The test context object.
1198 * KUNIT_EXPECT_TRUE(@test, !strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
1201 #define KUNIT_EXPECT_STREQ(test, left, right) \
1202 KUNIT_EXPECT_STREQ_MSG(test, left, right, NULL)
1204 #define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...) \
1205 KUNIT_BINARY_STR_ASSERTION(test, \
1213 * @test: The test context object.
1219 * KUNIT_EXPECT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
1222 #define KUNIT_EXPECT_STRNEQ(test, left, right) \
1223 KUNIT_EXPECT_STRNEQ_MSG(test, left, right, NULL)
1225 #define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...) \
1226 KUNIT_BINARY_STR_ASSERTION(test, \
1234 * @test: The test context object.
1241 * KUNIT_EXPECT_TRUE(@test, !memcmp((@left), (@right), (@size))). See
1248 #define KUNIT_EXPECT_MEMEQ(test, left, right, size) \
1249 KUNIT_EXPECT_MEMEQ_MSG(test, left, right, size, NULL)
1251 #define KUNIT_EXPECT_MEMEQ_MSG(test, left, right, size, fmt, ...) \
1252 KUNIT_MEM_ASSERTION(test, \
1261 * @test: The test context object.
1268 * KUNIT_EXPECT_TRUE(@test, memcmp((@left), (@right), (@size))). See
1275 #define KUNIT_EXPECT_MEMNEQ(test, left, right, size) \
1276 KUNIT_EXPECT_MEMNEQ_MSG(test, left, right, size, NULL)
1278 #define KUNIT_EXPECT_MEMNEQ_MSG(test, left, right, size, fmt, ...) \
1279 KUNIT_MEM_ASSERTION(test, \
1288 * @test: The test context object.
1292 * semantically equivalent to KUNIT_EXPECT_PTR_EQ(@test, ptr, NULL).
1295 #define KUNIT_EXPECT_NULL(test, ptr) \
1296 KUNIT_EXPECT_NULL_MSG(test, \
1300 #define KUNIT_EXPECT_NULL_MSG(test, ptr, fmt, ...) \
1301 KUNIT_BINARY_PTR_ASSERTION(test, \
1309 * @test: The test context object.
1313 * is semantically equivalent to KUNIT_EXPECT_PTR_NE(@test, ptr, NULL).
1316 #define KUNIT_EXPECT_NOT_NULL(test, ptr) \
1317 KUNIT_EXPECT_NOT_NULL_MSG(test, \
1321 #define KUNIT_EXPECT_NOT_NULL_MSG(test, ptr, fmt, ...) \
1322 KUNIT_BINARY_PTR_ASSERTION(test, \
1330 * @test: The test context object.
1335 * KUNIT_EXPECT_TRUE(@test, !IS_ERR_OR_NULL(@ptr)). See KUNIT_EXPECT_TRUE() for
1338 #define KUNIT_EXPECT_NOT_ERR_OR_NULL(test, ptr) \
1339 KUNIT_EXPECT_NOT_ERR_OR_NULL_MSG(test, ptr, NULL)
1341 #define KUNIT_EXPECT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...) \
1342 KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test, \
1349 * KUNIT_FAIL_AND_ABORT() - Always causes a test to fail and abort when evaluated.
1350 * @test: The test context object.
1356 * always causes the test case to fail and abort when evaluated.
1359 #define KUNIT_FAIL_AND_ABORT(test, fmt, ...) \
1360 KUNIT_FAIL_ASSERTION(test, KUNIT_ASSERTION, fmt, ##__VA_ARGS__)
1364 * @test: The test context object.
1365 * @condition: an arbitrary boolean expression. The test fails and aborts when
1368 * This and assertions of the form `KUNIT_ASSERT_*` will cause the test case to
1370 * an expectation failure, it will prevent the test case from continuing to run;
1373 #define KUNIT_ASSERT_TRUE(test, condition) \
1374 KUNIT_ASSERT_TRUE_MSG(test, condition, NULL)
1376 #define KUNIT_ASSERT_TRUE_MSG(test, condition, fmt, ...) \
1377 KUNIT_TRUE_MSG_ASSERTION(test, \
1385 * @test: The test context object.
1392 #define KUNIT_ASSERT_FALSE(test, condition) \
1393 KUNIT_ASSERT_FALSE_MSG(test, condition, NULL)
1395 #define KUNIT_ASSERT_FALSE_MSG(test, condition, fmt, ...) \
1396 KUNIT_FALSE_MSG_ASSERTION(test, \
1404 * @test: The test context object.
1412 #define KUNIT_ASSERT_EQ(test, left, right) \
1413 KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
1415 #define KUNIT_ASSERT_EQ_MSG(test, left, right, fmt, ...) \
1416 KUNIT_BINARY_INT_ASSERTION(test, \
1424 * @test: The test context object.
1432 #define KUNIT_ASSERT_PTR_EQ(test, left, right) \
1433 KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, NULL)
1435 #define KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, fmt, ...) \
1436 KUNIT_BINARY_PTR_ASSERTION(test, \
1444 * @test: The test context object.
1452 #define KUNIT_ASSERT_NE(test, left, right) \
1453 KUNIT_ASSERT_NE_MSG(test, left, right, NULL)
1455 #define KUNIT_ASSERT_NE_MSG(test, left, right, fmt, ...) \
1456 KUNIT_BINARY_INT_ASSERTION(test, \
1465 * @test: The test context object.
1473 #define KUNIT_ASSERT_PTR_NE(test, left, right) \
1474 KUNIT_ASSERT_PTR_NE_MSG(test, left, right, NULL)
1476 #define KUNIT_ASSERT_PTR_NE_MSG(test, left, right, fmt, ...) \
1477 KUNIT_BINARY_PTR_ASSERTION(test, \
1484 * @test: The test context object.
1493 #define KUNIT_ASSERT_LT(test, left, right) \
1494 KUNIT_ASSERT_LT_MSG(test, left, right, NULL)
1496 #define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...) \
1497 KUNIT_BINARY_INT_ASSERTION(test, \
1504 * @test: The test context object.
1513 #define KUNIT_ASSERT_LE(test, left, right) \
1514 KUNIT_ASSERT_LE_MSG(test, left, right, NULL)
1516 #define KUNIT_ASSERT_LE_MSG(test, left, right, fmt, ...) \
1517 KUNIT_BINARY_INT_ASSERTION(test, \
1525 * @test: The test context object.
1534 #define KUNIT_ASSERT_GT(test, left, right) \
1535 KUNIT_ASSERT_GT_MSG(test, left, right, NULL)
1537 #define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...) \
1538 KUNIT_BINARY_INT_ASSERTION(test, \
1546 * @test: The test context object.
1555 #define KUNIT_ASSERT_GE(test, left, right) \
1556 KUNIT_ASSERT_GE_MSG(test, left, right, NULL)
1558 #define KUNIT_ASSERT_GE_MSG(test, left, right, fmt, ...) \
1559 KUNIT_BINARY_INT_ASSERTION(test, \
1567 * @test: The test context object.
1575 #define KUNIT_ASSERT_STREQ(test, left, right) \
1576 KUNIT_ASSERT_STREQ_MSG(test, left, right, NULL)
1578 #define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...) \
1579 KUNIT_BINARY_STR_ASSERTION(test, \
1587 * @test: The test context object.
1593 * KUNIT_ASSERT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_ASSERT_TRUE()
1596 #define KUNIT_ASSERT_STRNEQ(test, left, right) \
1597 KUNIT_ASSERT_STRNEQ_MSG(test, left, right, NULL)
1599 #define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...) \
1600 KUNIT_BINARY_STR_ASSERTION(test, \
1608 * @test: The test context object.
1615 * KUNIT_ASSERT_TRUE(@test, !memcmp((@left), (@right), (@size))). See
1622 #define KUNIT_ASSERT_MEMEQ(test, left, right, size) \
1623 KUNIT_ASSERT_MEMEQ_MSG(test, left, right, size, NULL)
1625 #define KUNIT_ASSERT_MEMEQ_MSG(test, left, right, size, fmt, ...) \
1626 KUNIT_MEM_ASSERTION(test, \
1635 * @test: The test context object.
1642 * KUNIT_ASSERT_TRUE(@test, memcmp((@left), (@right), (@size))). See
1649 #define KUNIT_ASSERT_MEMNEQ(test, left, right, size) \
1650 KUNIT_ASSERT_MEMNEQ_MSG(test, left, right, size, NULL)
1652 #define KUNIT_ASSERT_MEMNEQ_MSG(test, left, right, size, fmt, ...) \
1653 KUNIT_MEM_ASSERTION(test, \
1662 * @test: The test context object.
1669 #define KUNIT_ASSERT_NULL(test, ptr) \
1670 KUNIT_ASSERT_NULL_MSG(test, \
1674 #define KUNIT_ASSERT_NULL_MSG(test, ptr, fmt, ...) \
1675 KUNIT_BINARY_PTR_ASSERTION(test, \
1683 * @test: The test context object.
1690 #define KUNIT_ASSERT_NOT_NULL(test, ptr) \
1691 KUNIT_ASSERT_NOT_NULL_MSG(test, \
1695 #define KUNIT_ASSERT_NOT_NULL_MSG(test, ptr, fmt, ...) \
1696 KUNIT_BINARY_PTR_ASSERTION(test, \
1704 * @test: The test context object.
1712 #define KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr) \
1713 KUNIT_ASSERT_NOT_ERR_OR_NULL_MSG(test, ptr, NULL)
1715 #define KUNIT_ASSERT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...) \
1716 KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test, \
1723 * KUNIT_ARRAY_PARAM() - Define test parameter generator from an array.
1724 * @name: prefix for the test parameter generator function.
1725 * @array: array of test parameters.
1731 static const void *name##_gen_params(struct kunit *test, \
1736 kunit_register_params_array(test, array, ARRAY_SIZE(array), NULL); \
1747 * KUNIT_ARRAY_PARAM_DESC() - Define test parameter generator from an array.
1748 * @name: prefix for the test parameter generator function.
1749 * @array: array of test parameters.
1755 static const void *name##_gen_params(struct kunit *test, \
1760 kunit_register_params_array(test, array, ARRAY_SIZE(array), NULL); \
1769 * kunit_register_params_array() - Register parameter array for a KUnit test.
1770 * @test: The KUnit test structure to which parameters will be added.
1771 * @array: An array of test parameters.
1776 * This macro initializes the @test's parameter array data, storing information
1778 * description function within `test->params_array`.
1785 #define kunit_register_params_array(test, array, param_count, get_desc) \
1787 struct kunit *_test = (test); \
1805 * - Scoped: kunit_warning_suppress(test) { ... }
1809 * a failed KUnit assertion), kunit_add_action() cleans up at test
1821 kunit_start_suppress_warning(struct kunit *test);
1822 void kunit_end_suppress_warning(struct kunit *test,
1831 * @test: The test context object.
1836 * Fails the test if suppression is already active; nesting is not supported.
1844 * kunit_warning_suppress(test) {
1846 * KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT(test, 1);
1849 #define kunit_warning_suppress(test) \
1852 kunit_start_suppress_warning(test); \
1854 kunit_end_suppress_warning(test, __kunit_suppress), \
1871 * @test: The test context object.
1876 * KUNIT_EXPECT_EQ(@test, KUNIT_SUPPRESSED_WARNING_COUNT(), @expected).
1879 #define KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT(test, expected) \
1880 KUNIT_EXPECT_EQ(test, KUNIT_SUPPRESSED_WARNING_COUNT(), expected)
1886 * @test: The test context object.
1894 #define KUNIT_ASSERT_SUPPRESSED_WARNING_COUNT(test, expected) \
1895 KUNIT_ASSERT_EQ(test, KUNIT_SUPPRESSED_WARNING_COUNT(), expected)