Lines Matching +full:left +full:- +full:right

1 /* SPDX-License-Identifier: GPL-2.0 */
13 #include <kunit/try-catch.h>
43 * sub-subtest. See the "Subtests" section in
44 * https://node-tap.org/tap-protocol/
50 * enum kunit_status - Type of result for a test or test suite
62 * struct kunit_case - represents an individual test case.
81 * .. code-block:: c
87 * KUNIT_EXPECT_EQ(test, 0, add(-1, 1));
89 * KUNIT_EXPECT_EQ(test, -1, add(INT_MAX, INT_MIN));
121 * KUNIT_CASE - A helper for creating a &struct kunit_case
132 * KUNIT_CASE_PARAM - A helper for creation a parameterized &struct kunit_case
153 * struct kunit_suite - describes a related collection of &struct kunit_case
186 * struct kunit - represents a running instance of a test.
228 WRITE_ONCE(test->status, KUNIT_FAILURE); in kunit_set_failure()
261 * kunit_test_suites() - used to register one or more &struct kunit_suite
281 * kunit_test_init_section_suites() - used to register one or more &struct
309 for (test_case = suite->test_cases; test_case->run_case; test_case++)
314 * kunit_kmalloc_array() - Like kmalloc_array() except the allocation is *test managed*.
327 * kunit_kmalloc() - Like kmalloc() except the allocation is *test managed*.
340 * kunit_kfree() - Like kfree except for allocations managed by KUnit.
347 * kunit_kzalloc() - Just like kunit_kmalloc(), but zeroes the allocation.
360 * kunit_kcalloc() - Just like kunit_kmalloc_array(), but zeroes the allocation.
378 * kunit_mark_skipped() - Marks @test_or_suite as skipped
390 WRITE_ONCE((test_or_suite)->status, KUNIT_SKIPPED); \
391 scnprintf((test_or_suite)->status_comment, \
397 * kunit_skip() - Marks @test_or_suite as skipped
410 kunit_try_catch_throw(&((test_or_suite)->try_catch)); \
414 * printk and log to per-test or per-suite log buffer. Logging only done
420 kunit_log_append((test_or_suite)->log, fmt "\n", \
426 (test)->name, ##__VA_ARGS__)
429 * kunit_info() - Prints an INFO level message associated with @test.
441 * kunit_warn() - Prints a WARN level message associated with @test.
452 * kunit_err() - Prints an ERROR level message associated with @test.
463 * KUNIT_SUCCEED() - A no-op expectation. Only exists for code clarity.
502 * KUNIT_FAIL() - Always causes a test to fail when evaluated.
572 left, \ argument
574 right, \ argument
578 const typeof(left) __left = (left); \
579 const typeof(right) __right = (right); \
582 .left_text = #left, \
583 .right_text = #right, \
602 left, \ argument
604 right, \ argument
611 left, op, right, \
617 left, \ argument
619 right, \ argument
626 left, op, right, \
632 left, \ argument
634 right, \ argument
638 const char *__left = (left); \
639 const char *__right = (right); \
642 .left_text = #left, \
643 .right_text = #right, \
682 * KUNIT_EXPECT_TRUE() - Causes a test failure when the expression is not true.
703 * KUNIT_EXPECT_FALSE() - Makes a test failure when the expression is not false.
722 * KUNIT_EXPECT_EQ() - Sets an expectation that @left and @right are equal.
724 * @left: an arbitrary expression that evaluates to a primitive C type.
725 * @right: an arbitrary expression that evaluates to a primitive C type.
727 * Sets an expectation that the values that @left and @right evaluate to are
729 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
732 #define KUNIT_EXPECT_EQ(test, left, right) \ argument
733 KUNIT_EXPECT_EQ_MSG(test, left, right, NULL)
735 #define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...) \ argument
738 left, ==, right, \
743 * KUNIT_EXPECT_PTR_EQ() - Expects that pointers @left and @right are equal.
745 * @left: an arbitrary expression that evaluates to a pointer.
746 * @right: an arbitrary expression that evaluates to a pointer.
748 * Sets an expectation that the values that @left and @right evaluate to are
750 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
753 #define KUNIT_EXPECT_PTR_EQ(test, left, right) \ argument
754 KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, NULL)
756 #define KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, fmt, ...) \ argument
759 left, ==, right, \
764 * KUNIT_EXPECT_NE() - An expectation that @left and @right are not equal.
766 * @left: an arbitrary expression that evaluates to a primitive C type.
767 * @right: an arbitrary expression that evaluates to a primitive C type.
769 * Sets an expectation that the values that @left and @right evaluate to are not
771 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
774 #define KUNIT_EXPECT_NE(test, left, right) \ argument
775 KUNIT_EXPECT_NE_MSG(test, left, right, NULL)
777 #define KUNIT_EXPECT_NE_MSG(test, left, right, fmt, ...) \ argument
780 left, !=, right, \
785 * KUNIT_EXPECT_PTR_NE() - Expects that pointers @left and @right are not equal.
787 * @left: an arbitrary expression that evaluates to a pointer.
788 * @right: an arbitrary expression that evaluates to a pointer.
790 * Sets an expectation that the values that @left and @right evaluate to are not
792 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
795 #define KUNIT_EXPECT_PTR_NE(test, left, right) \ argument
796 KUNIT_EXPECT_PTR_NE_MSG(test, left, right, NULL)
798 #define KUNIT_EXPECT_PTR_NE_MSG(test, left, right, fmt, ...) \ argument
801 left, !=, right, \
806 * KUNIT_EXPECT_LT() - An expectation that @left is less than @right.
808 * @left: an arbitrary expression that evaluates to a primitive C type.
809 * @right: an arbitrary expression that evaluates to a primitive C type.
811 * Sets an expectation that the value that @left evaluates to is less than the
812 * value that @right evaluates to. This is semantically equivalent to
813 * KUNIT_EXPECT_TRUE(@test, (@left) < (@right)). See KUNIT_EXPECT_TRUE() for
816 #define KUNIT_EXPECT_LT(test, left, right) \ argument
817 KUNIT_EXPECT_LT_MSG(test, left, right, NULL)
819 #define KUNIT_EXPECT_LT_MSG(test, left, right, fmt, ...) \ argument
822 left, <, right, \
827 * KUNIT_EXPECT_LE() - Expects that @left is less than or equal to @right.
829 * @left: an arbitrary expression that evaluates to a primitive C type.
830 * @right: an arbitrary expression that evaluates to a primitive C type.
832 * Sets an expectation that the value that @left evaluates to is less than or
833 * equal to the value that @right evaluates to. Semantically this is equivalent
834 * to KUNIT_EXPECT_TRUE(@test, (@left) <= (@right)). See KUNIT_EXPECT_TRUE() for
837 #define KUNIT_EXPECT_LE(test, left, right) \ argument
838 KUNIT_EXPECT_LE_MSG(test, left, right, NULL)
840 #define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...) \ argument
843 left, <=, right, \
848 * KUNIT_EXPECT_GT() - An expectation that @left is greater than @right.
850 * @left: an arbitrary expression that evaluates to a primitive C type.
851 * @right: an arbitrary expression that evaluates to a primitive C type.
853 * Sets an expectation that the value that @left evaluates to is greater than
854 * the value that @right evaluates to. This is semantically equivalent to
855 * KUNIT_EXPECT_TRUE(@test, (@left) > (@right)). See KUNIT_EXPECT_TRUE() for
858 #define KUNIT_EXPECT_GT(test, left, right) \ argument
859 KUNIT_EXPECT_GT_MSG(test, left, right, NULL)
861 #define KUNIT_EXPECT_GT_MSG(test, left, right, fmt, ...) \ argument
864 left, >, right, \
869 * KUNIT_EXPECT_GE() - Expects that @left is greater than or equal to @right.
871 * @left: an arbitrary expression that evaluates to a primitive C type.
872 * @right: an arbitrary expression that evaluates to a primitive C type.
874 * Sets an expectation that the value that @left evaluates to is greater than
875 * the value that @right evaluates to. This is semantically equivalent to
876 * KUNIT_EXPECT_TRUE(@test, (@left) >= (@right)). See KUNIT_EXPECT_TRUE() for
879 #define KUNIT_EXPECT_GE(test, left, right) \ argument
880 KUNIT_EXPECT_GE_MSG(test, left, right, NULL)
882 #define KUNIT_EXPECT_GE_MSG(test, left, right, fmt, ...) \ argument
885 left, >=, right, \
890 * KUNIT_EXPECT_STREQ() - Expects that strings @left and @right are equal.
892 * @left: an arbitrary expression that evaluates to a null terminated string.
893 * @right: an arbitrary expression that evaluates to a null terminated string.
895 * Sets an expectation that the values that @left and @right evaluate to are
897 * KUNIT_EXPECT_TRUE(@test, !strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
900 #define KUNIT_EXPECT_STREQ(test, left, right) \ argument
901 KUNIT_EXPECT_STREQ_MSG(test, left, right, NULL)
903 #define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...) \ argument
906 left, ==, right, \
911 * KUNIT_EXPECT_STRNEQ() - Expects that strings @left and @right are not equal.
913 * @left: an arbitrary expression that evaluates to a null terminated string.
914 * @right: an arbitrary expression that evaluates to a null terminated string.
916 * Sets an expectation that the values that @left and @right evaluate to are
918 * KUNIT_EXPECT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
921 #define KUNIT_EXPECT_STRNEQ(test, left, right) \ argument
922 KUNIT_EXPECT_STRNEQ_MSG(test, left, right, NULL)
924 #define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...) \ argument
927 left, !=, right, \
932 * KUNIT_EXPECT_NULL() - Expects that @ptr is null.
953 * KUNIT_EXPECT_NOT_NULL() - Expects that @ptr is not null.
974 * KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err.
997 * KUNIT_ASSERT_TRUE() - Sets an assertion that @condition is true.
1018 * KUNIT_ASSERT_FALSE() - Sets an assertion that @condition is false.
1037 * KUNIT_ASSERT_EQ() - Sets an assertion that @left and @right are equal.
1039 * @left: an arbitrary expression that evaluates to a primitive C type.
1040 * @right: an arbitrary expression that evaluates to a primitive C type.
1042 * Sets an assertion that the values that @left and @right evaluate to are
1046 #define KUNIT_ASSERT_EQ(test, left, right) \ argument
1047 KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
1049 #define KUNIT_ASSERT_EQ_MSG(test, left, right, fmt, ...) \ argument
1052 left, ==, right, \
1057 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
1059 * @left: an arbitrary expression that evaluates to a pointer.
1060 * @right: an arbitrary expression that evaluates to a pointer.
1062 * Sets an assertion that the values that @left and @right evaluate to are
1066 #define KUNIT_ASSERT_PTR_EQ(test, left, right) \ argument
1067 KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, NULL)
1069 #define KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, fmt, ...) \ argument
1072 left, ==, right, \
1077 * KUNIT_ASSERT_NE() - An assertion that @left and @right are not equal.
1079 * @left: an arbitrary expression that evaluates to a primitive C type.
1080 * @right: an arbitrary expression that evaluates to a primitive C type.
1082 * Sets an assertion that the values that @left and @right evaluate to are not
1086 #define KUNIT_ASSERT_NE(test, left, right) \ argument
1087 KUNIT_ASSERT_NE_MSG(test, left, right, NULL)
1089 #define KUNIT_ASSERT_NE_MSG(test, left, right, fmt, ...) \ argument
1092 left, !=, right, \
1097 * KUNIT_ASSERT_PTR_NE() - Asserts that pointers @left and @right are not equal.
1098 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
1100 * @left: an arbitrary expression that evaluates to a pointer.
1101 * @right: an arbitrary expression that evaluates to a pointer.
1103 * Sets an assertion that the values that @left and @right evaluate to are not
1107 #define KUNIT_ASSERT_PTR_NE(test, left, right) \ argument
1108 KUNIT_ASSERT_PTR_NE_MSG(test, left, right, NULL)
1110 #define KUNIT_ASSERT_PTR_NE_MSG(test, left, right, fmt, ...) \ argument
1113 left, !=, right, \
1117 * KUNIT_ASSERT_LT() - An assertion that @left is less than @right.
1119 * @left: an arbitrary expression that evaluates to a primitive C type.
1120 * @right: an arbitrary expression that evaluates to a primitive C type.
1122 * Sets an assertion that the value that @left evaluates to is less than the
1123 * value that @right evaluates to. This is the same as KUNIT_EXPECT_LT(), except
1127 #define KUNIT_ASSERT_LT(test, left, right) \ argument
1128 KUNIT_ASSERT_LT_MSG(test, left, right, NULL)
1130 #define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...) \ argument
1133 left, <, right, \
1137 * KUNIT_ASSERT_LE() - An assertion that @left is less than or equal to @right.
1139 * @left: an arbitrary expression that evaluates to a primitive C type.
1140 * @right: an arbitrary expression that evaluates to a primitive C type.
1142 * Sets an assertion that the value that @left evaluates to is less than or
1143 * equal to the value that @right evaluates to. This is the same as
1147 #define KUNIT_ASSERT_LE(test, left, right) \ argument
1148 KUNIT_ASSERT_LE_MSG(test, left, right, NULL)
1150 #define KUNIT_ASSERT_LE_MSG(test, left, right, fmt, ...) \ argument
1153 left, <=, right, \
1158 * KUNIT_ASSERT_GT() - An assertion that @left is greater than @right.
1160 * @left: an arbitrary expression that evaluates to a primitive C type.
1161 * @right: an arbitrary expression that evaluates to a primitive C type.
1163 * Sets an assertion that the value that @left evaluates to is greater than the
1164 * value that @right evaluates to. This is the same as KUNIT_EXPECT_GT(), except
1168 #define KUNIT_ASSERT_GT(test, left, right) \ argument
1169 KUNIT_ASSERT_GT_MSG(test, left, right, NULL)
1171 #define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...) \ argument
1174 left, >, right, \
1179 * KUNIT_ASSERT_GE() - Assertion that @left is greater than or equal to @right.
1181 * @left: an arbitrary expression that evaluates to a primitive C type.
1182 * @right: an arbitrary expression that evaluates to a primitive C type.
1184 * Sets an assertion that the value that @left evaluates to is greater than the
1185 * value that @right evaluates to. This is the same as KUNIT_EXPECT_GE(), except
1189 #define KUNIT_ASSERT_GE(test, left, right) \ argument
1190 KUNIT_ASSERT_GE_MSG(test, left, right, NULL)
1192 #define KUNIT_ASSERT_GE_MSG(test, left, right, fmt, ...) \ argument
1195 left, >=, right, \
1200 * KUNIT_ASSERT_STREQ() - An assertion that strings @left and @right are equal.
1202 * @left: an arbitrary expression that evaluates to a null terminated string.
1203 * @right: an arbitrary expression that evaluates to a null terminated string.
1205 * Sets an assertion that the values that @left and @right evaluate to are
1209 #define KUNIT_ASSERT_STREQ(test, left, right) \ argument
1210 KUNIT_ASSERT_STREQ_MSG(test, left, right, NULL)
1212 #define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...) \ argument
1215 left, ==, right, \
1220 * KUNIT_ASSERT_STRNEQ() - Expects that strings @left and @right are not equal.
1222 * @left: an arbitrary expression that evaluates to a null terminated string.
1223 * @right: an arbitrary expression that evaluates to a null terminated string.
1225 * Sets an expectation that the values that @left and @right evaluate to are
1227 * KUNIT_ASSERT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_ASSERT_TRUE()
1230 #define KUNIT_ASSERT_STRNEQ(test, left, right) \ argument
1231 KUNIT_ASSERT_STRNEQ_MSG(test, left, right, NULL)
1233 #define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...) \ argument
1236 left, !=, right, \
1241 * KUNIT_ASSERT_NULL() - Asserts that pointers @ptr is null.
1262 * KUNIT_ASSERT_NOT_NULL() - Asserts that pointers @ptr is not null.
1283 * KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err.
1303 * KUNIT_ARRAY_PARAM() - Define test parameter generator from an array.
1314 if (__next - (array) < ARRAY_SIZE((array))) { \