Lines Matching +full:left +full:-

1 /* SPDX-License-Identifier: GPL-2.0 */
13 #include <kunit/try-catch.h>
47 * sub-subtest. See the "Subtests" section in
48 * https://node-tap.org/tap-protocol/
55 * enum kunit_status - Type of result for a test or test suite
89 * struct kunit_case - represents an individual test case.
109 * .. code-block:: c
115 * KUNIT_EXPECT_EQ(test, 0, add(-1, 1));
117 * KUNIT_EXPECT_EQ(test, -1, add(INT_MAX, INT_MIN));
151 * KUNIT_CASE - A helper for creating a &struct kunit_case
164 * KUNIT_CASE_ATTR - A helper for creating a &struct kunit_case
176 * KUNIT_CASE_SLOW - A helper for creating a &struct kunit_case
187 * KUNIT_CASE_PARAM - A helper for creation a parameterized &struct kunit_case
208 * KUNIT_CASE_PARAM_ATTR - A helper for creating a parameterized &struct
222 * struct kunit_suite - describes a related collection of &struct kunit_case
267 * struct kunit - represents a running instance of a test.
311 WRITE_ONCE(test->status, KUNIT_FAILURE); in kunit_set_failure()
362 * kunit_test_suites() - used to register one or more &struct kunit_suite
387 * kunit_test_init_section_suites() - used to register one or more &struct
414 for (test_case = suite->test_cases; test_case->run_case; test_case++)
419 * kunit_kmalloc_array() - Like kmalloc_array() except the allocation is *test managed*.
435 * kunit_kmalloc() - Like kmalloc() except the allocation is *test managed*.
451 * kunit_kfree() - Like kfree except for allocations managed by KUnit.
458 * kunit_kzalloc() - Just like kunit_kmalloc(), but zeroes the allocation.
471 * kunit_kcalloc() - Just like kunit_kmalloc_array(), but zeroes the allocation.
486 * kunit_kfree_const() - conditionally free test managed memory
496 * kunit_kstrdup() - Duplicates a string into a test managed allocation.
499 * @str: The NULL-terminated string to duplicate.
520 * kunit_kstrdup_const() - Conditionally duplicates a string into a test managed allocation.
523 * @str: The NULL-terminated string to duplicate.
527 * kunit_kfree_const() -- not kunit_kfree().
533 * kunit_vm_mmap() - Allocate KUnit-tracked vm_mmap() area
554 * kunit_mark_skipped() - Marks @test_or_suite as skipped
566 WRITE_ONCE((test_or_suite)->status, KUNIT_SKIPPED); \
567 scnprintf((test_or_suite)->status_comment, \
573 * kunit_skip() - Marks @test_or_suite as skipped
586 kunit_try_catch_throw(&((test_or_suite)->try_catch)); \
590 * printk and log to per-test or per-suite log buffer. Logging only done
596 kunit_log_append((test_or_suite)->log, fmt, \
602 (test)->name, ##__VA_ARGS__)
605 * kunit_info() - Prints an INFO level message associated with @test.
617 * kunit_warn() - Prints a WARN level message associated with @test.
628 * kunit_err() - Prints an ERROR level message associated with @test.
643 WRITE_ONCE(test->last_seen.file, __FILE__); \
644 WRITE_ONCE(test->last_seen.line, __LINE__); \
648 * KUNIT_SUCCEED() - A no-op expectation. Only exists for code clarity.
693 * KUNIT_FAIL() - Always causes a test to fail when evaluated.
767 left, \ argument
773 const typeof(left) __left = (left); \
777 .left_text = #left, \
798 left, \ argument
807 left, op, right, \
813 left, \ argument
822 left, op, right, \
828 left, \ argument
834 const char *__left = (left); \
838 .left_text = #left, \
860 left, \ argument
867 const void *__left = (left); \
872 .left_text = #left, \
915 * KUNIT_EXPECT_TRUE() - Causes a test failure when the expression is not true.
936 * KUNIT_EXPECT_FALSE() - Makes a test failure when the expression is not false.
955 * KUNIT_EXPECT_EQ() - Sets an expectation that @left and @right are equal.
957 * @left: an arbitrary expression that evaluates to a primitive C type.
960 * Sets an expectation that the values that @left and @right evaluate to are
962 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
965 #define KUNIT_EXPECT_EQ(test, left, right) \ argument
966 KUNIT_EXPECT_EQ_MSG(test, left, right, NULL)
968 #define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...) \ argument
971 left, ==, right, \
976 * KUNIT_EXPECT_PTR_EQ() - Expects that pointers @left and @right are equal.
978 * @left: an arbitrary expression that evaluates to a pointer.
981 * Sets an expectation that the values that @left and @right evaluate to are
983 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
986 #define KUNIT_EXPECT_PTR_EQ(test, left, right) \ argument
987 KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, NULL)
989 #define KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, fmt, ...) \ argument
992 left, ==, right, \
997 * KUNIT_EXPECT_NE() - An expectation that @left and @right are not equal.
999 * @left: an arbitrary expression that evaluates to a primitive C type.
1002 * Sets an expectation that the values that @left and @right evaluate to are not
1004 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
1007 #define KUNIT_EXPECT_NE(test, left, right) \ argument
1008 KUNIT_EXPECT_NE_MSG(test, left, right, NULL)
1010 #define KUNIT_EXPECT_NE_MSG(test, left, right, fmt, ...) \ argument
1013 left, !=, right, \
1018 * KUNIT_EXPECT_PTR_NE() - Expects that pointers @left and @right are not equal.
1020 * @left: an arbitrary expression that evaluates to a pointer.
1023 * Sets an expectation that the values that @left and @right evaluate to are not
1025 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
1028 #define KUNIT_EXPECT_PTR_NE(test, left, right) \ argument
1029 KUNIT_EXPECT_PTR_NE_MSG(test, left, right, NULL)
1031 #define KUNIT_EXPECT_PTR_NE_MSG(test, left, right, fmt, ...) \ argument
1034 left, !=, right, \
1039 * KUNIT_EXPECT_LT() - An expectation that @left is less than @right.
1041 * @left: an arbitrary expression that evaluates to a primitive C type.
1044 * Sets an expectation that the value that @left evaluates to is less than the
1046 * KUNIT_EXPECT_TRUE(@test, (@left) < (@right)). See KUNIT_EXPECT_TRUE() for
1049 #define KUNIT_EXPECT_LT(test, left, right) \ argument
1050 KUNIT_EXPECT_LT_MSG(test, left, right, NULL)
1052 #define KUNIT_EXPECT_LT_MSG(test, left, right, fmt, ...) \ argument
1055 left, <, right, \
1060 * KUNIT_EXPECT_LE() - Expects that @left is less than or equal to @right.
1062 * @left: an arbitrary expression that evaluates to a primitive C type.
1065 * Sets an expectation that the value that @left evaluates to is less than or
1067 * to KUNIT_EXPECT_TRUE(@test, (@left) <= (@right)). See KUNIT_EXPECT_TRUE() for
1070 #define KUNIT_EXPECT_LE(test, left, right) \ argument
1071 KUNIT_EXPECT_LE_MSG(test, left, right, NULL)
1073 #define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...) \ argument
1076 left, <=, right, \
1081 * KUNIT_EXPECT_GT() - An expectation that @left is greater than @right.
1083 * @left: an arbitrary expression that evaluates to a primitive C type.
1086 * Sets an expectation that the value that @left evaluates to is greater than
1088 * KUNIT_EXPECT_TRUE(@test, (@left) > (@right)). See KUNIT_EXPECT_TRUE() for
1091 #define KUNIT_EXPECT_GT(test, left, right) \ argument
1092 KUNIT_EXPECT_GT_MSG(test, left, right, NULL)
1094 #define KUNIT_EXPECT_GT_MSG(test, left, right, fmt, ...) \ argument
1097 left, >, right, \
1102 * KUNIT_EXPECT_GE() - Expects that @left is greater than or equal to @right.
1104 * @left: an arbitrary expression that evaluates to a primitive C type.
1107 * Sets an expectation that the value that @left evaluates to is greater than
1109 * KUNIT_EXPECT_TRUE(@test, (@left) >= (@right)). See KUNIT_EXPECT_TRUE() for
1112 #define KUNIT_EXPECT_GE(test, left, right) \ argument
1113 KUNIT_EXPECT_GE_MSG(test, left, right, NULL)
1115 #define KUNIT_EXPECT_GE_MSG(test, left, right, fmt, ...) \ argument
1118 left, >=, right, \
1123 * KUNIT_EXPECT_STREQ() - Expects that strings @left and @right are equal.
1125 * @left: an arbitrary expression that evaluates to a null terminated string.
1128 * Sets an expectation that the values that @left and @right evaluate to are
1130 * KUNIT_EXPECT_TRUE(@test, !strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
1133 #define KUNIT_EXPECT_STREQ(test, left, right) \ argument
1134 KUNIT_EXPECT_STREQ_MSG(test, left, right, NULL)
1136 #define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...) \ argument
1139 left, ==, right, \
1144 * KUNIT_EXPECT_STRNEQ() - Expects that strings @left and @right are not equal.
1146 * @left: an arbitrary expression that evaluates to a null terminated string.
1149 * Sets an expectation that the values that @left and @right evaluate to are
1151 * KUNIT_EXPECT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
1154 #define KUNIT_EXPECT_STRNEQ(test, left, right) \ argument
1155 KUNIT_EXPECT_STRNEQ_MSG(test, left, right, NULL)
1157 #define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...) \ argument
1160 left, !=, right, \
1165 * KUNIT_EXPECT_MEMEQ() - Expects that the first @size bytes of @left and @right are equal.
1167 * @left: An arbitrary expression that evaluates to the specified size.
1171 * Sets an expectation that the values that @left and @right evaluate to are
1173 * KUNIT_EXPECT_TRUE(@test, !memcmp((@left), (@right), (@size))). See
1180 #define KUNIT_EXPECT_MEMEQ(test, left, right, size) \ argument
1181 KUNIT_EXPECT_MEMEQ_MSG(test, left, right, size, NULL)
1183 #define KUNIT_EXPECT_MEMEQ_MSG(test, left, right, size, fmt, ...) \ argument
1186 left, ==, right, \
1192 * KUNIT_EXPECT_MEMNEQ() - Expects that the first @size bytes of @left and @right are not equal.
1194 * @left: An arbitrary expression that evaluates to the specified size.
1198 * Sets an expectation that the values that @left and @right evaluate to are
1200 * KUNIT_EXPECT_TRUE(@test, memcmp((@left), (@right), (@size))). See
1207 #define KUNIT_EXPECT_MEMNEQ(test, left, right, size) \ argument
1208 KUNIT_EXPECT_MEMNEQ_MSG(test, left, right, size, NULL)
1210 #define KUNIT_EXPECT_MEMNEQ_MSG(test, left, right, size, fmt, ...) \ argument
1213 left, !=, right, \
1219 * KUNIT_EXPECT_NULL() - Expects that @ptr is null.
1240 * KUNIT_EXPECT_NOT_NULL() - Expects that @ptr is not null.
1261 * KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err.
1281 * KUNIT_FAIL_AND_ABORT() - Always causes a test to fail and abort when evaluated.
1295 * KUNIT_ASSERT_TRUE() - Sets an assertion that @condition is true.
1316 * KUNIT_ASSERT_FALSE() - Sets an assertion that @condition is false.
1335 * KUNIT_ASSERT_EQ() - Sets an assertion that @left and @right are equal.
1337 * @left: an arbitrary expression that evaluates to a primitive C type.
1340 * Sets an assertion that the values that @left and @right evaluate to are
1344 #define KUNIT_ASSERT_EQ(test, left, right) \ argument
1345 KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
1347 #define KUNIT_ASSERT_EQ_MSG(test, left, right, fmt, ...) \ argument
1350 left, ==, right, \
1355 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
1357 * @left: an arbitrary expression that evaluates to a pointer.
1360 * Sets an assertion that the values that @left and @right evaluate to are
1364 #define KUNIT_ASSERT_PTR_EQ(test, left, right) \ argument
1365 KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, NULL)
1367 #define KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, fmt, ...) \ argument
1370 left, ==, right, \
1375 * KUNIT_ASSERT_NE() - An assertion that @left and @right are not equal.
1377 * @left: an arbitrary expression that evaluates to a primitive C type.
1380 * Sets an assertion that the values that @left and @right evaluate to are not
1384 #define KUNIT_ASSERT_NE(test, left, right) \ argument
1385 KUNIT_ASSERT_NE_MSG(test, left, right, NULL)
1387 #define KUNIT_ASSERT_NE_MSG(test, left, right, fmt, ...) \ argument
1390 left, !=, right, \
1395 * KUNIT_ASSERT_PTR_NE() - Asserts that pointers @left and @right are not equal.
1396 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
1398 * @left: an arbitrary expression that evaluates to a pointer.
1401 * Sets an assertion that the values that @left and @right evaluate to are not
1405 #define KUNIT_ASSERT_PTR_NE(test, left, right) \ argument
1406 KUNIT_ASSERT_PTR_NE_MSG(test, left, right, NULL)
1408 #define KUNIT_ASSERT_PTR_NE_MSG(test, left, right, fmt, ...) \ argument
1411 left, !=, right, \
1415 * KUNIT_ASSERT_LT() - An assertion that @left is less than @right.
1417 * @left: an arbitrary expression that evaluates to a primitive C type.
1420 * Sets an assertion that the value that @left evaluates to is less than the
1425 #define KUNIT_ASSERT_LT(test, left, right) \ argument
1426 KUNIT_ASSERT_LT_MSG(test, left, right, NULL)
1428 #define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...) \ argument
1431 left, <, right, \
1435 * KUNIT_ASSERT_LE() - An assertion that @left is less than or equal to @right.
1437 * @left: an arbitrary expression that evaluates to a primitive C type.
1440 * Sets an assertion that the value that @left evaluates to is less than or
1445 #define KUNIT_ASSERT_LE(test, left, right) \ argument
1446 KUNIT_ASSERT_LE_MSG(test, left, right, NULL)
1448 #define KUNIT_ASSERT_LE_MSG(test, left, right, fmt, ...) \ argument
1451 left, <=, right, \
1456 * KUNIT_ASSERT_GT() - An assertion that @left is greater than @right.
1458 * @left: an arbitrary expression that evaluates to a primitive C type.
1461 * Sets an assertion that the value that @left evaluates to is greater than the
1466 #define KUNIT_ASSERT_GT(test, left, right) \ argument
1467 KUNIT_ASSERT_GT_MSG(test, left, right, NULL)
1469 #define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...) \ argument
1472 left, >, right, \
1477 * KUNIT_ASSERT_GE() - Assertion that @left is greater than or equal to @right.
1479 * @left: an arbitrary expression that evaluates to a primitive C type.
1482 * Sets an assertion that the value that @left evaluates to is greater than the
1487 #define KUNIT_ASSERT_GE(test, left, right) \ argument
1488 KUNIT_ASSERT_GE_MSG(test, left, right, NULL)
1490 #define KUNIT_ASSERT_GE_MSG(test, left, right, fmt, ...) \ argument
1493 left, >=, right, \
1498 * KUNIT_ASSERT_STREQ() - An assertion that strings @left and @right are equal.
1500 * @left: an arbitrary expression that evaluates to a null terminated string.
1503 * Sets an assertion that the values that @left and @right evaluate to are
1507 #define KUNIT_ASSERT_STREQ(test, left, right) \ argument
1508 KUNIT_ASSERT_STREQ_MSG(test, left, right, NULL)
1510 #define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...) \ argument
1513 left, ==, right, \
1518 * KUNIT_ASSERT_STRNEQ() - An assertion that strings @left and @right are not equal.
1520 * @left: an arbitrary expression that evaluates to a null terminated string.
1523 * Sets an assertion that the values that @left and @right evaluate to are
1525 * KUNIT_ASSERT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_ASSERT_TRUE()
1528 #define KUNIT_ASSERT_STRNEQ(test, left, right) \ argument
1529 KUNIT_ASSERT_STRNEQ_MSG(test, left, right, NULL)
1531 #define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...) \ argument
1534 left, !=, right, \
1539 * KUNIT_ASSERT_MEMEQ() - Asserts that the first @size bytes of @left and @right are equal.
1541 * @left: An arbitrary expression that evaluates to the specified size.
1545 * Sets an assertion that the values that @left and @right evaluate to are
1547 * KUNIT_ASSERT_TRUE(@test, !memcmp((@left), (@right), (@size))). See
1554 #define KUNIT_ASSERT_MEMEQ(test, left, right, size) \ argument
1555 KUNIT_ASSERT_MEMEQ_MSG(test, left, right, size, NULL)
1557 #define KUNIT_ASSERT_MEMEQ_MSG(test, left, right, size, fmt, ...) \ argument
1560 left, ==, right, \
1566 * KUNIT_ASSERT_MEMNEQ() - Asserts that the first @size bytes of @left and @right are not equal.
1568 * @left: An arbitrary expression that evaluates to the specified size.
1572 * Sets an assertion that the values that @left and @right evaluate to are
1574 * KUNIT_ASSERT_TRUE(@test, memcmp((@left), (@right), (@size))). See
1581 #define KUNIT_ASSERT_MEMNEQ(test, left, right, size) \ argument
1582 KUNIT_ASSERT_MEMNEQ_MSG(test, left, right, size, NULL)
1584 #define KUNIT_ASSERT_MEMNEQ_MSG(test, left, right, size, fmt, ...) \ argument
1587 left, !=, right, \
1593 * KUNIT_ASSERT_NULL() - Asserts that pointers @ptr is null.
1614 * KUNIT_ASSERT_NOT_NULL() - Asserts that pointers @ptr is not null.
1635 * KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err.
1655 * KUNIT_ARRAY_PARAM() - Define test parameter generator from an array.
1666 if (__next - (array) < ARRAY_SIZE((array))) { \
1676 * KUNIT_ARRAY_PARAM_DESC() - Define test parameter generator from an array.
1687 if (__next - (array) < ARRAY_SIZE((array))) { \
1688 strscpy(desc, __next->desc_member, KUNIT_PARAM_DESC_SIZE); \