@@ -480,6 +480,23 @@ static inline void *kunit_kcalloc(struct kunit *test, size_t n, size_t size, gfp
480480 return kunit_kmalloc_array (test , n , size , gfp | __GFP_ZERO );
481481}
482482
483+ /**
484+ * kunit_vm_mmap() - Allocate KUnit-tracked vm_mmap() area
485+ * @test: The test context object.
486+ * @file: struct file pointer to map from, if any
487+ * @addr: desired address, if any
488+ * @len: how many bytes to allocate
489+ * @prot: mmap PROT_* bits
490+ * @flag: mmap flags
491+ * @offset: offset into @file to start mapping from.
492+ *
493+ * See vm_mmap() for more information.
494+ */
495+ unsigned long kunit_vm_mmap (struct kunit * test , struct file * file ,
496+ unsigned long addr , unsigned long len ,
497+ unsigned long prot , unsigned long flag ,
498+ unsigned long offset );
499+
483500void kunit_cleanup (struct kunit * test );
484501
485502void __printf (2 , 3 ) kunit_log_append (struct string_stream * log , const char * fmt , ...);
@@ -1211,7 +1228,18 @@ do { \
12111228 fmt, \
12121229 ##__VA_ARGS__)
12131230
1214- #define KUNIT_ASSERT_FAILURE (test , fmt , ...) \
1231+ /**
1232+ * KUNIT_FAIL_AND_ABORT() - Always causes a test to fail and abort when evaluated.
1233+ * @test: The test context object.
1234+ * @fmt: an informational message to be printed when the assertion is made.
1235+ * @...: string format arguments.
1236+ *
1237+ * The opposite of KUNIT_SUCCEED(), it is an assertion that always fails. In
1238+ * other words, it always results in a failed assertion, and consequently
1239+ * always causes the test case to fail and abort when evaluated.
1240+ * See KUNIT_ASSERT_TRUE() for more information.
1241+ */
1242+ #define KUNIT_FAIL_AND_ABORT (test , fmt , ...) \
12151243 KUNIT_FAIL_ASSERTION(test, KUNIT_ASSERTION, fmt, ##__VA_ARGS__)
12161244
12171245/**
@@ -1438,12 +1466,12 @@ do { \
14381466 ##__VA_ARGS__)
14391467
14401468/**
1441- * KUNIT_ASSERT_STRNEQ() - Expects that strings @left and @right are not equal.
1469+ * KUNIT_ASSERT_STRNEQ() - An assertion that strings @left and @right are not equal.
14421470 * @test: The test context object.
14431471 * @left: an arbitrary expression that evaluates to a null terminated string.
14441472 * @right: an arbitrary expression that evaluates to a null terminated string.
14451473 *
1446- * Sets an expectation that the values that @left and @right evaluate to are
1474+ * Sets an assertion that the values that @left and @right evaluate to are
14471475 * not equal. This is semantically equivalent to
14481476 * KUNIT_ASSERT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_ASSERT_TRUE()
14491477 * for more information.
@@ -1458,6 +1486,60 @@ do { \
14581486 fmt, \
14591487 ##__VA_ARGS__)
14601488
1489+ /**
1490+ * KUNIT_ASSERT_MEMEQ() - Asserts that the first @size bytes of @left and @right are equal.
1491+ * @test: The test context object.
1492+ * @left: An arbitrary expression that evaluates to the specified size.
1493+ * @right: An arbitrary expression that evaluates to the specified size.
1494+ * @size: Number of bytes compared.
1495+ *
1496+ * Sets an assertion that the values that @left and @right evaluate to are
1497+ * equal. This is semantically equivalent to
1498+ * KUNIT_ASSERT_TRUE(@test, !memcmp((@left), (@right), (@size))). See
1499+ * KUNIT_ASSERT_TRUE() for more information.
1500+ *
1501+ * Although this assertion works for any memory block, it is not recommended
1502+ * for comparing more structured data, such as structs. This assertion is
1503+ * recommended for comparing, for example, data arrays.
1504+ */
1505+ #define KUNIT_ASSERT_MEMEQ (test , left , right , size ) \
1506+ KUNIT_ASSERT_MEMEQ_MSG(test, left, right, size, NULL)
1507+
1508+ #define KUNIT_ASSERT_MEMEQ_MSG (test , left , right , size , fmt , ...) \
1509+ KUNIT_MEM_ASSERTION(test, \
1510+ KUNIT_ASSERTION, \
1511+ left, ==, right, \
1512+ size, \
1513+ fmt, \
1514+ ##__VA_ARGS__)
1515+
1516+ /**
1517+ * KUNIT_ASSERT_MEMNEQ() - Asserts that the first @size bytes of @left and @right are not equal.
1518+ * @test: The test context object.
1519+ * @left: An arbitrary expression that evaluates to the specified size.
1520+ * @right: An arbitrary expression that evaluates to the specified size.
1521+ * @size: Number of bytes compared.
1522+ *
1523+ * Sets an assertion that the values that @left and @right evaluate to are
1524+ * not equal. This is semantically equivalent to
1525+ * KUNIT_ASSERT_TRUE(@test, memcmp((@left), (@right), (@size))). See
1526+ * KUNIT_ASSERT_TRUE() for more information.
1527+ *
1528+ * Although this assertion works for any memory block, it is not recommended
1529+ * for comparing more structured data, such as structs. This assertion is
1530+ * recommended for comparing, for example, data arrays.
1531+ */
1532+ #define KUNIT_ASSERT_MEMNEQ (test , left , right , size ) \
1533+ KUNIT_ASSERT_MEMNEQ_MSG(test, left, right, size, NULL)
1534+
1535+ #define KUNIT_ASSERT_MEMNEQ_MSG (test , left , right , size , fmt , ...) \
1536+ KUNIT_MEM_ASSERTION(test, \
1537+ KUNIT_ASSERTION, \
1538+ left, !=, right, \
1539+ size, \
1540+ fmt, \
1541+ ##__VA_ARGS__)
1542+
14611543/**
14621544 * KUNIT_ASSERT_NULL() - Asserts that pointers @ptr is null.
14631545 * @test: The test context object.
0 commit comments