• Home
  • Raw
  • Download

Lines Matching +full:left +full:-

1 /* SPDX-License-Identifier: GPL-2.0 */
13 #include <kunit/try-catch.h>
26 * struct kunit_resource - represents a *test managed resource*
43 * .. code-block:: c
53 * res->data = kmalloc(params->size, params->gfp);
55 * if (!res->data)
56 * return -ENOMEM;
63 * kfree(res->data);
99 * sub-subtest. See the "Subtests" section in
100 * https://node-tap.org/tap-protocol/
106 * struct kunit_case - represents an individual test case.
124 * .. code-block:: c
130 * KUNIT_EXPECT_EQ(test, 0, add(-1, 1));
132 * KUNIT_EXPECT_EQ(test, -1, add(INT_MAX, INT_MIN));
156 * KUNIT_CASE - A helper for creating a &struct kunit_case
167 * struct kunit_suite - describes a related collection of &struct kunit_case
194 * struct kunit - represents a running instance of a test.
230 WRITE_ONCE(test->success, false); in kunit_set_failure()
257 * kunit_test_suites_for_module() - used to register one or more
265 * If a test suite is built-in, module_init() gets translated into
294 * kunit_test_suites() - used to register one or more &struct kunit_suite
319 for (test_case = suite->test_cases; test_case->run_case; test_case++)
334 * kunit_get_resource() - Hold resource for use. Should not need to be used
341 kref_get(&res->refcount); in kunit_get_resource()
354 if (res->free) { in kunit_release_resource()
355 res->free(res); in kunit_release_resource()
361 * kunit_put_resource() - When caller is done with retrieved resource,
374 kref_put(&res->refcount, kunit_release_resource); in kunit_put_resource()
378 * kunit_add_resource() - Add a *test managed resource*.
380 * @init: a user-supplied function to initialize the result (if needed). If
383 * @free: a user-supplied function to free the resource (if needed).
394 * kunit_add_named_resource() - Add a named *test managed resource*.
396 * @init: a user-supplied function to initialize the resource data, if needed.
397 * @free: a user-supplied function to free the resource data, if needed.
410 * kunit_alloc_resource() - Allocates a *test managed resource*.
438 return res->data; in kunit_alloc_resource()
448 * kunit_resource_instance_match() - Match a resource with the same instance.
460 return res->data == match_data; in kunit_resource_instance_match()
464 * kunit_resource_name_match() - Match a resource with the same name.
473 return res->name && strcmp(res->name, match_name) == 0; in kunit_resource_name_match()
477 * kunit_find_resource() - Find a resource using match function/data.
489 spin_lock(&test->lock); in kunit_find_resource()
491 list_for_each_entry_reverse(res, &test->resources, node) { in kunit_find_resource()
499 spin_unlock(&test->lock); in kunit_find_resource()
505 * kunit_find_named_resource() - Find a resource using match name.
518 * kunit_destroy_resource() - Find a kunit_resource and destroy it.
524 * 0 if kunit_resource is found and freed, -ENOENT if not found.
538 * kunit_remove_resource() - remove resource from resource list associated with
550 * kunit_kmalloc() - Like kmalloc() except the allocation is *test managed*.
562 * kunit_kfree() - Like kfree except for allocations managed by KUnit.
569 * kunit_kzalloc() - Just like kunit_kmalloc(), but zeroes the allocation.
586 * printk and log to per-test or per-suite log buffer. Logging only done
592 kunit_log_append((test_or_suite)->log, fmt "\n", \
598 (test)->name, ##__VA_ARGS__)
601 * kunit_info() - Prints an INFO level message associated with @test.
613 * kunit_warn() - Prints a WARN level message associated with @test.
624 * kunit_err() - Prints an ERROR level message associated with @test.
635 * KUNIT_SUCCEED() - A no-op expectation. Only exists for code clarity.
668 * KUNIT_FAIL() - Always causes a test to fail when evaluated.
740 left, \ argument
746 typeof(left) __left = (left); \
756 #left, \
768 left, \ argument
776 left, ==, right, \
784 left, \ argument
792 left, !=, right, \
800 left, \ argument
808 left, <, right, \
816 left, \ argument
824 left, <=, right, \
832 left, \ argument
840 left, >, right, \
848 left, \ argument
856 left, >=, right, \
860 #define KUNIT_BINARY_EQ_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\ argument
865 left, \
870 #define KUNIT_BINARY_EQ_ASSERTION(test, assert_type, left, right) \ argument
873 left, \
879 left, \ argument
887 left, \
892 #define KUNIT_BINARY_PTR_EQ_ASSERTION(test, assert_type, left, right) \ argument
895 left, \
899 #define KUNIT_BINARY_NE_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\ argument
904 left, \
909 #define KUNIT_BINARY_NE_ASSERTION(test, assert_type, left, right) \ argument
912 left, \
918 left, \ argument
926 left, \
931 #define KUNIT_BINARY_PTR_NE_ASSERTION(test, assert_type, left, right) \ argument
934 left, \
938 #define KUNIT_BINARY_LT_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\ argument
943 left, \
948 #define KUNIT_BINARY_LT_ASSERTION(test, assert_type, left, right) \ argument
951 left, \
957 left, \ argument
965 left, \
970 #define KUNIT_BINARY_PTR_LT_ASSERTION(test, assert_type, left, right) \ argument
973 left, \
977 #define KUNIT_BINARY_LE_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\ argument
982 left, \
987 #define KUNIT_BINARY_LE_ASSERTION(test, assert_type, left, right) \ argument
990 left, \
996 left, \ argument
1004 left, \
1009 #define KUNIT_BINARY_PTR_LE_ASSERTION(test, assert_type, left, right) \ argument
1012 left, \
1016 #define KUNIT_BINARY_GT_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\ argument
1021 left, \
1026 #define KUNIT_BINARY_GT_ASSERTION(test, assert_type, left, right) \ argument
1029 left, \
1035 left, \ argument
1043 left, \
1048 #define KUNIT_BINARY_PTR_GT_ASSERTION(test, assert_type, left, right) \ argument
1051 left, \
1055 #define KUNIT_BINARY_GE_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\ argument
1060 left, \
1065 #define KUNIT_BINARY_GE_ASSERTION(test, assert_type, left, right) \ argument
1068 left, \
1074 left, \ argument
1082 left, \
1087 #define KUNIT_BINARY_PTR_GE_ASSERTION(test, assert_type, left, right) \ argument
1090 left, \
1096 left, \ argument
1102 typeof(left) __left = (left); \
1111 #left, \
1121 left, \ argument
1127 left, ==, right, \
1131 #define KUNIT_BINARY_STR_EQ_ASSERTION(test, assert_type, left, right) \ argument
1134 left, \
1140 left, \ argument
1146 left, !=, right, \
1150 #define KUNIT_BINARY_STR_NE_ASSERTION(test, assert_type, left, right) \ argument
1153 left, \
1183 * KUNIT_EXPECT_TRUE() - Causes a test failure when the expression is not true.
1204 * KUNIT_EXPECT_FALSE() - Makes a test failure when the expression is not false.
1223 * KUNIT_EXPECT_EQ() - Sets an expectation that @left and @right are equal.
1225 * @left: an arbitrary expression that evaluates to a primitive C type.
1228 * Sets an expectation that the values that @left and @right evaluate to are
1230 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
1233 #define KUNIT_EXPECT_EQ(test, left, right) \ argument
1234 KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1236 #define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...) \ argument
1239 left, \
1245 * KUNIT_EXPECT_PTR_EQ() - Expects that pointers @left and @right are equal.
1247 * @left: an arbitrary expression that evaluates to a pointer.
1250 * Sets an expectation that the values that @left and @right evaluate to are
1252 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
1255 #define KUNIT_EXPECT_PTR_EQ(test, left, right) \ argument
1258 left, \
1261 #define KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, fmt, ...) \ argument
1264 left, \
1270 * KUNIT_EXPECT_NE() - An expectation that @left and @right are not equal.
1272 * @left: an arbitrary expression that evaluates to a primitive C type.
1275 * Sets an expectation that the values that @left and @right evaluate to are not
1277 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
1280 #define KUNIT_EXPECT_NE(test, left, right) \ argument
1281 KUNIT_BINARY_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1283 #define KUNIT_EXPECT_NE_MSG(test, left, right, fmt, ...) \ argument
1286 left, \
1292 * KUNIT_EXPECT_PTR_NE() - Expects that pointers @left and @right are not equal.
1294 * @left: an arbitrary expression that evaluates to a pointer.
1297 * Sets an expectation that the values that @left and @right evaluate to are not
1299 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
1302 #define KUNIT_EXPECT_PTR_NE(test, left, right) \ argument
1305 left, \
1308 #define KUNIT_EXPECT_PTR_NE_MSG(test, left, right, fmt, ...) \ argument
1311 left, \
1317 * KUNIT_EXPECT_LT() - An expectation that @left is less than @right.
1319 * @left: an arbitrary expression that evaluates to a primitive C type.
1322 * Sets an expectation that the value that @left evaluates to is less than the
1324 * KUNIT_EXPECT_TRUE(@test, (@left) < (@right)). See KUNIT_EXPECT_TRUE() for
1327 #define KUNIT_EXPECT_LT(test, left, right) \ argument
1328 KUNIT_BINARY_LT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1330 #define KUNIT_EXPECT_LT_MSG(test, left, right, fmt, ...) \ argument
1333 left, \
1339 * KUNIT_EXPECT_LE() - Expects that @left is less than or equal to @right.
1341 * @left: an arbitrary expression that evaluates to a primitive C type.
1344 * Sets an expectation that the value that @left evaluates to is less than or
1346 * to KUNIT_EXPECT_TRUE(@test, (@left) <= (@right)). See KUNIT_EXPECT_TRUE() for
1349 #define KUNIT_EXPECT_LE(test, left, right) \ argument
1350 KUNIT_BINARY_LE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1352 #define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...) \ argument
1355 left, \
1361 * KUNIT_EXPECT_GT() - An expectation that @left is greater than @right.
1363 * @left: an arbitrary expression that evaluates to a primitive C type.
1366 * Sets an expectation that the value that @left evaluates to is greater than
1368 * KUNIT_EXPECT_TRUE(@test, (@left) > (@right)). See KUNIT_EXPECT_TRUE() for
1371 #define KUNIT_EXPECT_GT(test, left, right) \ argument
1372 KUNIT_BINARY_GT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1374 #define KUNIT_EXPECT_GT_MSG(test, left, right, fmt, ...) \ argument
1377 left, \
1383 * KUNIT_EXPECT_GE() - Expects that @left is greater than or equal to @right.
1385 * @left: an arbitrary expression that evaluates to a primitive C type.
1388 * Sets an expectation that the value that @left evaluates to is greater than
1390 * KUNIT_EXPECT_TRUE(@test, (@left) >= (@right)). See KUNIT_EXPECT_TRUE() for
1393 #define KUNIT_EXPECT_GE(test, left, right) \ argument
1394 KUNIT_BINARY_GE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1396 #define KUNIT_EXPECT_GE_MSG(test, left, right, fmt, ...) \ argument
1399 left, \
1405 * KUNIT_EXPECT_STREQ() - Expects that strings @left and @right are equal.
1407 * @left: an arbitrary expression that evaluates to a null terminated string.
1410 * Sets an expectation that the values that @left and @right evaluate to are
1412 * KUNIT_EXPECT_TRUE(@test, !strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
1415 #define KUNIT_EXPECT_STREQ(test, left, right) \ argument
1416 KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1418 #define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...) \ argument
1421 left, \
1427 * KUNIT_EXPECT_STRNEQ() - Expects that strings @left and @right are not equal.
1429 * @left: an arbitrary expression that evaluates to a null terminated string.
1432 * Sets an expectation that the values that @left and @right evaluate to are
1434 * KUNIT_EXPECT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
1437 #define KUNIT_EXPECT_STRNEQ(test, left, right) \ argument
1438 KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1440 #define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...) \ argument
1443 left, \
1449 * KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err.
1472 * KUNIT_ASSERT_TRUE() - Sets an assertion that @condition is true.
1493 * KUNIT_ASSERT_FALSE() - Sets an assertion that @condition is false.
1512 * KUNIT_ASSERT_EQ() - Sets an assertion that @left and @right are equal.
1514 * @left: an arbitrary expression that evaluates to a primitive C type.
1517 * Sets an assertion that the values that @left and @right evaluate to are
1521 #define KUNIT_ASSERT_EQ(test, left, right) \ argument
1522 KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
1524 #define KUNIT_ASSERT_EQ_MSG(test, left, right, fmt, ...) \ argument
1527 left, \
1533 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
1535 * @left: an arbitrary expression that evaluates to a pointer.
1538 * Sets an assertion that the values that @left and @right evaluate to are
1542 #define KUNIT_ASSERT_PTR_EQ(test, left, right) \ argument
1543 KUNIT_BINARY_PTR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
1545 #define KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, fmt, ...) \ argument
1548 left, \
1554 * KUNIT_ASSERT_NE() - An assertion that @left and @right are not equal.
1556 * @left: an arbitrary expression that evaluates to a primitive C type.
1559 * Sets an assertion that the values that @left and @right evaluate to are not
1563 #define KUNIT_ASSERT_NE(test, left, right) \ argument
1564 KUNIT_BINARY_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
1566 #define KUNIT_ASSERT_NE_MSG(test, left, right, fmt, ...) \ argument
1569 left, \
1575 * KUNIT_ASSERT_PTR_NE() - Asserts that pointers @left and @right are not equal.
1576 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
1578 * @left: an arbitrary expression that evaluates to a pointer.
1581 * Sets an assertion that the values that @left and @right evaluate to are not
1585 #define KUNIT_ASSERT_PTR_NE(test, left, right) \ argument
1586 KUNIT_BINARY_PTR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
1588 #define KUNIT_ASSERT_PTR_NE_MSG(test, left, right, fmt, ...) \ argument
1591 left, \
1596 * KUNIT_ASSERT_LT() - An assertion that @left is less than @right.
1598 * @left: an arbitrary expression that evaluates to a primitive C type.
1601 * Sets an assertion that the value that @left evaluates to is less than the
1606 #define KUNIT_ASSERT_LT(test, left, right) \ argument
1607 KUNIT_BINARY_LT_ASSERTION(test, KUNIT_ASSERTION, left, right)
1609 #define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...) \ argument
1612 left, \
1617 * KUNIT_ASSERT_LE() - An assertion that @left is less than or equal to @right.
1619 * @left: an arbitrary expression that evaluates to a primitive C type.
1622 * Sets an assertion that the value that @left evaluates to is less than or
1627 #define KUNIT_ASSERT_LE(test, left, right) \ argument
1628 KUNIT_BINARY_LE_ASSERTION(test, KUNIT_ASSERTION, left, right)
1630 #define KUNIT_ASSERT_LE_MSG(test, left, right, fmt, ...) \ argument
1633 left, \
1639 * KUNIT_ASSERT_GT() - An assertion that @left is greater than @right.
1641 * @left: an arbitrary expression that evaluates to a primitive C type.
1644 * Sets an assertion that the value that @left evaluates to is greater than the
1649 #define KUNIT_ASSERT_GT(test, left, right) \ argument
1650 KUNIT_BINARY_GT_ASSERTION(test, KUNIT_ASSERTION, left, right)
1652 #define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...) \ argument
1655 left, \
1661 * KUNIT_ASSERT_GE() - Assertion that @left is greater than or equal to @right.
1663 * @left: an arbitrary expression that evaluates to a primitive C type.
1666 * Sets an assertion that the value that @left evaluates to is greater than the
1671 #define KUNIT_ASSERT_GE(test, left, right) \ argument
1672 KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
1674 #define KUNIT_ASSERT_GE_MSG(test, left, right, fmt, ...) \ argument
1677 left, \
1683 * KUNIT_ASSERT_STREQ() - An assertion that strings @left and @right are equal.
1685 * @left: an arbitrary expression that evaluates to a null terminated string.
1688 * Sets an assertion that the values that @left and @right evaluate to are
1692 #define KUNIT_ASSERT_STREQ(test, left, right) \ argument
1693 KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
1695 #define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...) \ argument
1698 left, \
1704 * KUNIT_ASSERT_STRNEQ() - Expects that strings @left and @right are not equal.
1706 * @left: an arbitrary expression that evaluates to a null terminated string.
1709 * Sets an expectation that the values that @left and @right evaluate to are
1711 * KUNIT_ASSERT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_ASSERT_TRUE()
1714 #define KUNIT_ASSERT_STRNEQ(test, left, right) \ argument
1715 KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
1717 #define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...) \ argument
1720 left, \
1726 * KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err.