linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] kunit: Support for Parameterized Testing
@ 2020-10-23 15:05 Arpitha Raghunandan
  2020-10-23 15:06 ` [PATCH v2 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature Arpitha Raghunandan
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Arpitha Raghunandan @ 2020-10-23 15:05 UTC (permalink / raw)
  To: brendanhiggins, skhan, elver, yzaikin, tytso, adilger.kernel
  Cc: Arpitha Raghunandan, linux-kselftest, kunit-dev, linux-kernel,
	linux-kernel-mentees, linux-ext4

Implementation of support for parameterized testing in KUnit.

Signed-off-by: Arpitha Raghunandan <98.arpi@gmail.com>
---
Changes v1->v2:
- Use of a generator method to access test case parameters

 include/kunit/test.h | 45 ++++++++++++++++++++++++++++++++++++++++++++
 lib/kunit/test.c     | 20 +++++++++++++++++++-
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/include/kunit/test.h b/include/kunit/test.h
index a423fffefea0..c417ac140326 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -141,6 +141,7 @@ struct kunit;
 struct kunit_case {
 	void (*run_case)(struct kunit *test);
 	const char *name;
+	void* (*generate_params)(struct kunit *test, void *prev);
 
 	/* private: internal use only. */
 	bool success;
@@ -162,6 +163,9 @@ static inline char *kunit_status_to_string(bool status)
  * &struct kunit_case for an example on how to use it.
  */
 #define KUNIT_CASE(test_name) { .run_case = test_name, .name = #test_name }
+#define KUNIT_CASE_PARAM(test_name, gen_params)			\
+		{ .run_case = test_name, .name = #test_name,	\
+		  .generate_params = gen_params }
 
 /**
  * struct kunit_suite - describes a related collection of &struct kunit_case
@@ -208,6 +212,15 @@ struct kunit {
 	const char *name; /* Read only after initialization! */
 	char *log; /* Points at case log after initialization */
 	struct kunit_try_catch try_catch;
+	/* param_values points to test case parameters in parameterized tests */
+	void *param_values;
+	/*
+	 * current_param stores the index of the parameter in
+	 * the array of parameters in parameterized tests.
+	 * current_param + 1 is printed to indicate the parameter
+	 * that causes the test to fail in case of test failure.
+	 */
+	int current_param;
 	/*
 	 * success starts as true, and may only be set to false during a
 	 * test case; thus, it is safe to update this across multiple
@@ -1742,4 +1755,36 @@ do {									       \
 						fmt,			       \
 						##__VA_ARGS__)
 
+/**
+ * kunit_param_generator_helper() - Helper method for test parameter generators
+ * 				    required in parameterized tests.
+ * @test: The test context object.
+ * @prev_param: a pointer to the previous test parameter, NULL for first parameter.
+ * @param_array: a user-supplied pointer to an array of test parameters.
+ * @array_size: number of test parameters in the array.
+ * @type_size: size of one test parameter.
+ */
+static inline void *kunit_param_generator_helper(struct kunit *test,
+					void *prev_param,
+					void *param_array,
+					size_t array_size,
+					size_t type_size)
+{
+	KUNIT_ASSERT_EQ(test, (prev_param - param_array) % type_size, 0);
+
+	if (!prev_param)
+		return param_array;
+
+	KUNIT_ASSERT_GE(test, prev_param, param_array);
+
+	if (prev_param + type_size < param_array + (array_size * type_size))
+		return prev_param + type_size;
+	else
+		return NULL;
+}
+
+#define KUNIT_PARAM_GENERATOR_HELPER(test, prev_param, param_array, param_type) \
+	kunit_param_generator_helper(test, prev_param, param_array,		\
+				ARRAY_SIZE(param_array), sizeof(param_type))
+
 #endif /* _KUNIT_TEST_H */
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 750704abe89a..0e6ffe6384a7 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -127,6 +127,11 @@ unsigned int kunit_test_case_num(struct kunit_suite *suite,
 }
 EXPORT_SYMBOL_GPL(kunit_test_case_num);
 
+static void kunit_print_failed_param(struct kunit *test)
+{
+	kunit_err(test, "\n\tTest failed at parameter: %d\n", test->current_param + 1);
+}
+
 static void kunit_print_string_stream(struct kunit *test,
 				      struct string_stream *stream)
 {
@@ -168,6 +173,8 @@ static void kunit_fail(struct kunit *test, struct kunit_assert *assert)
 	assert->format(assert, stream);
 
 	kunit_print_string_stream(test, stream);
+	if (test->param_values)
+		kunit_print_failed_param(test);
 
 	WARN_ON(string_stream_destroy(stream));
 }
@@ -239,7 +246,18 @@ static void kunit_run_case_internal(struct kunit *test,
 		}
 	}
 
-	test_case->run_case(test);
+	if (!test_case->generate_params) {
+		test_case->run_case(test);
+	} else {
+		test->param_values = test_case->generate_params(test, NULL);
+		test->current_param = 0;
+
+		while (test->param_values) {
+			test_case->run_case(test);
+			test->param_values = test_case->generate_params(test, test->param_values);
+			test->current_param++;
+		}
+	}
 }
 
 static void kunit_case_internal_cleanup(struct kunit *test)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature
  2020-10-23 15:05 [PATCH v2 1/2] kunit: Support for Parameterized Testing Arpitha Raghunandan
@ 2020-10-23 15:06 ` Arpitha Raghunandan
  2020-10-23 17:33   ` kernel test robot
  2020-10-26 18:11   ` Iurii Zaikin
  2020-10-23 18:08 ` [PATCH v2 1/2] kunit: Support for Parameterized Testing kernel test robot
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 10+ messages in thread
From: Arpitha Raghunandan @ 2020-10-23 15:06 UTC (permalink / raw)
  To: brendanhiggins, skhan, elver, yzaikin, tytso, adilger.kernel
  Cc: Arpitha Raghunandan, linux-kselftest, kunit-dev, linux-kernel,
	linux-kernel-mentees, linux-ext4

Modify fs/ext4/inode-test.c to use the parameterized testing
feature of KUnit.

Signed-off-by: Arpitha Raghunandan <98.arpi@gmail.com>
---
Changes v1->v2:
- Modification based on latest implementation of KUnit parameterized testing

 fs/ext4/inode-test.c | 318 ++++++++++++++++++++++---------------------
 1 file changed, 162 insertions(+), 156 deletions(-)

diff --git a/fs/ext4/inode-test.c b/fs/ext4/inode-test.c
index d62d802c9c12..611a1cf2581d 100644
--- a/fs/ext4/inode-test.c
+++ b/fs/ext4/inode-test.c
@@ -80,6 +80,137 @@ struct timestamp_expectation {
 	bool lower_bound;
 };
 
+static struct timestamp_expectation test_data[] = {
+	{
+		.test_case_name = LOWER_BOUND_NEG_NO_EXTRA_BITS_CASE,
+		.msb_set = true,
+		.lower_bound = true,
+		.extra_bits = 0,
+		.expected = {.tv_sec = -0x80000000LL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = UPPER_BOUND_NEG_NO_EXTRA_BITS_CASE,
+		.msb_set = true,
+		.lower_bound = false,
+		.extra_bits = 0,
+		.expected = {.tv_sec = -1LL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = LOWER_BOUND_NONNEG_NO_EXTRA_BITS_CASE,
+		.msb_set = false,
+		.lower_bound = true,
+		.extra_bits = 0,
+		.expected = {0LL, 0L},
+	},
+
+	{
+		.test_case_name = UPPER_BOUND_NONNEG_NO_EXTRA_BITS_CASE,
+		.msb_set = false,
+		.lower_bound = false,
+		.extra_bits = 0,
+		.expected = {.tv_sec = 0x7fffffffLL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = LOWER_BOUND_NEG_LO_1_CASE,
+		.msb_set = true,
+		.lower_bound = true,
+		.extra_bits = 1,
+		.expected = {.tv_sec = 0x80000000LL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = UPPER_BOUND_NEG_LO_1_CASE,
+		.msb_set = true,
+		.lower_bound = false,
+		.extra_bits = 1,
+		.expected = {.tv_sec = 0xffffffffLL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = LOWER_BOUND_NONNEG_LO_1_CASE,
+		.msb_set = false,
+		.lower_bound = true,
+		.extra_bits = 1,
+		.expected = {.tv_sec = 0x100000000LL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = UPPER_BOUND_NONNEG_LO_1_CASE,
+		.msb_set = false,
+		.lower_bound = false,
+		.extra_bits = 1,
+		.expected = {.tv_sec = 0x17fffffffLL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = LOWER_BOUND_NEG_HI_1_CASE,
+		.msb_set = true,
+		.lower_bound = true,
+		.extra_bits =  2,
+		.expected = {.tv_sec = 0x180000000LL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = UPPER_BOUND_NEG_HI_1_CASE,
+		.msb_set = true,
+		.lower_bound = false,
+		.extra_bits = 2,
+		.expected = {.tv_sec = 0x1ffffffffLL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = LOWER_BOUND_NONNEG_HI_1_CASE,
+		.msb_set = false,
+		.lower_bound = true,
+		.extra_bits = 2,
+		.expected = {.tv_sec = 0x200000000LL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = UPPER_BOUND_NONNEG_HI_1_CASE,
+		.msb_set = false,
+		.lower_bound = false,
+		.extra_bits = 2,
+		.expected = {.tv_sec = 0x27fffffffLL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = UPPER_BOUND_NONNEG_HI_1_NS_1_CASE,
+		.msb_set = false,
+		.lower_bound = false,
+		.extra_bits = 6,
+		.expected = {.tv_sec = 0x27fffffffLL, .tv_nsec = 1L},
+	},
+
+	{
+		.test_case_name = LOWER_BOUND_NONNEG_HI_1_NS_MAX_CASE,
+		.msb_set = false,
+		.lower_bound = true,
+		.extra_bits = 0xFFFFFFFF,
+		.expected = {.tv_sec = 0x300000000LL,
+			     .tv_nsec = MAX_NANOSECONDS},
+	},
+
+	{
+		.test_case_name = LOWER_BOUND_NONNEG_EXTRA_BITS_1_CASE,
+		.msb_set = false,
+		.lower_bound = true,
+		.extra_bits = 3,
+		.expected = {.tv_sec = 0x300000000LL, .tv_nsec = 0L},
+	},
+
+	{
+		.test_case_name = UPPER_BOUND_NONNEG_EXTRA_BITS_1_CASE,
+		.msb_set = false,
+		.lower_bound = false,
+		.extra_bits = 3,
+		.expected = {.tv_sec = 0x37fffffffLL, .tv_nsec = 0L},
+	}
+};
+
 static time64_t get_32bit_time(const struct timestamp_expectation * const test)
 {
 	if (test->msb_set) {
@@ -101,166 +232,41 @@ static time64_t get_32bit_time(const struct timestamp_expectation * const test)
  */
 static void inode_test_xtimestamp_decoding(struct kunit *test)
 {
-	const struct timestamp_expectation test_data[] = {
-		{
-			.test_case_name = LOWER_BOUND_NEG_NO_EXTRA_BITS_CASE,
-			.msb_set = true,
-			.lower_bound = true,
-			.extra_bits = 0,
-			.expected = {.tv_sec = -0x80000000LL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = UPPER_BOUND_NEG_NO_EXTRA_BITS_CASE,
-			.msb_set = true,
-			.lower_bound = false,
-			.extra_bits = 0,
-			.expected = {.tv_sec = -1LL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = LOWER_BOUND_NONNEG_NO_EXTRA_BITS_CASE,
-			.msb_set = false,
-			.lower_bound = true,
-			.extra_bits = 0,
-			.expected = {0LL, 0L},
-		},
-
-		{
-			.test_case_name = UPPER_BOUND_NONNEG_NO_EXTRA_BITS_CASE,
-			.msb_set = false,
-			.lower_bound = false,
-			.extra_bits = 0,
-			.expected = {.tv_sec = 0x7fffffffLL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = LOWER_BOUND_NEG_LO_1_CASE,
-			.msb_set = true,
-			.lower_bound = true,
-			.extra_bits = 1,
-			.expected = {.tv_sec = 0x80000000LL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = UPPER_BOUND_NEG_LO_1_CASE,
-			.msb_set = true,
-			.lower_bound = false,
-			.extra_bits = 1,
-			.expected = {.tv_sec = 0xffffffffLL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = LOWER_BOUND_NONNEG_LO_1_CASE,
-			.msb_set = false,
-			.lower_bound = true,
-			.extra_bits = 1,
-			.expected = {.tv_sec = 0x100000000LL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = UPPER_BOUND_NONNEG_LO_1_CASE,
-			.msb_set = false,
-			.lower_bound = false,
-			.extra_bits = 1,
-			.expected = {.tv_sec = 0x17fffffffLL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = LOWER_BOUND_NEG_HI_1_CASE,
-			.msb_set = true,
-			.lower_bound = true,
-			.extra_bits =  2,
-			.expected = {.tv_sec = 0x180000000LL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = UPPER_BOUND_NEG_HI_1_CASE,
-			.msb_set = true,
-			.lower_bound = false,
-			.extra_bits = 2,
-			.expected = {.tv_sec = 0x1ffffffffLL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = LOWER_BOUND_NONNEG_HI_1_CASE,
-			.msb_set = false,
-			.lower_bound = true,
-			.extra_bits = 2,
-			.expected = {.tv_sec = 0x200000000LL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = UPPER_BOUND_NONNEG_HI_1_CASE,
-			.msb_set = false,
-			.lower_bound = false,
-			.extra_bits = 2,
-			.expected = {.tv_sec = 0x27fffffffLL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = UPPER_BOUND_NONNEG_HI_1_NS_1_CASE,
-			.msb_set = false,
-			.lower_bound = false,
-			.extra_bits = 6,
-			.expected = {.tv_sec = 0x27fffffffLL, .tv_nsec = 1L},
-		},
-
-		{
-			.test_case_name = LOWER_BOUND_NONNEG_HI_1_NS_MAX_CASE,
-			.msb_set = false,
-			.lower_bound = true,
-			.extra_bits = 0xFFFFFFFF,
-			.expected = {.tv_sec = 0x300000000LL,
-				     .tv_nsec = MAX_NANOSECONDS},
-		},
-
-		{
-			.test_case_name = LOWER_BOUND_NONNEG_EXTRA_BITS_1_CASE,
-			.msb_set = false,
-			.lower_bound = true,
-			.extra_bits = 3,
-			.expected = {.tv_sec = 0x300000000LL, .tv_nsec = 0L},
-		},
-
-		{
-			.test_case_name = UPPER_BOUND_NONNEG_EXTRA_BITS_1_CASE,
-			.msb_set = false,
-			.lower_bound = false,
-			.extra_bits = 3,
-			.expected = {.tv_sec = 0x37fffffffLL, .tv_nsec = 0L},
-		}
-	};
-
 	struct timespec64 timestamp;
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(test_data); ++i) {
-		timestamp.tv_sec = get_32bit_time(&test_data[i]);
-		ext4_decode_extra_time(&timestamp,
-				       cpu_to_le32(test_data[i].extra_bits));
-
-		KUNIT_EXPECT_EQ_MSG(test,
-				    test_data[i].expected.tv_sec,
-				    timestamp.tv_sec,
-				    CASE_NAME_FORMAT,
-				    test_data[i].test_case_name,
-				    test_data[i].msb_set,
-				    test_data[i].lower_bound,
-				    test_data[i].extra_bits);
-		KUNIT_EXPECT_EQ_MSG(test,
-				    test_data[i].expected.tv_nsec,
-				    timestamp.tv_nsec,
-				    CASE_NAME_FORMAT,
-				    test_data[i].test_case_name,
-				    test_data[i].msb_set,
-				    test_data[i].lower_bound,
-				    test_data[i].extra_bits);
-	}
+
+	struct timestamp_expectation *test_param =
+			(struct timestamp_expectation *)(test->param_values);
+
+	timestamp.tv_sec = get_32bit_time(test_param);
+	ext4_decode_extra_time(&timestamp,
+			       cpu_to_le32(test_param->extra_bits));
+
+	KUNIT_EXPECT_EQ_MSG(test,
+			    test_param->expected.tv_sec,
+			    timestamp.tv_sec,
+			    CASE_NAME_FORMAT,
+			    test_param->test_case_name,
+			    test_param->msb_set,
+			    test_param->lower_bound,
+			    test_param->extra_bits);
+	KUNIT_EXPECT_EQ_MSG(test,
+			    test_param->expected.tv_nsec,
+			    timestamp.tv_nsec,
+			    CASE_NAME_FORMAT,
+			    test_param->test_case_name,
+			    test_param->msb_set,
+			    test_param->lower_bound,
+			    test_param->extra_bits);
+}
+
+static void *generate_params(struct kunit *test, void *prev)
+{
+	return KUNIT_PARAM_GENERATOR_HELPER(test, prev, test_data,
+					struct timestamp_expectation);
 }
 
 static struct kunit_case ext4_inode_test_cases[] = {
-	KUNIT_CASE(inode_test_xtimestamp_decoding),
+	KUNIT_CASE_PARAM(inode_test_xtimestamp_decoding, generate_params),
 	{}
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature
  2020-10-23 15:06 ` [PATCH v2 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature Arpitha Raghunandan
@ 2020-10-23 17:33   ` kernel test robot
  2020-10-26 18:11   ` Iurii Zaikin
  1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2020-10-23 17:33 UTC (permalink / raw)
  To: Arpitha Raghunandan, brendanhiggins, skhan, elver, yzaikin,
	tytso, adilger.kernel
  Cc: kbuild-all, Arpitha Raghunandan, linux-kselftest, kunit-dev,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 57634 bytes --]

Hi Arpitha,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ext4/dev]
[also build test WARNING on linus/master v5.9 next-20201023]
[cannot apply to tytso-fscrypt/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Arpitha-Raghunandan/kunit-Support-for-Parameterized-Testing/20201023-230827
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
config: x86_64-randconfig-s021-20201023 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-17-g2d3af347-dirty
        # https://github.com/0day-ci/linux/commit/67c9830f2988a5b2153f7bb05396611947ee6677
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Arpitha-Raghunandan/kunit-Support-for-Parameterized-Testing/20201023-230827
        git checkout 67c9830f2988a5b2153f7bb05396611947ee6677
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


"sparse warnings: (new ones prefixed by >>)"
   fs/ext4/inode-test.c: note: in included file:
>> include/kunit/test.h:1732:9: sparse: sparse: incompatible types in comparison expression (different type sizes):
>> include/kunit/test.h:1732:9: sparse:    unsigned long *
>> include/kunit/test.h:1732:9: sparse:    int *

vim +1732 include/kunit/test.h

73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1147  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1148  #define KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, assert_type, ptr)	       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1149  	KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1150  						assert_type,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1151  						ptr,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1152  						NULL)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1153  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1154  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1155   * KUNIT_EXPECT_TRUE() - Causes a test failure when the expression is not true.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1156   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1157   * @condition: an arbitrary boolean expression. The test fails when this does
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1158   * not evaluate to true.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1159   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1160   * This and expectations of the form `KUNIT_EXPECT_*` will cause the test case
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1161   * to fail when the specified condition is not met; however, it will not prevent
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1162   * the test case from continuing to run; this is otherwise known as an
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1163   * *expectation failure*.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1164   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1165  #define KUNIT_EXPECT_TRUE(test, condition) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1166  	KUNIT_TRUE_ASSERTION(test, KUNIT_EXPECTATION, condition)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1167  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1168  #define KUNIT_EXPECT_TRUE_MSG(test, condition, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1169  	KUNIT_TRUE_MSG_ASSERTION(test,					       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1170  				 KUNIT_EXPECTATION,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1171  				 condition,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1172  				 fmt,					       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1173  				 ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1174  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1175  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1176   * KUNIT_EXPECT_FALSE() - Makes a test failure when the expression is not false.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1177   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1178   * @condition: an arbitrary boolean expression. The test fails when this does
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1179   * not evaluate to false.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1180   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1181   * Sets an expectation that @condition evaluates to false. See
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1182   * KUNIT_EXPECT_TRUE() for more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1183   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1184  #define KUNIT_EXPECT_FALSE(test, condition) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1185  	KUNIT_FALSE_ASSERTION(test, KUNIT_EXPECTATION, condition)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1186  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1187  #define KUNIT_EXPECT_FALSE_MSG(test, condition, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1188  	KUNIT_FALSE_MSG_ASSERTION(test,					       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1189  				  KUNIT_EXPECTATION,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1190  				  condition,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1191  				  fmt,					       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1192  				  ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1193  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1194  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1195   * KUNIT_EXPECT_EQ() - Sets an expectation that @left and @right are equal.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1196   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1197   * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1198   * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1199   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1200   * Sets an expectation that the values that @left and @right evaluate to are
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1201   * equal. This is semantically equivalent to
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1202   * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1203   * more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1204   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1205  #define KUNIT_EXPECT_EQ(test, left, right) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1206  	KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1207  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1208  #define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1209  	KUNIT_BINARY_EQ_MSG_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1210  				      KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1211  				      left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1212  				      right,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1213  				      fmt,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1214  				      ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1215  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1216  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1217   * KUNIT_EXPECT_PTR_EQ() - Expects that pointers @left and @right are equal.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1218   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1219   * @left: an arbitrary expression that evaluates to a pointer.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1220   * @right: an arbitrary expression that evaluates to a pointer.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1221   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1222   * Sets an expectation that the values that @left and @right evaluate to are
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1223   * equal. This is semantically equivalent to
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1224   * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1225   * more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1226   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1227  #define KUNIT_EXPECT_PTR_EQ(test, left, right)				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1228  	KUNIT_BINARY_PTR_EQ_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1229  				      KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1230  				      left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1231  				      right)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1232  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1233  #define KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1234  	KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1235  					  KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1236  					  left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1237  					  right,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1238  					  fmt,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1239  					  ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1240  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1241  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1242   * KUNIT_EXPECT_NE() - An expectation that @left and @right are not equal.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1243   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1244   * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1245   * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1246   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1247   * Sets an expectation that the values that @left and @right evaluate to are not
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1248   * equal. This is semantically equivalent to
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1249   * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1250   * more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1251   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1252  #define KUNIT_EXPECT_NE(test, left, right) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1253  	KUNIT_BINARY_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1254  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1255  #define KUNIT_EXPECT_NE_MSG(test, left, right, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1256  	KUNIT_BINARY_NE_MSG_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1257  				      KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1258  				      left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1259  				      right,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1260  				      fmt,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1261  				      ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1262  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1263  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1264   * KUNIT_EXPECT_PTR_NE() - Expects that pointers @left and @right are not equal.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1265   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1266   * @left: an arbitrary expression that evaluates to a pointer.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1267   * @right: an arbitrary expression that evaluates to a pointer.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1268   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1269   * Sets an expectation that the values that @left and @right evaluate to are not
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1270   * equal. This is semantically equivalent to
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1271   * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1272   * more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1273   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1274  #define KUNIT_EXPECT_PTR_NE(test, left, right)				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1275  	KUNIT_BINARY_PTR_NE_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1276  				      KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1277  				      left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1278  				      right)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1279  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1280  #define KUNIT_EXPECT_PTR_NE_MSG(test, left, right, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1281  	KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1282  					  KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1283  					  left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1284  					  right,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1285  					  fmt,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1286  					  ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1287  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1288  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1289   * KUNIT_EXPECT_LT() - An expectation that @left is less than @right.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1290   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1291   * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1292   * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1293   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1294   * Sets an expectation that the value that @left evaluates to is less than the
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1295   * value that @right evaluates to. This is semantically equivalent to
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1296   * KUNIT_EXPECT_TRUE(@test, (@left) < (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1297   * more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1298   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1299  #define KUNIT_EXPECT_LT(test, left, right) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1300  	KUNIT_BINARY_LT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1301  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1302  #define KUNIT_EXPECT_LT_MSG(test, left, right, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1303  	KUNIT_BINARY_LT_MSG_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1304  				      KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1305  				      left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1306  				      right,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1307  				      fmt,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1308  				      ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1309  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1310  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1311   * KUNIT_EXPECT_LE() - Expects that @left is less than or equal to @right.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1312   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1313   * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1314   * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1315   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1316   * Sets an expectation that the value that @left evaluates to is less than or
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1317   * equal to the value that @right evaluates to. Semantically this is equivalent
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1318   * to KUNIT_EXPECT_TRUE(@test, (@left) <= (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1319   * more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1320   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1321  #define KUNIT_EXPECT_LE(test, left, right) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1322  	KUNIT_BINARY_LE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1323  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1324  #define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1325  	KUNIT_BINARY_LE_MSG_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1326  				      KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1327  				      left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1328  				      right,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1329  				      fmt,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1330  				      ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1331  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1332  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1333   * KUNIT_EXPECT_GT() - An expectation that @left is greater than @right.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1334   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1335   * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1336   * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1337   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1338   * Sets an expectation that the value that @left evaluates to is greater than
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1339   * the value that @right evaluates to. This is semantically equivalent to
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1340   * KUNIT_EXPECT_TRUE(@test, (@left) > (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1341   * more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1342   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1343  #define KUNIT_EXPECT_GT(test, left, right) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1344  	KUNIT_BINARY_GT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1345  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1346  #define KUNIT_EXPECT_GT_MSG(test, left, right, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1347  	KUNIT_BINARY_GT_MSG_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1348  				      KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1349  				      left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1350  				      right,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1351  				      fmt,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1352  				      ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1353  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1354  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1355   * KUNIT_EXPECT_GE() - Expects that @left is greater than or equal to @right.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1356   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1357   * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1358   * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1359   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1360   * Sets an expectation that the value that @left evaluates to is greater than
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1361   * the value that @right evaluates to. This is semantically equivalent to
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1362   * KUNIT_EXPECT_TRUE(@test, (@left) >= (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1363   * more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1364   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1365  #define KUNIT_EXPECT_GE(test, left, right) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1366  	KUNIT_BINARY_GE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1367  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1368  #define KUNIT_EXPECT_GE_MSG(test, left, right, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1369  	KUNIT_BINARY_GE_MSG_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1370  				      KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1371  				      left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1372  				      right,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1373  				      fmt,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1374  				      ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1375  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1376  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1377   * KUNIT_EXPECT_STREQ() - Expects that strings @left and @right are equal.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1378   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1379   * @left: an arbitrary expression that evaluates to a null terminated string.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1380   * @right: an arbitrary expression that evaluates to a null terminated string.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1381   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1382   * Sets an expectation that the values that @left and @right evaluate to are
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1383   * equal. This is semantically equivalent to
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1384   * KUNIT_EXPECT_TRUE(@test, !strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1385   * for more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1386   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1387  #define KUNIT_EXPECT_STREQ(test, left, right) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1388  	KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1389  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1390  #define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1391  	KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1392  					  KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1393  					  left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1394  					  right,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1395  					  fmt,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1396  					  ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1397  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1398  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1399   * KUNIT_EXPECT_STRNEQ() - Expects that strings @left and @right are not equal.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1400   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1401   * @left: an arbitrary expression that evaluates to a null terminated string.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1402   * @right: an arbitrary expression that evaluates to a null terminated string.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1403   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1404   * Sets an expectation that the values that @left and @right evaluate to are
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1405   * not equal. This is semantically equivalent to
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1406   * KUNIT_EXPECT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1407   * for more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1408   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1409  #define KUNIT_EXPECT_STRNEQ(test, left, right) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1410  	KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1411  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1412  #define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1413  	KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1414  					  KUNIT_EXPECTATION,		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1415  					  left,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1416  					  right,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1417  					  fmt,				       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1418  					  ##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1419  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1420  /**
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1421   * KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1422   * @test: The test context object.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1423   * @ptr: an arbitrary pointer.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1424   *
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1425   * Sets an expectation that the value that @ptr evaluates to is not null and not
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1426   * an errno stored in a pointer. This is semantically equivalent to
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1427   * KUNIT_EXPECT_TRUE(@test, !IS_ERR_OR_NULL(@ptr)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1428   * more information.
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1429   */
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1430  #define KUNIT_EXPECT_NOT_ERR_OR_NULL(test, ptr) \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1431  	KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, KUNIT_EXPECTATION, ptr)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1432  
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1433  #define KUNIT_EXPECT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...)		       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1434  	KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1435  						KUNIT_EXPECTATION,	       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1436  						ptr,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1437  						fmt,			       \
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1438  						##__VA_ARGS__)
73cda7bb8bfb1d4 Brendan Higgins     2019-09-23  1439  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1440  #define KUNIT_ASSERT_FAILURE(test, fmt, ...) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1441  	KUNIT_FAIL_ASSERTION(test, KUNIT_ASSERTION, fmt, ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1442  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1443  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1444   * KUNIT_ASSERT_TRUE() - Sets an assertion that @condition is true.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1445   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1446   * @condition: an arbitrary boolean expression. The test fails and aborts when
e4aea8f8532b55f Brendan Higgins     2019-09-23  1447   * this does not evaluate to true.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1448   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1449   * This and assertions of the form `KUNIT_ASSERT_*` will cause the test case to
e4aea8f8532b55f Brendan Higgins     2019-09-23  1450   * fail *and immediately abort* when the specified condition is not met. Unlike
e4aea8f8532b55f Brendan Higgins     2019-09-23  1451   * an expectation failure, it will prevent the test case from continuing to run;
e4aea8f8532b55f Brendan Higgins     2019-09-23  1452   * this is otherwise known as an *assertion failure*.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1453   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1454  #define KUNIT_ASSERT_TRUE(test, condition) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1455  	KUNIT_TRUE_ASSERTION(test, KUNIT_ASSERTION, condition)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1456  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1457  #define KUNIT_ASSERT_TRUE_MSG(test, condition, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1458  	KUNIT_TRUE_MSG_ASSERTION(test,					       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1459  				 KUNIT_ASSERTION,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1460  				 condition,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1461  				 fmt,					       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1462  				 ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1463  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1464  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1465   * KUNIT_ASSERT_FALSE() - Sets an assertion that @condition is false.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1466   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1467   * @condition: an arbitrary boolean expression.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1468   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1469   * Sets an assertion that the value that @condition evaluates to is false. This
e4aea8f8532b55f Brendan Higgins     2019-09-23  1470   * is the same as KUNIT_EXPECT_FALSE(), except it causes an assertion failure
e4aea8f8532b55f Brendan Higgins     2019-09-23  1471   * (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1472   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1473  #define KUNIT_ASSERT_FALSE(test, condition) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1474  	KUNIT_FALSE_ASSERTION(test, KUNIT_ASSERTION, condition)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1475  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1476  #define KUNIT_ASSERT_FALSE_MSG(test, condition, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1477  	KUNIT_FALSE_MSG_ASSERTION(test,					       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1478  				  KUNIT_ASSERTION,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1479  				  condition,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1480  				  fmt,					       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1481  				  ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1482  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1483  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1484   * KUNIT_ASSERT_EQ() - Sets an assertion that @left and @right are equal.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1485   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1486   * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1487   * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1488   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1489   * Sets an assertion that the values that @left and @right evaluate to are
e4aea8f8532b55f Brendan Higgins     2019-09-23  1490   * equal. This is the same as KUNIT_EXPECT_EQ(), except it causes an assertion
e4aea8f8532b55f Brendan Higgins     2019-09-23  1491   * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1492   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1493  #define KUNIT_ASSERT_EQ(test, left, right) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1494  	KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1495  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1496  #define KUNIT_ASSERT_EQ_MSG(test, left, right, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1497  	KUNIT_BINARY_EQ_MSG_ASSERTION(test,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1498  				      KUNIT_ASSERTION,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1499  				      left,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1500  				      right,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1501  				      fmt,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1502  				      ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1503  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1504  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1505   * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1506   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1507   * @left: an arbitrary expression that evaluates to a pointer.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1508   * @right: an arbitrary expression that evaluates to a pointer.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1509   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1510   * Sets an assertion that the values that @left and @right evaluate to are
e4aea8f8532b55f Brendan Higgins     2019-09-23  1511   * equal. This is the same as KUNIT_EXPECT_EQ(), except it causes an assertion
e4aea8f8532b55f Brendan Higgins     2019-09-23  1512   * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1513   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1514  #define KUNIT_ASSERT_PTR_EQ(test, left, right) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1515  	KUNIT_BINARY_PTR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1516  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1517  #define KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1518  	KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1519  					  KUNIT_ASSERTION,		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1520  					  left,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1521  					  right,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1522  					  fmt,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1523  					  ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1524  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1525  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1526   * KUNIT_ASSERT_NE() - An assertion that @left and @right are not equal.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1527   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1528   * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1529   * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1530   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1531   * Sets an assertion that the values that @left and @right evaluate to are not
e4aea8f8532b55f Brendan Higgins     2019-09-23  1532   * equal. This is the same as KUNIT_EXPECT_NE(), except it causes an assertion
e4aea8f8532b55f Brendan Higgins     2019-09-23  1533   * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1534   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1535  #define KUNIT_ASSERT_NE(test, left, right) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1536  	KUNIT_BINARY_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1537  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1538  #define KUNIT_ASSERT_NE_MSG(test, left, right, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1539  	KUNIT_BINARY_NE_MSG_ASSERTION(test,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1540  				      KUNIT_ASSERTION,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1541  				      left,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1542  				      right,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1543  				      fmt,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1544  				      ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1545  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1546  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1547   * KUNIT_ASSERT_PTR_NE() - Asserts that pointers @left and @right are not equal.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1548   * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1549   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1550   * @left: an arbitrary expression that evaluates to a pointer.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1551   * @right: an arbitrary expression that evaluates to a pointer.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1552   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1553   * Sets an assertion that the values that @left and @right evaluate to are not
e4aea8f8532b55f Brendan Higgins     2019-09-23  1554   * equal. This is the same as KUNIT_EXPECT_NE(), except it causes an assertion
e4aea8f8532b55f Brendan Higgins     2019-09-23  1555   * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1556   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1557  #define KUNIT_ASSERT_PTR_NE(test, left, right) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1558  	KUNIT_BINARY_PTR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1559  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1560  #define KUNIT_ASSERT_PTR_NE_MSG(test, left, right, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1561  	KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1562  					  KUNIT_ASSERTION,		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1563  					  left,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1564  					  right,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1565  					  fmt,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1566  					  ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1567  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1568   * KUNIT_ASSERT_LT() - An assertion that @left is less than @right.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1569   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1570   * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1571   * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1572   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1573   * Sets an assertion that the value that @left evaluates to is less than the
e4aea8f8532b55f Brendan Higgins     2019-09-23  1574   * value that @right evaluates to. This is the same as KUNIT_EXPECT_LT(), except
e4aea8f8532b55f Brendan Higgins     2019-09-23  1575   * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
e4aea8f8532b55f Brendan Higgins     2019-09-23  1576   * is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1577   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1578  #define KUNIT_ASSERT_LT(test, left, right) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1579  	KUNIT_BINARY_LT_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1580  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1581  #define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1582  	KUNIT_BINARY_LT_MSG_ASSERTION(test,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1583  				      KUNIT_ASSERTION,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1584  				      left,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1585  				      right,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1586  				      fmt,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1587  				      ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1588  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1589   * KUNIT_ASSERT_LE() - An assertion that @left is less than or equal to @right.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1590   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1591   * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1592   * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1593   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1594   * Sets an assertion that the value that @left evaluates to is less than or
e4aea8f8532b55f Brendan Higgins     2019-09-23  1595   * equal to the value that @right evaluates to. This is the same as
e4aea8f8532b55f Brendan Higgins     2019-09-23  1596   * KUNIT_EXPECT_LE(), except it causes an assertion failure (see
e4aea8f8532b55f Brendan Higgins     2019-09-23  1597   * KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1598   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1599  #define KUNIT_ASSERT_LE(test, left, right) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1600  	KUNIT_BINARY_LE_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1601  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1602  #define KUNIT_ASSERT_LE_MSG(test, left, right, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1603  	KUNIT_BINARY_LE_MSG_ASSERTION(test,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1604  				      KUNIT_ASSERTION,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1605  				      left,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1606  				      right,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1607  				      fmt,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1608  				      ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1609  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1610  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1611   * KUNIT_ASSERT_GT() - An assertion that @left is greater than @right.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1612   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1613   * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1614   * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1615   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1616   * Sets an assertion that the value that @left evaluates to is greater than the
e4aea8f8532b55f Brendan Higgins     2019-09-23  1617   * value that @right evaluates to. This is the same as KUNIT_EXPECT_GT(), except
e4aea8f8532b55f Brendan Higgins     2019-09-23  1618   * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
e4aea8f8532b55f Brendan Higgins     2019-09-23  1619   * is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1620   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1621  #define KUNIT_ASSERT_GT(test, left, right) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1622  	KUNIT_BINARY_GT_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1623  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1624  #define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1625  	KUNIT_BINARY_GT_MSG_ASSERTION(test,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1626  				      KUNIT_ASSERTION,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1627  				      left,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1628  				      right,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1629  				      fmt,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1630  				      ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1631  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1632  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1633   * KUNIT_ASSERT_GE() - Assertion that @left is greater than or equal to @right.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1634   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1635   * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1636   * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1637   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1638   * Sets an assertion that the value that @left evaluates to is greater than the
e4aea8f8532b55f Brendan Higgins     2019-09-23  1639   * value that @right evaluates to. This is the same as KUNIT_EXPECT_GE(), except
e4aea8f8532b55f Brendan Higgins     2019-09-23  1640   * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
e4aea8f8532b55f Brendan Higgins     2019-09-23  1641   * is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1642   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1643  #define KUNIT_ASSERT_GE(test, left, right) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1644  	KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1645  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1646  #define KUNIT_ASSERT_GE_MSG(test, left, right, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1647  	KUNIT_BINARY_GE_MSG_ASSERTION(test,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1648  				      KUNIT_ASSERTION,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1649  				      left,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1650  				      right,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1651  				      fmt,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1652  				      ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1653  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1654  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1655   * KUNIT_ASSERT_STREQ() - An assertion that strings @left and @right are equal.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1656   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1657   * @left: an arbitrary expression that evaluates to a null terminated string.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1658   * @right: an arbitrary expression that evaluates to a null terminated string.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1659   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1660   * Sets an assertion that the values that @left and @right evaluate to are
e4aea8f8532b55f Brendan Higgins     2019-09-23  1661   * equal. This is the same as KUNIT_EXPECT_STREQ(), except it causes an
e4aea8f8532b55f Brendan Higgins     2019-09-23  1662   * assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1663   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1664  #define KUNIT_ASSERT_STREQ(test, left, right) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1665  	KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1666  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1667  #define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1668  	KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1669  					  KUNIT_ASSERTION,		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1670  					  left,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1671  					  right,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1672  					  fmt,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1673  					  ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1674  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1675  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1676   * KUNIT_ASSERT_STRNEQ() - Expects that strings @left and @right are not equal.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1677   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1678   * @left: an arbitrary expression that evaluates to a null terminated string.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1679   * @right: an arbitrary expression that evaluates to a null terminated string.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1680   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1681   * Sets an expectation that the values that @left and @right evaluate to are
e4aea8f8532b55f Brendan Higgins     2019-09-23  1682   * not equal. This is semantically equivalent to
e4aea8f8532b55f Brendan Higgins     2019-09-23  1683   * KUNIT_ASSERT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_ASSERT_TRUE()
e4aea8f8532b55f Brendan Higgins     2019-09-23  1684   * for more information.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1685   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1686  #define KUNIT_ASSERT_STRNEQ(test, left, right) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1687  	KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1688  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1689  #define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1690  	KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1691  					  KUNIT_ASSERTION,		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1692  					  left,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1693  					  right,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1694  					  fmt,				       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1695  					  ##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1696  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1697  /**
e4aea8f8532b55f Brendan Higgins     2019-09-23  1698   * KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1699   * @test: The test context object.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1700   * @ptr: an arbitrary pointer.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1701   *
e4aea8f8532b55f Brendan Higgins     2019-09-23  1702   * Sets an assertion that the value that @ptr evaluates to is not null and not
e4aea8f8532b55f Brendan Higgins     2019-09-23  1703   * an errno stored in a pointer. This is the same as
e4aea8f8532b55f Brendan Higgins     2019-09-23  1704   * KUNIT_EXPECT_NOT_ERR_OR_NULL(), except it causes an assertion failure (see
e4aea8f8532b55f Brendan Higgins     2019-09-23  1705   * KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55f Brendan Higgins     2019-09-23  1706   */
e4aea8f8532b55f Brendan Higgins     2019-09-23  1707  #define KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr) \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1708  	KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, KUNIT_ASSERTION, ptr)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1709  
e4aea8f8532b55f Brendan Higgins     2019-09-23  1710  #define KUNIT_ASSERT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...)		       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1711  	KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1712  						KUNIT_ASSERTION,	       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1713  						ptr,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1714  						fmt,			       \
e4aea8f8532b55f Brendan Higgins     2019-09-23  1715  						##__VA_ARGS__)
e4aea8f8532b55f Brendan Higgins     2019-09-23  1716  
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1717  /**
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1718   * kunit_param_generator_helper() - Helper method for test parameter generators
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1719   * 				    required in parameterized tests.
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1720   * @test: The test context object.
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1721   * @prev_param: a pointer to the previous test parameter, NULL for first parameter.
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1722   * @param_array: a user-supplied pointer to an array of test parameters.
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1723   * @array_size: number of test parameters in the array.
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1724   * @type_size: size of one test parameter.
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1725   */
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1726  static inline void *kunit_param_generator_helper(struct kunit *test,
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1727  					void *prev_param,
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1728  					void *param_array,
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1729  					size_t array_size,
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1730  					size_t type_size)
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1731  {
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23 @1732  	KUNIT_ASSERT_EQ(test, (prev_param - param_array) % type_size, 0);
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1733  
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1734  	if (!prev_param)
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1735  		return param_array;
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1736  
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1737  	KUNIT_ASSERT_GE(test, prev_param, param_array);
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1738  
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1739  	if (prev_param + type_size < param_array + (array_size * type_size))
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1740  		return prev_param + type_size;
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1741  	else
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1742  		return NULL;
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1743  }
2c09a7974ce3b43 Arpitha Raghunandan 2020-10-23  1744  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33172 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] kunit: Support for Parameterized Testing
  2020-10-23 15:05 [PATCH v2 1/2] kunit: Support for Parameterized Testing Arpitha Raghunandan
  2020-10-23 15:06 ` [PATCH v2 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature Arpitha Raghunandan
@ 2020-10-23 18:08 ` kernel test robot
  2020-10-23 18:14 ` kernel test robot
  2020-10-23 18:48 ` Marco Elver
  3 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2020-10-23 18:08 UTC (permalink / raw)
  To: Arpitha Raghunandan, brendanhiggins, skhan, elver, yzaikin,
	tytso, adilger.kernel
  Cc: kbuild-all, clang-built-linux, Arpitha Raghunandan,
	linux-kselftest, kunit-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 41868 bytes --]

Hi Arpitha,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ext4/dev]
[also build test WARNING on linus/master v5.9 next-20201023]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Arpitha-Raghunandan/kunit-Support-for-Parameterized-Testing/20201023-230827
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
config: x86_64-randconfig-r015-20201023 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 147b9497e79a98a8614b2b5eb4ba653b44f6b6f0)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/2c09a7974ce3b438845bfafb539513dc91c021b4
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Arpitha-Raghunandan/kunit-Support-for-Parameterized-Testing/20201023-230827
        git checkout 2c09a7974ce3b438845bfafb539513dc91c021b4
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from lib/kunit/test.c:9:
>> include/kunit/test.h:1732:2: warning: comparison of distinct pointer types ('typeof (__left) *' (aka 'unsigned long *') and 'typeof (__right) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
           KUNIT_ASSERT_EQ(test, (prev_param - param_array) % type_size, 0);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1494:2: note: expanded from macro 'KUNIT_ASSERT_EQ'
           KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:843:2: note: expanded from macro 'KUNIT_BINARY_EQ_ASSERTION'
           KUNIT_BINARY_EQ_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:833:2: note: expanded from macro 'KUNIT_BINARY_EQ_MSG_ASSERTION'
           KUNIT_BASE_EQ_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:744:2: note: expanded from macro 'KUNIT_BASE_EQ_MSG_ASSERTION'
           KUNIT_BASE_BINARY_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:720:9: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
           ((void)__typecheck(__left, __right));                                  \
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:850:29: note: expanded from macro '__typecheck'
                   (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                              ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
   In file included from lib/kunit/test.c:9:
>> include/kunit/test.h:1737:2: warning: incompatible pointer to integer conversion initializing 'long long' with an expression of type 'typeof (prev_param)' (aka 'void *') [-Wint-conversion]
           KUNIT_ASSERT_GE(test, prev_param, param_array);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1644:2: note: expanded from macro 'KUNIT_ASSERT_GE'
           KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1038:2: note: expanded from macro 'KUNIT_BINARY_GE_ASSERTION'
           KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1028:2: note: expanded from macro 'KUNIT_BINARY_GE_MSG_ASSERTION'
           KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/kunit/test.h:729:8: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
                                             __left,                              \
                                             ^~~~~~
   include/kunit/assert.h:238:16: note: expanded from macro 'KUNIT_INIT_BINARY_ASSERT_STRUCT'
           .left_value = left_val,                                                \
                         ^~~~~~~~
   include/kunit/test.h:622:36: note: expanded from macro 'KUNIT_ASSERTION'
           struct assert_class __assertion = INITIALIZER;                         \
                                             ^~~~~~~~~~~
>> include/kunit/test.h:1737:2: warning: incompatible pointer to integer conversion initializing 'long long' with an expression of type 'typeof (param_array)' (aka 'void *') [-Wint-conversion]
           KUNIT_ASSERT_GE(test, prev_param, param_array);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1644:2: note: expanded from macro 'KUNIT_ASSERT_GE'
           KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1038:2: note: expanded from macro 'KUNIT_BINARY_GE_ASSERTION'
           KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1028:2: note: expanded from macro 'KUNIT_BINARY_GE_MSG_ASSERTION'
           KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/kunit/test.h:731:8: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
                                             __right),                            \
                                             ^~~~~~~
   include/kunit/assert.h:240:17: note: expanded from macro 'KUNIT_INIT_BINARY_ASSERT_STRUCT'
           .right_value = right_val                                               \
                          ^~~~~~~~~
   include/kunit/test.h:622:36: note: expanded from macro 'KUNIT_ASSERTION'
           struct assert_class __assertion = INITIALIZER;                         \
                                             ^~~~~~~~~~~
   3 warnings generated.
--
   In file included from lib/kunit/debugfs.c:10:
>> include/kunit/test.h:1732:2: warning: comparison of distinct pointer types ('typeof (__left) *' (aka 'unsigned long *') and 'typeof (__right) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
           KUNIT_ASSERT_EQ(test, (prev_param - param_array) % type_size, 0);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1494:2: note: expanded from macro 'KUNIT_ASSERT_EQ'
           KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:843:2: note: expanded from macro 'KUNIT_BINARY_EQ_ASSERTION'
           KUNIT_BINARY_EQ_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:833:2: note: expanded from macro 'KUNIT_BINARY_EQ_MSG_ASSERTION'
           KUNIT_BASE_EQ_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:744:2: note: expanded from macro 'KUNIT_BASE_EQ_MSG_ASSERTION'
           KUNIT_BASE_BINARY_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:720:9: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
           ((void)__typecheck(__left, __right));                                  \
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:850:29: note: expanded from macro '__typecheck'
                   (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                              ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
   In file included from lib/kunit/debugfs.c:10:
>> include/kunit/test.h:1737:2: warning: incompatible pointer to integer conversion initializing 'long long' with an expression of type 'typeof (prev_param)' (aka 'void *') [-Wint-conversion]
           KUNIT_ASSERT_GE(test, prev_param, param_array);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1644:2: note: expanded from macro 'KUNIT_ASSERT_GE'
           KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1038:2: note: expanded from macro 'KUNIT_BINARY_GE_ASSERTION'
           KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1028:2: note: expanded from macro 'KUNIT_BINARY_GE_MSG_ASSERTION'
           KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/kunit/test.h:729:8: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
                                             __left,                              \
                                             ^~~~~~
   include/kunit/assert.h:238:16: note: expanded from macro 'KUNIT_INIT_BINARY_ASSERT_STRUCT'
           .left_value = left_val,                                                \
                         ^~~~~~~~
   include/kunit/test.h:622:36: note: expanded from macro 'KUNIT_ASSERTION'
           struct assert_class __assertion = INITIALIZER;                         \
                                             ^~~~~~~~~~~
>> include/kunit/test.h:1737:2: warning: incompatible pointer to integer conversion initializing 'long long' with an expression of type 'typeof (param_array)' (aka 'void *') [-Wint-conversion]
           KUNIT_ASSERT_GE(test, prev_param, param_array);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1644:2: note: expanded from macro 'KUNIT_ASSERT_GE'
           KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1038:2: note: expanded from macro 'KUNIT_BINARY_GE_ASSERTION'
           KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1028:2: note: expanded from macro 'KUNIT_BINARY_GE_MSG_ASSERTION'
           KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/kunit/test.h:731:8: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
                                             __right),                            \
                                             ^~~~~~~
   include/kunit/assert.h:240:17: note: expanded from macro 'KUNIT_INIT_BINARY_ASSERT_STRUCT'
           .right_value = right_val                                               \
                          ^~~~~~~~~
   include/kunit/test.h:622:36: note: expanded from macro 'KUNIT_ASSERTION'
           struct assert_class __assertion = INITIALIZER;                         \
                                             ^~~~~~~~~~~
   lib/kunit/debugfs.c:28:6: warning: no previous prototype for function 'kunit_debugfs_cleanup' [-Wmissing-prototypes]
   void kunit_debugfs_cleanup(void)
        ^
   lib/kunit/debugfs.c:28:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void kunit_debugfs_cleanup(void)
   ^
   static 
   lib/kunit/debugfs.c:33:6: warning: no previous prototype for function 'kunit_debugfs_init' [-Wmissing-prototypes]
   void kunit_debugfs_init(void)
        ^
   lib/kunit/debugfs.c:33:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void kunit_debugfs_init(void)
   ^
   static 
   lib/kunit/debugfs.c:92:6: warning: no previous prototype for function 'kunit_debugfs_create_suite' [-Wmissing-prototypes]
   void kunit_debugfs_create_suite(struct kunit_suite *suite)
        ^
   lib/kunit/debugfs.c:92:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void kunit_debugfs_create_suite(struct kunit_suite *suite)
   ^
   static 
   lib/kunit/debugfs.c:108:6: warning: no previous prototype for function 'kunit_debugfs_destroy_suite' [-Wmissing-prototypes]
   void kunit_debugfs_destroy_suite(struct kunit_suite *suite)
        ^
   lib/kunit/debugfs.c:108:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void kunit_debugfs_destroy_suite(struct kunit_suite *suite)
   ^
   static 
   7 warnings generated.

vim +1732 include/kunit/test.h

  1147	
  1148	#define KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, assert_type, ptr)	       \
  1149		KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,			       \
  1150							assert_type,		       \
  1151							ptr,			       \
  1152							NULL)
  1153	
  1154	/**
  1155	 * KUNIT_EXPECT_TRUE() - Causes a test failure when the expression is not true.
  1156	 * @test: The test context object.
  1157	 * @condition: an arbitrary boolean expression. The test fails when this does
  1158	 * not evaluate to true.
  1159	 *
  1160	 * This and expectations of the form `KUNIT_EXPECT_*` will cause the test case
  1161	 * to fail when the specified condition is not met; however, it will not prevent
  1162	 * the test case from continuing to run; this is otherwise known as an
  1163	 * *expectation failure*.
  1164	 */
  1165	#define KUNIT_EXPECT_TRUE(test, condition) \
  1166		KUNIT_TRUE_ASSERTION(test, KUNIT_EXPECTATION, condition)
  1167	
  1168	#define KUNIT_EXPECT_TRUE_MSG(test, condition, fmt, ...)		       \
  1169		KUNIT_TRUE_MSG_ASSERTION(test,					       \
  1170					 KUNIT_EXPECTATION,			       \
  1171					 condition,				       \
  1172					 fmt,					       \
  1173					 ##__VA_ARGS__)
  1174	
  1175	/**
  1176	 * KUNIT_EXPECT_FALSE() - Makes a test failure when the expression is not false.
  1177	 * @test: The test context object.
  1178	 * @condition: an arbitrary boolean expression. The test fails when this does
  1179	 * not evaluate to false.
  1180	 *
  1181	 * Sets an expectation that @condition evaluates to false. See
  1182	 * KUNIT_EXPECT_TRUE() for more information.
  1183	 */
  1184	#define KUNIT_EXPECT_FALSE(test, condition) \
  1185		KUNIT_FALSE_ASSERTION(test, KUNIT_EXPECTATION, condition)
  1186	
  1187	#define KUNIT_EXPECT_FALSE_MSG(test, condition, fmt, ...)		       \
  1188		KUNIT_FALSE_MSG_ASSERTION(test,					       \
  1189					  KUNIT_EXPECTATION,			       \
  1190					  condition,				       \
  1191					  fmt,					       \
  1192					  ##__VA_ARGS__)
  1193	
  1194	/**
  1195	 * KUNIT_EXPECT_EQ() - Sets an expectation that @left and @right are equal.
  1196	 * @test: The test context object.
  1197	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1198	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1199	 *
  1200	 * Sets an expectation that the values that @left and @right evaluate to are
  1201	 * equal. This is semantically equivalent to
  1202	 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
  1203	 * more information.
  1204	 */
  1205	#define KUNIT_EXPECT_EQ(test, left, right) \
  1206		KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1207	
  1208	#define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...)		       \
  1209		KUNIT_BINARY_EQ_MSG_ASSERTION(test,				       \
  1210					      KUNIT_EXPECTATION,		       \
  1211					      left,				       \
  1212					      right,				       \
  1213					      fmt,				       \
  1214					      ##__VA_ARGS__)
  1215	
  1216	/**
  1217	 * KUNIT_EXPECT_PTR_EQ() - Expects that pointers @left and @right are equal.
  1218	 * @test: The test context object.
  1219	 * @left: an arbitrary expression that evaluates to a pointer.
  1220	 * @right: an arbitrary expression that evaluates to a pointer.
  1221	 *
  1222	 * Sets an expectation that the values that @left and @right evaluate to are
  1223	 * equal. This is semantically equivalent to
  1224	 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
  1225	 * more information.
  1226	 */
  1227	#define KUNIT_EXPECT_PTR_EQ(test, left, right)				       \
  1228		KUNIT_BINARY_PTR_EQ_ASSERTION(test,				       \
  1229					      KUNIT_EXPECTATION,		       \
  1230					      left,				       \
  1231					      right)
  1232	
  1233	#define KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, fmt, ...)		       \
  1234		KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test,				       \
  1235						  KUNIT_EXPECTATION,		       \
  1236						  left,				       \
  1237						  right,			       \
  1238						  fmt,				       \
  1239						  ##__VA_ARGS__)
  1240	
  1241	/**
  1242	 * KUNIT_EXPECT_NE() - An expectation that @left and @right are not equal.
  1243	 * @test: The test context object.
  1244	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1245	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1246	 *
  1247	 * Sets an expectation that the values that @left and @right evaluate to are not
  1248	 * equal. This is semantically equivalent to
  1249	 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
  1250	 * more information.
  1251	 */
  1252	#define KUNIT_EXPECT_NE(test, left, right) \
  1253		KUNIT_BINARY_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1254	
  1255	#define KUNIT_EXPECT_NE_MSG(test, left, right, fmt, ...)		       \
  1256		KUNIT_BINARY_NE_MSG_ASSERTION(test,				       \
  1257					      KUNIT_EXPECTATION,		       \
  1258					      left,				       \
  1259					      right,				       \
  1260					      fmt,				       \
  1261					      ##__VA_ARGS__)
  1262	
  1263	/**
  1264	 * KUNIT_EXPECT_PTR_NE() - Expects that pointers @left and @right are not equal.
  1265	 * @test: The test context object.
  1266	 * @left: an arbitrary expression that evaluates to a pointer.
  1267	 * @right: an arbitrary expression that evaluates to a pointer.
  1268	 *
  1269	 * Sets an expectation that the values that @left and @right evaluate to are not
  1270	 * equal. This is semantically equivalent to
  1271	 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
  1272	 * more information.
  1273	 */
  1274	#define KUNIT_EXPECT_PTR_NE(test, left, right)				       \
  1275		KUNIT_BINARY_PTR_NE_ASSERTION(test,				       \
  1276					      KUNIT_EXPECTATION,		       \
  1277					      left,				       \
  1278					      right)
  1279	
  1280	#define KUNIT_EXPECT_PTR_NE_MSG(test, left, right, fmt, ...)		       \
  1281		KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test,				       \
  1282						  KUNIT_EXPECTATION,		       \
  1283						  left,				       \
  1284						  right,			       \
  1285						  fmt,				       \
  1286						  ##__VA_ARGS__)
  1287	
  1288	/**
  1289	 * KUNIT_EXPECT_LT() - An expectation that @left is less than @right.
  1290	 * @test: The test context object.
  1291	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1292	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1293	 *
  1294	 * Sets an expectation that the value that @left evaluates to is less than the
  1295	 * value that @right evaluates to. This is semantically equivalent to
  1296	 * KUNIT_EXPECT_TRUE(@test, (@left) < (@right)). See KUNIT_EXPECT_TRUE() for
  1297	 * more information.
  1298	 */
  1299	#define KUNIT_EXPECT_LT(test, left, right) \
  1300		KUNIT_BINARY_LT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1301	
  1302	#define KUNIT_EXPECT_LT_MSG(test, left, right, fmt, ...)		       \
  1303		KUNIT_BINARY_LT_MSG_ASSERTION(test,				       \
  1304					      KUNIT_EXPECTATION,		       \
  1305					      left,				       \
  1306					      right,				       \
  1307					      fmt,				       \
  1308					      ##__VA_ARGS__)
  1309	
  1310	/**
  1311	 * KUNIT_EXPECT_LE() - Expects that @left is less than or equal to @right.
  1312	 * @test: The test context object.
  1313	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1314	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1315	 *
  1316	 * Sets an expectation that the value that @left evaluates to is less than or
  1317	 * equal to the value that @right evaluates to. Semantically this is equivalent
  1318	 * to KUNIT_EXPECT_TRUE(@test, (@left) <= (@right)). See KUNIT_EXPECT_TRUE() for
  1319	 * more information.
  1320	 */
  1321	#define KUNIT_EXPECT_LE(test, left, right) \
  1322		KUNIT_BINARY_LE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1323	
  1324	#define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...)		       \
  1325		KUNIT_BINARY_LE_MSG_ASSERTION(test,				       \
  1326					      KUNIT_EXPECTATION,		       \
  1327					      left,				       \
  1328					      right,				       \
  1329					      fmt,				       \
  1330					      ##__VA_ARGS__)
  1331	
  1332	/**
  1333	 * KUNIT_EXPECT_GT() - An expectation that @left is greater than @right.
  1334	 * @test: The test context object.
  1335	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1336	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1337	 *
  1338	 * Sets an expectation that the value that @left evaluates to is greater than
  1339	 * the value that @right evaluates to. This is semantically equivalent to
  1340	 * KUNIT_EXPECT_TRUE(@test, (@left) > (@right)). See KUNIT_EXPECT_TRUE() for
  1341	 * more information.
  1342	 */
  1343	#define KUNIT_EXPECT_GT(test, left, right) \
  1344		KUNIT_BINARY_GT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1345	
  1346	#define KUNIT_EXPECT_GT_MSG(test, left, right, fmt, ...)		       \
  1347		KUNIT_BINARY_GT_MSG_ASSERTION(test,				       \
  1348					      KUNIT_EXPECTATION,		       \
  1349					      left,				       \
  1350					      right,				       \
  1351					      fmt,				       \
  1352					      ##__VA_ARGS__)
  1353	
  1354	/**
  1355	 * KUNIT_EXPECT_GE() - Expects that @left is greater than or equal to @right.
  1356	 * @test: The test context object.
  1357	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1358	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1359	 *
  1360	 * Sets an expectation that the value that @left evaluates to is greater than
  1361	 * the value that @right evaluates to. This is semantically equivalent to
  1362	 * KUNIT_EXPECT_TRUE(@test, (@left) >= (@right)). See KUNIT_EXPECT_TRUE() for
  1363	 * more information.
  1364	 */
  1365	#define KUNIT_EXPECT_GE(test, left, right) \
  1366		KUNIT_BINARY_GE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1367	
  1368	#define KUNIT_EXPECT_GE_MSG(test, left, right, fmt, ...)		       \
  1369		KUNIT_BINARY_GE_MSG_ASSERTION(test,				       \
  1370					      KUNIT_EXPECTATION,		       \
  1371					      left,				       \
  1372					      right,				       \
  1373					      fmt,				       \
  1374					      ##__VA_ARGS__)
  1375	
  1376	/**
  1377	 * KUNIT_EXPECT_STREQ() - Expects that strings @left and @right are equal.
  1378	 * @test: The test context object.
  1379	 * @left: an arbitrary expression that evaluates to a null terminated string.
  1380	 * @right: an arbitrary expression that evaluates to a null terminated string.
  1381	 *
  1382	 * Sets an expectation that the values that @left and @right evaluate to are
  1383	 * equal. This is semantically equivalent to
  1384	 * KUNIT_EXPECT_TRUE(@test, !strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
  1385	 * for more information.
  1386	 */
  1387	#define KUNIT_EXPECT_STREQ(test, left, right) \
  1388		KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1389	
  1390	#define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...)		       \
  1391		KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,				       \
  1392						  KUNIT_EXPECTATION,		       \
  1393						  left,				       \
  1394						  right,			       \
  1395						  fmt,				       \
  1396						  ##__VA_ARGS__)
  1397	
  1398	/**
  1399	 * KUNIT_EXPECT_STRNEQ() - Expects that strings @left and @right are not equal.
  1400	 * @test: The test context object.
  1401	 * @left: an arbitrary expression that evaluates to a null terminated string.
  1402	 * @right: an arbitrary expression that evaluates to a null terminated string.
  1403	 *
  1404	 * Sets an expectation that the values that @left and @right evaluate to are
  1405	 * not equal. This is semantically equivalent to
  1406	 * KUNIT_EXPECT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
  1407	 * for more information.
  1408	 */
  1409	#define KUNIT_EXPECT_STRNEQ(test, left, right) \
  1410		KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1411	
  1412	#define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...)		       \
  1413		KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,				       \
  1414						  KUNIT_EXPECTATION,		       \
  1415						  left,				       \
  1416						  right,			       \
  1417						  fmt,				       \
  1418						  ##__VA_ARGS__)
  1419	
  1420	/**
  1421	 * KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err.
  1422	 * @test: The test context object.
  1423	 * @ptr: an arbitrary pointer.
  1424	 *
  1425	 * Sets an expectation that the value that @ptr evaluates to is not null and not
  1426	 * an errno stored in a pointer. This is semantically equivalent to
  1427	 * KUNIT_EXPECT_TRUE(@test, !IS_ERR_OR_NULL(@ptr)). See KUNIT_EXPECT_TRUE() for
  1428	 * more information.
  1429	 */
  1430	#define KUNIT_EXPECT_NOT_ERR_OR_NULL(test, ptr) \
  1431		KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, KUNIT_EXPECTATION, ptr)
  1432	
  1433	#define KUNIT_EXPECT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...)		       \
  1434		KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,			       \
  1435							KUNIT_EXPECTATION,	       \
  1436							ptr,			       \
  1437							fmt,			       \
  1438							##__VA_ARGS__)
  1439	
  1440	#define KUNIT_ASSERT_FAILURE(test, fmt, ...) \
  1441		KUNIT_FAIL_ASSERTION(test, KUNIT_ASSERTION, fmt, ##__VA_ARGS__)
  1442	
  1443	/**
  1444	 * KUNIT_ASSERT_TRUE() - Sets an assertion that @condition is true.
  1445	 * @test: The test context object.
  1446	 * @condition: an arbitrary boolean expression. The test fails and aborts when
  1447	 * this does not evaluate to true.
  1448	 *
  1449	 * This and assertions of the form `KUNIT_ASSERT_*` will cause the test case to
  1450	 * fail *and immediately abort* when the specified condition is not met. Unlike
  1451	 * an expectation failure, it will prevent the test case from continuing to run;
  1452	 * this is otherwise known as an *assertion failure*.
  1453	 */
  1454	#define KUNIT_ASSERT_TRUE(test, condition) \
  1455		KUNIT_TRUE_ASSERTION(test, KUNIT_ASSERTION, condition)
  1456	
  1457	#define KUNIT_ASSERT_TRUE_MSG(test, condition, fmt, ...)		       \
  1458		KUNIT_TRUE_MSG_ASSERTION(test,					       \
  1459					 KUNIT_ASSERTION,			       \
  1460					 condition,				       \
  1461					 fmt,					       \
  1462					 ##__VA_ARGS__)
  1463	
  1464	/**
  1465	 * KUNIT_ASSERT_FALSE() - Sets an assertion that @condition is false.
  1466	 * @test: The test context object.
  1467	 * @condition: an arbitrary boolean expression.
  1468	 *
  1469	 * Sets an assertion that the value that @condition evaluates to is false. This
  1470	 * is the same as KUNIT_EXPECT_FALSE(), except it causes an assertion failure
  1471	 * (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1472	 */
  1473	#define KUNIT_ASSERT_FALSE(test, condition) \
  1474		KUNIT_FALSE_ASSERTION(test, KUNIT_ASSERTION, condition)
  1475	
  1476	#define KUNIT_ASSERT_FALSE_MSG(test, condition, fmt, ...)		       \
  1477		KUNIT_FALSE_MSG_ASSERTION(test,					       \
  1478					  KUNIT_ASSERTION,			       \
  1479					  condition,				       \
  1480					  fmt,					       \
  1481					  ##__VA_ARGS__)
  1482	
  1483	/**
  1484	 * KUNIT_ASSERT_EQ() - Sets an assertion that @left and @right are equal.
  1485	 * @test: The test context object.
  1486	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1487	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1488	 *
  1489	 * Sets an assertion that the values that @left and @right evaluate to are
  1490	 * equal. This is the same as KUNIT_EXPECT_EQ(), except it causes an assertion
  1491	 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1492	 */
  1493	#define KUNIT_ASSERT_EQ(test, left, right) \
  1494		KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1495	
  1496	#define KUNIT_ASSERT_EQ_MSG(test, left, right, fmt, ...)		       \
  1497		KUNIT_BINARY_EQ_MSG_ASSERTION(test,				       \
  1498					      KUNIT_ASSERTION,			       \
  1499					      left,				       \
  1500					      right,				       \
  1501					      fmt,				       \
  1502					      ##__VA_ARGS__)
  1503	
  1504	/**
  1505	 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
  1506	 * @test: The test context object.
  1507	 * @left: an arbitrary expression that evaluates to a pointer.
  1508	 * @right: an arbitrary expression that evaluates to a pointer.
  1509	 *
  1510	 * Sets an assertion that the values that @left and @right evaluate to are
  1511	 * equal. This is the same as KUNIT_EXPECT_EQ(), except it causes an assertion
  1512	 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1513	 */
  1514	#define KUNIT_ASSERT_PTR_EQ(test, left, right) \
  1515		KUNIT_BINARY_PTR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1516	
  1517	#define KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, fmt, ...)		       \
  1518		KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test,				       \
  1519						  KUNIT_ASSERTION,		       \
  1520						  left,				       \
  1521						  right,			       \
  1522						  fmt,				       \
  1523						  ##__VA_ARGS__)
  1524	
  1525	/**
  1526	 * KUNIT_ASSERT_NE() - An assertion that @left and @right are not equal.
  1527	 * @test: The test context object.
  1528	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1529	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1530	 *
  1531	 * Sets an assertion that the values that @left and @right evaluate to are not
  1532	 * equal. This is the same as KUNIT_EXPECT_NE(), except it causes an assertion
  1533	 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1534	 */
  1535	#define KUNIT_ASSERT_NE(test, left, right) \
  1536		KUNIT_BINARY_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1537	
  1538	#define KUNIT_ASSERT_NE_MSG(test, left, right, fmt, ...)		       \
  1539		KUNIT_BINARY_NE_MSG_ASSERTION(test,				       \
  1540					      KUNIT_ASSERTION,			       \
  1541					      left,				       \
  1542					      right,				       \
  1543					      fmt,				       \
  1544					      ##__VA_ARGS__)
  1545	
  1546	/**
  1547	 * KUNIT_ASSERT_PTR_NE() - Asserts that pointers @left and @right are not equal.
  1548	 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
  1549	 * @test: The test context object.
  1550	 * @left: an arbitrary expression that evaluates to a pointer.
  1551	 * @right: an arbitrary expression that evaluates to a pointer.
  1552	 *
  1553	 * Sets an assertion that the values that @left and @right evaluate to are not
  1554	 * equal. This is the same as KUNIT_EXPECT_NE(), except it causes an assertion
  1555	 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1556	 */
  1557	#define KUNIT_ASSERT_PTR_NE(test, left, right) \
  1558		KUNIT_BINARY_PTR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1559	
  1560	#define KUNIT_ASSERT_PTR_NE_MSG(test, left, right, fmt, ...)		       \
  1561		KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test,				       \
  1562						  KUNIT_ASSERTION,		       \
  1563						  left,				       \
  1564						  right,			       \
  1565						  fmt,				       \
  1566						  ##__VA_ARGS__)
  1567	/**
  1568	 * KUNIT_ASSERT_LT() - An assertion that @left is less than @right.
  1569	 * @test: The test context object.
  1570	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1571	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1572	 *
  1573	 * Sets an assertion that the value that @left evaluates to is less than the
  1574	 * value that @right evaluates to. This is the same as KUNIT_EXPECT_LT(), except
  1575	 * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
  1576	 * is not met.
  1577	 */
  1578	#define KUNIT_ASSERT_LT(test, left, right) \
  1579		KUNIT_BINARY_LT_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1580	
  1581	#define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...)		       \
  1582		KUNIT_BINARY_LT_MSG_ASSERTION(test,				       \
  1583					      KUNIT_ASSERTION,			       \
  1584					      left,				       \
  1585					      right,				       \
  1586					      fmt,				       \
  1587					      ##__VA_ARGS__)
  1588	/**
  1589	 * KUNIT_ASSERT_LE() - An assertion that @left is less than or equal to @right.
  1590	 * @test: The test context object.
  1591	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1592	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1593	 *
  1594	 * Sets an assertion that the value that @left evaluates to is less than or
  1595	 * equal to the value that @right evaluates to. This is the same as
  1596	 * KUNIT_EXPECT_LE(), except it causes an assertion failure (see
  1597	 * KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1598	 */
  1599	#define KUNIT_ASSERT_LE(test, left, right) \
  1600		KUNIT_BINARY_LE_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1601	
  1602	#define KUNIT_ASSERT_LE_MSG(test, left, right, fmt, ...)		       \
  1603		KUNIT_BINARY_LE_MSG_ASSERTION(test,				       \
  1604					      KUNIT_ASSERTION,			       \
  1605					      left,				       \
  1606					      right,				       \
  1607					      fmt,				       \
  1608					      ##__VA_ARGS__)
  1609	
  1610	/**
  1611	 * KUNIT_ASSERT_GT() - An assertion that @left is greater than @right.
  1612	 * @test: The test context object.
  1613	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1614	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1615	 *
  1616	 * Sets an assertion that the value that @left evaluates to is greater than the
  1617	 * value that @right evaluates to. This is the same as KUNIT_EXPECT_GT(), except
  1618	 * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
  1619	 * is not met.
  1620	 */
  1621	#define KUNIT_ASSERT_GT(test, left, right) \
  1622		KUNIT_BINARY_GT_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1623	
  1624	#define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...)		       \
  1625		KUNIT_BINARY_GT_MSG_ASSERTION(test,				       \
  1626					      KUNIT_ASSERTION,			       \
  1627					      left,				       \
  1628					      right,				       \
  1629					      fmt,				       \
  1630					      ##__VA_ARGS__)
  1631	
  1632	/**
  1633	 * KUNIT_ASSERT_GE() - Assertion that @left is greater than or equal to @right.
  1634	 * @test: The test context object.
  1635	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1636	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1637	 *
  1638	 * Sets an assertion that the value that @left evaluates to is greater than the
  1639	 * value that @right evaluates to. This is the same as KUNIT_EXPECT_GE(), except
  1640	 * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
  1641	 * is not met.
  1642	 */
  1643	#define KUNIT_ASSERT_GE(test, left, right) \
  1644		KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1645	
  1646	#define KUNIT_ASSERT_GE_MSG(test, left, right, fmt, ...)		       \
  1647		KUNIT_BINARY_GE_MSG_ASSERTION(test,				       \
  1648					      KUNIT_ASSERTION,			       \
  1649					      left,				       \
  1650					      right,				       \
  1651					      fmt,				       \
  1652					      ##__VA_ARGS__)
  1653	
  1654	/**
  1655	 * KUNIT_ASSERT_STREQ() - An assertion that strings @left and @right are equal.
  1656	 * @test: The test context object.
  1657	 * @left: an arbitrary expression that evaluates to a null terminated string.
  1658	 * @right: an arbitrary expression that evaluates to a null terminated string.
  1659	 *
  1660	 * Sets an assertion that the values that @left and @right evaluate to are
  1661	 * equal. This is the same as KUNIT_EXPECT_STREQ(), except it causes an
  1662	 * assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1663	 */
  1664	#define KUNIT_ASSERT_STREQ(test, left, right) \
  1665		KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1666	
  1667	#define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...)		       \
  1668		KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,				       \
  1669						  KUNIT_ASSERTION,		       \
  1670						  left,				       \
  1671						  right,			       \
  1672						  fmt,				       \
  1673						  ##__VA_ARGS__)
  1674	
  1675	/**
  1676	 * KUNIT_ASSERT_STRNEQ() - Expects that strings @left and @right are not equal.
  1677	 * @test: The test context object.
  1678	 * @left: an arbitrary expression that evaluates to a null terminated string.
  1679	 * @right: an arbitrary expression that evaluates to a null terminated string.
  1680	 *
  1681	 * Sets an expectation that the values that @left and @right evaluate to are
  1682	 * not equal. This is semantically equivalent to
  1683	 * KUNIT_ASSERT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_ASSERT_TRUE()
  1684	 * for more information.
  1685	 */
  1686	#define KUNIT_ASSERT_STRNEQ(test, left, right) \
  1687		KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1688	
  1689	#define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...)		       \
  1690		KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,				       \
  1691						  KUNIT_ASSERTION,		       \
  1692						  left,				       \
  1693						  right,			       \
  1694						  fmt,				       \
  1695						  ##__VA_ARGS__)
  1696	
  1697	/**
  1698	 * KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err.
  1699	 * @test: The test context object.
  1700	 * @ptr: an arbitrary pointer.
  1701	 *
  1702	 * Sets an assertion that the value that @ptr evaluates to is not null and not
  1703	 * an errno stored in a pointer. This is the same as
  1704	 * KUNIT_EXPECT_NOT_ERR_OR_NULL(), except it causes an assertion failure (see
  1705	 * KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1706	 */
  1707	#define KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr) \
  1708		KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, KUNIT_ASSERTION, ptr)
  1709	
  1710	#define KUNIT_ASSERT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...)		       \
  1711		KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,			       \
  1712							KUNIT_ASSERTION,	       \
  1713							ptr,			       \
  1714							fmt,			       \
  1715							##__VA_ARGS__)
  1716	
  1717	/**
  1718	 * kunit_param_generator_helper() - Helper method for test parameter generators
  1719	 * 				    required in parameterized tests.
  1720	 * @test: The test context object.
  1721	 * @prev_param: a pointer to the previous test parameter, NULL for first parameter.
  1722	 * @param_array: a user-supplied pointer to an array of test parameters.
  1723	 * @array_size: number of test parameters in the array.
  1724	 * @type_size: size of one test parameter.
  1725	 */
  1726	static inline void *kunit_param_generator_helper(struct kunit *test,
  1727						void *prev_param,
  1728						void *param_array,
  1729						size_t array_size,
  1730						size_t type_size)
  1731	{
> 1732		KUNIT_ASSERT_EQ(test, (prev_param - param_array) % type_size, 0);
  1733	
  1734		if (!prev_param)
  1735			return param_array;
  1736	
> 1737		KUNIT_ASSERT_GE(test, prev_param, param_array);
  1738	
  1739		if (prev_param + type_size < param_array + (array_size * type_size))
  1740			return prev_param + type_size;
  1741		else
  1742			return NULL;
  1743	}
  1744	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32031 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] kunit: Support for Parameterized Testing
  2020-10-23 15:05 [PATCH v2 1/2] kunit: Support for Parameterized Testing Arpitha Raghunandan
  2020-10-23 15:06 ` [PATCH v2 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature Arpitha Raghunandan
  2020-10-23 18:08 ` [PATCH v2 1/2] kunit: Support for Parameterized Testing kernel test robot
@ 2020-10-23 18:14 ` kernel test robot
  2020-10-23 18:48 ` Marco Elver
  3 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2020-10-23 18:14 UTC (permalink / raw)
  To: Arpitha Raghunandan, brendanhiggins, skhan, elver, yzaikin,
	tytso, adilger.kernel
  Cc: kbuild-all, clang-built-linux, Arpitha Raghunandan,
	linux-kselftest, kunit-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 41866 bytes --]

Hi Arpitha,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ext4/dev]
[also build test WARNING on linus/master v5.9 next-20201023]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Arpitha-Raghunandan/kunit-Support-for-Parameterized-Testing/20201023-230827
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
config: arm64-randconfig-r026-20201023 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 147b9497e79a98a8614b2b5eb4ba653b44f6b6f0)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/2c09a7974ce3b438845bfafb539513dc91c021b4
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Arpitha-Raghunandan/kunit-Support-for-Parameterized-Testing/20201023-230827
        git checkout 2c09a7974ce3b438845bfafb539513dc91c021b4
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from lib/kunit/test.c:9:
>> include/kunit/test.h:1732:2: warning: comparison of distinct pointer types ('typeof (__left) *' (aka 'unsigned long *') and 'typeof (__right) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
           KUNIT_ASSERT_EQ(test, (prev_param - param_array) % type_size, 0);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1494:2: note: expanded from macro 'KUNIT_ASSERT_EQ'
           KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:843:2: note: expanded from macro 'KUNIT_BINARY_EQ_ASSERTION'
           KUNIT_BINARY_EQ_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:833:2: note: expanded from macro 'KUNIT_BINARY_EQ_MSG_ASSERTION'
           KUNIT_BASE_EQ_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:744:2: note: expanded from macro 'KUNIT_BASE_EQ_MSG_ASSERTION'
           KUNIT_BASE_BINARY_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:720:9: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
           ((void)__typecheck(__left, __right));                                  \
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:850:29: note: expanded from macro '__typecheck'
                   (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                              ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
   In file included from lib/kunit/test.c:9:
>> include/kunit/test.h:1737:2: warning: incompatible pointer to integer conversion initializing 'long long' with an expression of type 'typeof (prev_param)' (aka 'void *') [-Wint-conversion]
           KUNIT_ASSERT_GE(test, prev_param, param_array);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1644:2: note: expanded from macro 'KUNIT_ASSERT_GE'
           KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1038:2: note: expanded from macro 'KUNIT_BINARY_GE_ASSERTION'
           KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1028:2: note: expanded from macro 'KUNIT_BINARY_GE_MSG_ASSERTION'
           KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/kunit/test.h:729:8: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
                                             __left,                              \
                                             ^~~~~~
   include/kunit/assert.h:238:16: note: expanded from macro 'KUNIT_INIT_BINARY_ASSERT_STRUCT'
           .left_value = left_val,                                                \
                         ^~~~~~~~
   include/kunit/test.h:622:36: note: expanded from macro 'KUNIT_ASSERTION'
           struct assert_class __assertion = INITIALIZER;                         \
                                             ^~~~~~~~~~~
>> include/kunit/test.h:1737:2: warning: incompatible pointer to integer conversion initializing 'long long' with an expression of type 'typeof (param_array)' (aka 'void *') [-Wint-conversion]
           KUNIT_ASSERT_GE(test, prev_param, param_array);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1644:2: note: expanded from macro 'KUNIT_ASSERT_GE'
           KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1038:2: note: expanded from macro 'KUNIT_BINARY_GE_ASSERTION'
           KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1028:2: note: expanded from macro 'KUNIT_BINARY_GE_MSG_ASSERTION'
           KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/kunit/test.h:731:8: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
                                             __right),                            \
                                             ^~~~~~~
   include/kunit/assert.h:240:17: note: expanded from macro 'KUNIT_INIT_BINARY_ASSERT_STRUCT'
           .right_value = right_val                                               \
                          ^~~~~~~~~
   include/kunit/test.h:622:36: note: expanded from macro 'KUNIT_ASSERTION'
           struct assert_class __assertion = INITIALIZER;                         \
                                             ^~~~~~~~~~~
   3 warnings generated.
--
   In file included from lib/kunit/debugfs.c:10:
>> include/kunit/test.h:1732:2: warning: comparison of distinct pointer types ('typeof (__left) *' (aka 'unsigned long *') and 'typeof (__right) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
           KUNIT_ASSERT_EQ(test, (prev_param - param_array) % type_size, 0);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1494:2: note: expanded from macro 'KUNIT_ASSERT_EQ'
           KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:843:2: note: expanded from macro 'KUNIT_BINARY_EQ_ASSERTION'
           KUNIT_BINARY_EQ_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:833:2: note: expanded from macro 'KUNIT_BINARY_EQ_MSG_ASSERTION'
           KUNIT_BASE_EQ_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:744:2: note: expanded from macro 'KUNIT_BASE_EQ_MSG_ASSERTION'
           KUNIT_BASE_BINARY_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:720:9: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
           ((void)__typecheck(__left, __right));                                  \
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:850:29: note: expanded from macro '__typecheck'
                   (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                              ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
   In file included from lib/kunit/debugfs.c:10:
>> include/kunit/test.h:1737:2: warning: incompatible pointer to integer conversion initializing 'long long' with an expression of type 'typeof (prev_param)' (aka 'void *') [-Wint-conversion]
           KUNIT_ASSERT_GE(test, prev_param, param_array);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1644:2: note: expanded from macro 'KUNIT_ASSERT_GE'
           KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1038:2: note: expanded from macro 'KUNIT_BINARY_GE_ASSERTION'
           KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1028:2: note: expanded from macro 'KUNIT_BINARY_GE_MSG_ASSERTION'
           KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/kunit/test.h:729:8: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
                                             __left,                              \
                                             ^~~~~~
   include/kunit/assert.h:238:16: note: expanded from macro 'KUNIT_INIT_BINARY_ASSERT_STRUCT'
           .left_value = left_val,                                                \
                         ^~~~~~~~
   include/kunit/test.h:622:36: note: expanded from macro 'KUNIT_ASSERTION'
           struct assert_class __assertion = INITIALIZER;                         \
                                             ^~~~~~~~~~~
>> include/kunit/test.h:1737:2: warning: incompatible pointer to integer conversion initializing 'long long' with an expression of type 'typeof (param_array)' (aka 'void *') [-Wint-conversion]
           KUNIT_ASSERT_GE(test, prev_param, param_array);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1644:2: note: expanded from macro 'KUNIT_ASSERT_GE'
           KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1038:2: note: expanded from macro 'KUNIT_BINARY_GE_ASSERTION'
           KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1028:2: note: expanded from macro 'KUNIT_BINARY_GE_MSG_ASSERTION'
           KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/kunit/test.h:731:8: note: expanded from macro 'KUNIT_BASE_BINARY_ASSERTION'
                                             __right),                            \
                                             ^~~~~~~
   include/kunit/assert.h:240:17: note: expanded from macro 'KUNIT_INIT_BINARY_ASSERT_STRUCT'
           .right_value = right_val                                               \
                          ^~~~~~~~~
   include/kunit/test.h:622:36: note: expanded from macro 'KUNIT_ASSERTION'
           struct assert_class __assertion = INITIALIZER;                         \
                                             ^~~~~~~~~~~
   lib/kunit/debugfs.c:28:6: warning: no previous prototype for function 'kunit_debugfs_cleanup' [-Wmissing-prototypes]
   void kunit_debugfs_cleanup(void)
        ^
   lib/kunit/debugfs.c:28:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void kunit_debugfs_cleanup(void)
   ^
   static 
   lib/kunit/debugfs.c:33:6: warning: no previous prototype for function 'kunit_debugfs_init' [-Wmissing-prototypes]
   void kunit_debugfs_init(void)
        ^
   lib/kunit/debugfs.c:33:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void kunit_debugfs_init(void)
   ^
   static 
   lib/kunit/debugfs.c:92:6: warning: no previous prototype for function 'kunit_debugfs_create_suite' [-Wmissing-prototypes]
   void kunit_debugfs_create_suite(struct kunit_suite *suite)
        ^
   lib/kunit/debugfs.c:92:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void kunit_debugfs_create_suite(struct kunit_suite *suite)
   ^
   static 
   lib/kunit/debugfs.c:108:6: warning: no previous prototype for function 'kunit_debugfs_destroy_suite' [-Wmissing-prototypes]
   void kunit_debugfs_destroy_suite(struct kunit_suite *suite)
        ^
   lib/kunit/debugfs.c:108:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void kunit_debugfs_destroy_suite(struct kunit_suite *suite)
   ^
   static 
   7 warnings generated.

vim +1732 include/kunit/test.h

  1147	
  1148	#define KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, assert_type, ptr)	       \
  1149		KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,			       \
  1150							assert_type,		       \
  1151							ptr,			       \
  1152							NULL)
  1153	
  1154	/**
  1155	 * KUNIT_EXPECT_TRUE() - Causes a test failure when the expression is not true.
  1156	 * @test: The test context object.
  1157	 * @condition: an arbitrary boolean expression. The test fails when this does
  1158	 * not evaluate to true.
  1159	 *
  1160	 * This and expectations of the form `KUNIT_EXPECT_*` will cause the test case
  1161	 * to fail when the specified condition is not met; however, it will not prevent
  1162	 * the test case from continuing to run; this is otherwise known as an
  1163	 * *expectation failure*.
  1164	 */
  1165	#define KUNIT_EXPECT_TRUE(test, condition) \
  1166		KUNIT_TRUE_ASSERTION(test, KUNIT_EXPECTATION, condition)
  1167	
  1168	#define KUNIT_EXPECT_TRUE_MSG(test, condition, fmt, ...)		       \
  1169		KUNIT_TRUE_MSG_ASSERTION(test,					       \
  1170					 KUNIT_EXPECTATION,			       \
  1171					 condition,				       \
  1172					 fmt,					       \
  1173					 ##__VA_ARGS__)
  1174	
  1175	/**
  1176	 * KUNIT_EXPECT_FALSE() - Makes a test failure when the expression is not false.
  1177	 * @test: The test context object.
  1178	 * @condition: an arbitrary boolean expression. The test fails when this does
  1179	 * not evaluate to false.
  1180	 *
  1181	 * Sets an expectation that @condition evaluates to false. See
  1182	 * KUNIT_EXPECT_TRUE() for more information.
  1183	 */
  1184	#define KUNIT_EXPECT_FALSE(test, condition) \
  1185		KUNIT_FALSE_ASSERTION(test, KUNIT_EXPECTATION, condition)
  1186	
  1187	#define KUNIT_EXPECT_FALSE_MSG(test, condition, fmt, ...)		       \
  1188		KUNIT_FALSE_MSG_ASSERTION(test,					       \
  1189					  KUNIT_EXPECTATION,			       \
  1190					  condition,				       \
  1191					  fmt,					       \
  1192					  ##__VA_ARGS__)
  1193	
  1194	/**
  1195	 * KUNIT_EXPECT_EQ() - Sets an expectation that @left and @right are equal.
  1196	 * @test: The test context object.
  1197	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1198	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1199	 *
  1200	 * Sets an expectation that the values that @left and @right evaluate to are
  1201	 * equal. This is semantically equivalent to
  1202	 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
  1203	 * more information.
  1204	 */
  1205	#define KUNIT_EXPECT_EQ(test, left, right) \
  1206		KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1207	
  1208	#define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...)		       \
  1209		KUNIT_BINARY_EQ_MSG_ASSERTION(test,				       \
  1210					      KUNIT_EXPECTATION,		       \
  1211					      left,				       \
  1212					      right,				       \
  1213					      fmt,				       \
  1214					      ##__VA_ARGS__)
  1215	
  1216	/**
  1217	 * KUNIT_EXPECT_PTR_EQ() - Expects that pointers @left and @right are equal.
  1218	 * @test: The test context object.
  1219	 * @left: an arbitrary expression that evaluates to a pointer.
  1220	 * @right: an arbitrary expression that evaluates to a pointer.
  1221	 *
  1222	 * Sets an expectation that the values that @left and @right evaluate to are
  1223	 * equal. This is semantically equivalent to
  1224	 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
  1225	 * more information.
  1226	 */
  1227	#define KUNIT_EXPECT_PTR_EQ(test, left, right)				       \
  1228		KUNIT_BINARY_PTR_EQ_ASSERTION(test,				       \
  1229					      KUNIT_EXPECTATION,		       \
  1230					      left,				       \
  1231					      right)
  1232	
  1233	#define KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, fmt, ...)		       \
  1234		KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test,				       \
  1235						  KUNIT_EXPECTATION,		       \
  1236						  left,				       \
  1237						  right,			       \
  1238						  fmt,				       \
  1239						  ##__VA_ARGS__)
  1240	
  1241	/**
  1242	 * KUNIT_EXPECT_NE() - An expectation that @left and @right are not equal.
  1243	 * @test: The test context object.
  1244	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1245	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1246	 *
  1247	 * Sets an expectation that the values that @left and @right evaluate to are not
  1248	 * equal. This is semantically equivalent to
  1249	 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
  1250	 * more information.
  1251	 */
  1252	#define KUNIT_EXPECT_NE(test, left, right) \
  1253		KUNIT_BINARY_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1254	
  1255	#define KUNIT_EXPECT_NE_MSG(test, left, right, fmt, ...)		       \
  1256		KUNIT_BINARY_NE_MSG_ASSERTION(test,				       \
  1257					      KUNIT_EXPECTATION,		       \
  1258					      left,				       \
  1259					      right,				       \
  1260					      fmt,				       \
  1261					      ##__VA_ARGS__)
  1262	
  1263	/**
  1264	 * KUNIT_EXPECT_PTR_NE() - Expects that pointers @left and @right are not equal.
  1265	 * @test: The test context object.
  1266	 * @left: an arbitrary expression that evaluates to a pointer.
  1267	 * @right: an arbitrary expression that evaluates to a pointer.
  1268	 *
  1269	 * Sets an expectation that the values that @left and @right evaluate to are not
  1270	 * equal. This is semantically equivalent to
  1271	 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
  1272	 * more information.
  1273	 */
  1274	#define KUNIT_EXPECT_PTR_NE(test, left, right)				       \
  1275		KUNIT_BINARY_PTR_NE_ASSERTION(test,				       \
  1276					      KUNIT_EXPECTATION,		       \
  1277					      left,				       \
  1278					      right)
  1279	
  1280	#define KUNIT_EXPECT_PTR_NE_MSG(test, left, right, fmt, ...)		       \
  1281		KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test,				       \
  1282						  KUNIT_EXPECTATION,		       \
  1283						  left,				       \
  1284						  right,			       \
  1285						  fmt,				       \
  1286						  ##__VA_ARGS__)
  1287	
  1288	/**
  1289	 * KUNIT_EXPECT_LT() - An expectation that @left is less than @right.
  1290	 * @test: The test context object.
  1291	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1292	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1293	 *
  1294	 * Sets an expectation that the value that @left evaluates to is less than the
  1295	 * value that @right evaluates to. This is semantically equivalent to
  1296	 * KUNIT_EXPECT_TRUE(@test, (@left) < (@right)). See KUNIT_EXPECT_TRUE() for
  1297	 * more information.
  1298	 */
  1299	#define KUNIT_EXPECT_LT(test, left, right) \
  1300		KUNIT_BINARY_LT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1301	
  1302	#define KUNIT_EXPECT_LT_MSG(test, left, right, fmt, ...)		       \
  1303		KUNIT_BINARY_LT_MSG_ASSERTION(test,				       \
  1304					      KUNIT_EXPECTATION,		       \
  1305					      left,				       \
  1306					      right,				       \
  1307					      fmt,				       \
  1308					      ##__VA_ARGS__)
  1309	
  1310	/**
  1311	 * KUNIT_EXPECT_LE() - Expects that @left is less than or equal to @right.
  1312	 * @test: The test context object.
  1313	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1314	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1315	 *
  1316	 * Sets an expectation that the value that @left evaluates to is less than or
  1317	 * equal to the value that @right evaluates to. Semantically this is equivalent
  1318	 * to KUNIT_EXPECT_TRUE(@test, (@left) <= (@right)). See KUNIT_EXPECT_TRUE() for
  1319	 * more information.
  1320	 */
  1321	#define KUNIT_EXPECT_LE(test, left, right) \
  1322		KUNIT_BINARY_LE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1323	
  1324	#define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...)		       \
  1325		KUNIT_BINARY_LE_MSG_ASSERTION(test,				       \
  1326					      KUNIT_EXPECTATION,		       \
  1327					      left,				       \
  1328					      right,				       \
  1329					      fmt,				       \
  1330					      ##__VA_ARGS__)
  1331	
  1332	/**
  1333	 * KUNIT_EXPECT_GT() - An expectation that @left is greater than @right.
  1334	 * @test: The test context object.
  1335	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1336	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1337	 *
  1338	 * Sets an expectation that the value that @left evaluates to is greater than
  1339	 * the value that @right evaluates to. This is semantically equivalent to
  1340	 * KUNIT_EXPECT_TRUE(@test, (@left) > (@right)). See KUNIT_EXPECT_TRUE() for
  1341	 * more information.
  1342	 */
  1343	#define KUNIT_EXPECT_GT(test, left, right) \
  1344		KUNIT_BINARY_GT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1345	
  1346	#define KUNIT_EXPECT_GT_MSG(test, left, right, fmt, ...)		       \
  1347		KUNIT_BINARY_GT_MSG_ASSERTION(test,				       \
  1348					      KUNIT_EXPECTATION,		       \
  1349					      left,				       \
  1350					      right,				       \
  1351					      fmt,				       \
  1352					      ##__VA_ARGS__)
  1353	
  1354	/**
  1355	 * KUNIT_EXPECT_GE() - Expects that @left is greater than or equal to @right.
  1356	 * @test: The test context object.
  1357	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1358	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1359	 *
  1360	 * Sets an expectation that the value that @left evaluates to is greater than
  1361	 * the value that @right evaluates to. This is semantically equivalent to
  1362	 * KUNIT_EXPECT_TRUE(@test, (@left) >= (@right)). See KUNIT_EXPECT_TRUE() for
  1363	 * more information.
  1364	 */
  1365	#define KUNIT_EXPECT_GE(test, left, right) \
  1366		KUNIT_BINARY_GE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1367	
  1368	#define KUNIT_EXPECT_GE_MSG(test, left, right, fmt, ...)		       \
  1369		KUNIT_BINARY_GE_MSG_ASSERTION(test,				       \
  1370					      KUNIT_EXPECTATION,		       \
  1371					      left,				       \
  1372					      right,				       \
  1373					      fmt,				       \
  1374					      ##__VA_ARGS__)
  1375	
  1376	/**
  1377	 * KUNIT_EXPECT_STREQ() - Expects that strings @left and @right are equal.
  1378	 * @test: The test context object.
  1379	 * @left: an arbitrary expression that evaluates to a null terminated string.
  1380	 * @right: an arbitrary expression that evaluates to a null terminated string.
  1381	 *
  1382	 * Sets an expectation that the values that @left and @right evaluate to are
  1383	 * equal. This is semantically equivalent to
  1384	 * KUNIT_EXPECT_TRUE(@test, !strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
  1385	 * for more information.
  1386	 */
  1387	#define KUNIT_EXPECT_STREQ(test, left, right) \
  1388		KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1389	
  1390	#define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...)		       \
  1391		KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,				       \
  1392						  KUNIT_EXPECTATION,		       \
  1393						  left,				       \
  1394						  right,			       \
  1395						  fmt,				       \
  1396						  ##__VA_ARGS__)
  1397	
  1398	/**
  1399	 * KUNIT_EXPECT_STRNEQ() - Expects that strings @left and @right are not equal.
  1400	 * @test: The test context object.
  1401	 * @left: an arbitrary expression that evaluates to a null terminated string.
  1402	 * @right: an arbitrary expression that evaluates to a null terminated string.
  1403	 *
  1404	 * Sets an expectation that the values that @left and @right evaluate to are
  1405	 * not equal. This is semantically equivalent to
  1406	 * KUNIT_EXPECT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
  1407	 * for more information.
  1408	 */
  1409	#define KUNIT_EXPECT_STRNEQ(test, left, right) \
  1410		KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
  1411	
  1412	#define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...)		       \
  1413		KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,				       \
  1414						  KUNIT_EXPECTATION,		       \
  1415						  left,				       \
  1416						  right,			       \
  1417						  fmt,				       \
  1418						  ##__VA_ARGS__)
  1419	
  1420	/**
  1421	 * KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err.
  1422	 * @test: The test context object.
  1423	 * @ptr: an arbitrary pointer.
  1424	 *
  1425	 * Sets an expectation that the value that @ptr evaluates to is not null and not
  1426	 * an errno stored in a pointer. This is semantically equivalent to
  1427	 * KUNIT_EXPECT_TRUE(@test, !IS_ERR_OR_NULL(@ptr)). See KUNIT_EXPECT_TRUE() for
  1428	 * more information.
  1429	 */
  1430	#define KUNIT_EXPECT_NOT_ERR_OR_NULL(test, ptr) \
  1431		KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, KUNIT_EXPECTATION, ptr)
  1432	
  1433	#define KUNIT_EXPECT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...)		       \
  1434		KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,			       \
  1435							KUNIT_EXPECTATION,	       \
  1436							ptr,			       \
  1437							fmt,			       \
  1438							##__VA_ARGS__)
  1439	
  1440	#define KUNIT_ASSERT_FAILURE(test, fmt, ...) \
  1441		KUNIT_FAIL_ASSERTION(test, KUNIT_ASSERTION, fmt, ##__VA_ARGS__)
  1442	
  1443	/**
  1444	 * KUNIT_ASSERT_TRUE() - Sets an assertion that @condition is true.
  1445	 * @test: The test context object.
  1446	 * @condition: an arbitrary boolean expression. The test fails and aborts when
  1447	 * this does not evaluate to true.
  1448	 *
  1449	 * This and assertions of the form `KUNIT_ASSERT_*` will cause the test case to
  1450	 * fail *and immediately abort* when the specified condition is not met. Unlike
  1451	 * an expectation failure, it will prevent the test case from continuing to run;
  1452	 * this is otherwise known as an *assertion failure*.
  1453	 */
  1454	#define KUNIT_ASSERT_TRUE(test, condition) \
  1455		KUNIT_TRUE_ASSERTION(test, KUNIT_ASSERTION, condition)
  1456	
  1457	#define KUNIT_ASSERT_TRUE_MSG(test, condition, fmt, ...)		       \
  1458		KUNIT_TRUE_MSG_ASSERTION(test,					       \
  1459					 KUNIT_ASSERTION,			       \
  1460					 condition,				       \
  1461					 fmt,					       \
  1462					 ##__VA_ARGS__)
  1463	
  1464	/**
  1465	 * KUNIT_ASSERT_FALSE() - Sets an assertion that @condition is false.
  1466	 * @test: The test context object.
  1467	 * @condition: an arbitrary boolean expression.
  1468	 *
  1469	 * Sets an assertion that the value that @condition evaluates to is false. This
  1470	 * is the same as KUNIT_EXPECT_FALSE(), except it causes an assertion failure
  1471	 * (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1472	 */
  1473	#define KUNIT_ASSERT_FALSE(test, condition) \
  1474		KUNIT_FALSE_ASSERTION(test, KUNIT_ASSERTION, condition)
  1475	
  1476	#define KUNIT_ASSERT_FALSE_MSG(test, condition, fmt, ...)		       \
  1477		KUNIT_FALSE_MSG_ASSERTION(test,					       \
  1478					  KUNIT_ASSERTION,			       \
  1479					  condition,				       \
  1480					  fmt,					       \
  1481					  ##__VA_ARGS__)
  1482	
  1483	/**
  1484	 * KUNIT_ASSERT_EQ() - Sets an assertion that @left and @right are equal.
  1485	 * @test: The test context object.
  1486	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1487	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1488	 *
  1489	 * Sets an assertion that the values that @left and @right evaluate to are
  1490	 * equal. This is the same as KUNIT_EXPECT_EQ(), except it causes an assertion
  1491	 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1492	 */
  1493	#define KUNIT_ASSERT_EQ(test, left, right) \
  1494		KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1495	
  1496	#define KUNIT_ASSERT_EQ_MSG(test, left, right, fmt, ...)		       \
  1497		KUNIT_BINARY_EQ_MSG_ASSERTION(test,				       \
  1498					      KUNIT_ASSERTION,			       \
  1499					      left,				       \
  1500					      right,				       \
  1501					      fmt,				       \
  1502					      ##__VA_ARGS__)
  1503	
  1504	/**
  1505	 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
  1506	 * @test: The test context object.
  1507	 * @left: an arbitrary expression that evaluates to a pointer.
  1508	 * @right: an arbitrary expression that evaluates to a pointer.
  1509	 *
  1510	 * Sets an assertion that the values that @left and @right evaluate to are
  1511	 * equal. This is the same as KUNIT_EXPECT_EQ(), except it causes an assertion
  1512	 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1513	 */
  1514	#define KUNIT_ASSERT_PTR_EQ(test, left, right) \
  1515		KUNIT_BINARY_PTR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1516	
  1517	#define KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, fmt, ...)		       \
  1518		KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test,				       \
  1519						  KUNIT_ASSERTION,		       \
  1520						  left,				       \
  1521						  right,			       \
  1522						  fmt,				       \
  1523						  ##__VA_ARGS__)
  1524	
  1525	/**
  1526	 * KUNIT_ASSERT_NE() - An assertion that @left and @right are not equal.
  1527	 * @test: The test context object.
  1528	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1529	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1530	 *
  1531	 * Sets an assertion that the values that @left and @right evaluate to are not
  1532	 * equal. This is the same as KUNIT_EXPECT_NE(), except it causes an assertion
  1533	 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1534	 */
  1535	#define KUNIT_ASSERT_NE(test, left, right) \
  1536		KUNIT_BINARY_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1537	
  1538	#define KUNIT_ASSERT_NE_MSG(test, left, right, fmt, ...)		       \
  1539		KUNIT_BINARY_NE_MSG_ASSERTION(test,				       \
  1540					      KUNIT_ASSERTION,			       \
  1541					      left,				       \
  1542					      right,				       \
  1543					      fmt,				       \
  1544					      ##__VA_ARGS__)
  1545	
  1546	/**
  1547	 * KUNIT_ASSERT_PTR_NE() - Asserts that pointers @left and @right are not equal.
  1548	 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
  1549	 * @test: The test context object.
  1550	 * @left: an arbitrary expression that evaluates to a pointer.
  1551	 * @right: an arbitrary expression that evaluates to a pointer.
  1552	 *
  1553	 * Sets an assertion that the values that @left and @right evaluate to are not
  1554	 * equal. This is the same as KUNIT_EXPECT_NE(), except it causes an assertion
  1555	 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1556	 */
  1557	#define KUNIT_ASSERT_PTR_NE(test, left, right) \
  1558		KUNIT_BINARY_PTR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1559	
  1560	#define KUNIT_ASSERT_PTR_NE_MSG(test, left, right, fmt, ...)		       \
  1561		KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test,				       \
  1562						  KUNIT_ASSERTION,		       \
  1563						  left,				       \
  1564						  right,			       \
  1565						  fmt,				       \
  1566						  ##__VA_ARGS__)
  1567	/**
  1568	 * KUNIT_ASSERT_LT() - An assertion that @left is less than @right.
  1569	 * @test: The test context object.
  1570	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1571	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1572	 *
  1573	 * Sets an assertion that the value that @left evaluates to is less than the
  1574	 * value that @right evaluates to. This is the same as KUNIT_EXPECT_LT(), except
  1575	 * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
  1576	 * is not met.
  1577	 */
  1578	#define KUNIT_ASSERT_LT(test, left, right) \
  1579		KUNIT_BINARY_LT_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1580	
  1581	#define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...)		       \
  1582		KUNIT_BINARY_LT_MSG_ASSERTION(test,				       \
  1583					      KUNIT_ASSERTION,			       \
  1584					      left,				       \
  1585					      right,				       \
  1586					      fmt,				       \
  1587					      ##__VA_ARGS__)
  1588	/**
  1589	 * KUNIT_ASSERT_LE() - An assertion that @left is less than or equal to @right.
  1590	 * @test: The test context object.
  1591	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1592	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1593	 *
  1594	 * Sets an assertion that the value that @left evaluates to is less than or
  1595	 * equal to the value that @right evaluates to. This is the same as
  1596	 * KUNIT_EXPECT_LE(), except it causes an assertion failure (see
  1597	 * KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1598	 */
  1599	#define KUNIT_ASSERT_LE(test, left, right) \
  1600		KUNIT_BINARY_LE_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1601	
  1602	#define KUNIT_ASSERT_LE_MSG(test, left, right, fmt, ...)		       \
  1603		KUNIT_BINARY_LE_MSG_ASSERTION(test,				       \
  1604					      KUNIT_ASSERTION,			       \
  1605					      left,				       \
  1606					      right,				       \
  1607					      fmt,				       \
  1608					      ##__VA_ARGS__)
  1609	
  1610	/**
  1611	 * KUNIT_ASSERT_GT() - An assertion that @left is greater than @right.
  1612	 * @test: The test context object.
  1613	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1614	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1615	 *
  1616	 * Sets an assertion that the value that @left evaluates to is greater than the
  1617	 * value that @right evaluates to. This is the same as KUNIT_EXPECT_GT(), except
  1618	 * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
  1619	 * is not met.
  1620	 */
  1621	#define KUNIT_ASSERT_GT(test, left, right) \
  1622		KUNIT_BINARY_GT_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1623	
  1624	#define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...)		       \
  1625		KUNIT_BINARY_GT_MSG_ASSERTION(test,				       \
  1626					      KUNIT_ASSERTION,			       \
  1627					      left,				       \
  1628					      right,				       \
  1629					      fmt,				       \
  1630					      ##__VA_ARGS__)
  1631	
  1632	/**
  1633	 * KUNIT_ASSERT_GE() - Assertion that @left is greater than or equal to @right.
  1634	 * @test: The test context object.
  1635	 * @left: an arbitrary expression that evaluates to a primitive C type.
  1636	 * @right: an arbitrary expression that evaluates to a primitive C type.
  1637	 *
  1638	 * Sets an assertion that the value that @left evaluates to is greater than the
  1639	 * value that @right evaluates to. This is the same as KUNIT_EXPECT_GE(), except
  1640	 * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
  1641	 * is not met.
  1642	 */
  1643	#define KUNIT_ASSERT_GE(test, left, right) \
  1644		KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1645	
  1646	#define KUNIT_ASSERT_GE_MSG(test, left, right, fmt, ...)		       \
  1647		KUNIT_BINARY_GE_MSG_ASSERTION(test,				       \
  1648					      KUNIT_ASSERTION,			       \
  1649					      left,				       \
  1650					      right,				       \
  1651					      fmt,				       \
  1652					      ##__VA_ARGS__)
  1653	
  1654	/**
  1655	 * KUNIT_ASSERT_STREQ() - An assertion that strings @left and @right are equal.
  1656	 * @test: The test context object.
  1657	 * @left: an arbitrary expression that evaluates to a null terminated string.
  1658	 * @right: an arbitrary expression that evaluates to a null terminated string.
  1659	 *
  1660	 * Sets an assertion that the values that @left and @right evaluate to are
  1661	 * equal. This is the same as KUNIT_EXPECT_STREQ(), except it causes an
  1662	 * assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1663	 */
  1664	#define KUNIT_ASSERT_STREQ(test, left, right) \
  1665		KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1666	
  1667	#define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...)		       \
  1668		KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,				       \
  1669						  KUNIT_ASSERTION,		       \
  1670						  left,				       \
  1671						  right,			       \
  1672						  fmt,				       \
  1673						  ##__VA_ARGS__)
  1674	
  1675	/**
  1676	 * KUNIT_ASSERT_STRNEQ() - Expects that strings @left and @right are not equal.
  1677	 * @test: The test context object.
  1678	 * @left: an arbitrary expression that evaluates to a null terminated string.
  1679	 * @right: an arbitrary expression that evaluates to a null terminated string.
  1680	 *
  1681	 * Sets an expectation that the values that @left and @right evaluate to are
  1682	 * not equal. This is semantically equivalent to
  1683	 * KUNIT_ASSERT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_ASSERT_TRUE()
  1684	 * for more information.
  1685	 */
  1686	#define KUNIT_ASSERT_STRNEQ(test, left, right) \
  1687		KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
  1688	
  1689	#define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...)		       \
  1690		KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,				       \
  1691						  KUNIT_ASSERTION,		       \
  1692						  left,				       \
  1693						  right,			       \
  1694						  fmt,				       \
  1695						  ##__VA_ARGS__)
  1696	
  1697	/**
  1698	 * KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err.
  1699	 * @test: The test context object.
  1700	 * @ptr: an arbitrary pointer.
  1701	 *
  1702	 * Sets an assertion that the value that @ptr evaluates to is not null and not
  1703	 * an errno stored in a pointer. This is the same as
  1704	 * KUNIT_EXPECT_NOT_ERR_OR_NULL(), except it causes an assertion failure (see
  1705	 * KUNIT_ASSERT_TRUE()) when the assertion is not met.
  1706	 */
  1707	#define KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr) \
  1708		KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, KUNIT_ASSERTION, ptr)
  1709	
  1710	#define KUNIT_ASSERT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...)		       \
  1711		KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,			       \
  1712							KUNIT_ASSERTION,	       \
  1713							ptr,			       \
  1714							fmt,			       \
  1715							##__VA_ARGS__)
  1716	
  1717	/**
  1718	 * kunit_param_generator_helper() - Helper method for test parameter generators
  1719	 * 				    required in parameterized tests.
  1720	 * @test: The test context object.
  1721	 * @prev_param: a pointer to the previous test parameter, NULL for first parameter.
  1722	 * @param_array: a user-supplied pointer to an array of test parameters.
  1723	 * @array_size: number of test parameters in the array.
  1724	 * @type_size: size of one test parameter.
  1725	 */
  1726	static inline void *kunit_param_generator_helper(struct kunit *test,
  1727						void *prev_param,
  1728						void *param_array,
  1729						size_t array_size,
  1730						size_t type_size)
  1731	{
> 1732		KUNIT_ASSERT_EQ(test, (prev_param - param_array) % type_size, 0);
  1733	
  1734		if (!prev_param)
  1735			return param_array;
  1736	
> 1737		KUNIT_ASSERT_GE(test, prev_param, param_array);
  1738	
  1739		if (prev_param + type_size < param_array + (array_size * type_size))
  1740			return prev_param + type_size;
  1741		else
  1742			return NULL;
  1743	}
  1744	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34761 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] kunit: Support for Parameterized Testing
  2020-10-23 15:05 [PATCH v2 1/2] kunit: Support for Parameterized Testing Arpitha Raghunandan
                   ` (2 preceding siblings ...)
  2020-10-23 18:14 ` kernel test robot
@ 2020-10-23 18:48 ` Marco Elver
  2020-10-23 18:56   ` Marco Elver
  2020-10-24  5:23   ` Arpitha Raghunandan
  3 siblings, 2 replies; 10+ messages in thread
From: Marco Elver @ 2020-10-23 18:48 UTC (permalink / raw)
  To: Arpitha Raghunandan
  Cc: brendanhiggins, skhan, yzaikin, tytso, adilger.kernel,
	linux-kselftest, kunit-dev, linux-kernel, linux-kernel-mentees,
	linux-ext4

On Fri, Oct 23, 2020 at 08:35PM +0530, Arpitha Raghunandan wrote:
> Implementation of support for parameterized testing in KUnit.

Already looks much cleaner, thanks for using this approach!

I think the commit message needs a brief summary of the approach.

> Signed-off-by: Arpitha Raghunandan <98.arpi@gmail.com>
> ---
> Changes v1->v2:
> - Use of a generator method to access test case parameters
> 
>  include/kunit/test.h | 45 ++++++++++++++++++++++++++++++++++++++++++++
>  lib/kunit/test.c     | 20 +++++++++++++++++++-
>  2 files changed, 64 insertions(+), 1 deletion(-)
> 
> diff --git a/include/kunit/test.h b/include/kunit/test.h
> index a423fffefea0..c417ac140326 100644
> --- a/include/kunit/test.h
> +++ b/include/kunit/test.h
> @@ -141,6 +141,7 @@ struct kunit;
>  struct kunit_case {
>  	void (*run_case)(struct kunit *test);
>  	const char *name;
> +	void* (*generate_params)(struct kunit *test, void *prev);

Would adding documentation above this field be the right place, or
somewhere else? In any case, some explanation of the protocol would be
good.

>  	/* private: internal use only. */
>  	bool success;
> @@ -162,6 +163,9 @@ static inline char *kunit_status_to_string(bool status)
>   * &struct kunit_case for an example on how to use it.
>   */
>  #define KUNIT_CASE(test_name) { .run_case = test_name, .name = #test_name }
> +#define KUNIT_CASE_PARAM(test_name, gen_params)			\
> +		{ .run_case = test_name, .name = #test_name,	\
> +		  .generate_params = gen_params }
>  
>  /**
>   * struct kunit_suite - describes a related collection of &struct kunit_case
> @@ -208,6 +212,15 @@ struct kunit {
>  	const char *name; /* Read only after initialization! */
>  	char *log; /* Points at case log after initialization */
>  	struct kunit_try_catch try_catch;
> +	/* param_values points to test case parameters in parameterized tests */
> +	void *param_values;
> +	/*
> +	 * current_param stores the index of the parameter in
> +	 * the array of parameters in parameterized tests.
> +	 * current_param + 1 is printed to indicate the parameter
> +	 * that causes the test to fail in case of test failure.
> +	 */
> +	int current_param;
>  	/*
>  	 * success starts as true, and may only be set to false during a
>  	 * test case; thus, it is safe to update this across multiple
> @@ -1742,4 +1755,36 @@ do {									       \
>  						fmt,			       \
>  						##__VA_ARGS__)
>  
> +/**
> + * kunit_param_generator_helper() - Helper method for test parameter generators
> + * 				    required in parameterized tests.
> + * @test: The test context object.
> + * @prev_param: a pointer to the previous test parameter, NULL for first parameter.
> + * @param_array: a user-supplied pointer to an array of test parameters.
> + * @array_size: number of test parameters in the array.
> + * @type_size: size of one test parameter.
> + */
> +static inline void *kunit_param_generator_helper(struct kunit *test,

I don't think this needs to be inline, but see my other suggestion
below, which might make this function obsolete.

> +					void *prev_param,
> +					void *param_array,
> +					size_t array_size,
> +					size_t type_size)
> +{
> +	KUNIT_ASSERT_EQ(test, (prev_param - param_array) % type_size, 0);
> +
> +	if (!prev_param)
> +		return param_array;
> +
> +	KUNIT_ASSERT_GE(test, prev_param, param_array);
> +
> +	if (prev_param + type_size < param_array + (array_size * type_size))
> +		return prev_param + type_size;
> +	else
> +		return NULL;
> +}
> +
> +#define KUNIT_PARAM_GENERATOR_HELPER(test, prev_param, param_array, param_type) \
> +	kunit_param_generator_helper(test, prev_param, param_array,		\
> +				ARRAY_SIZE(param_array), sizeof(param_type))

You do not need param_type, you can use the same trick that ARRAY_SIZE
uses:

	#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))

So you could use sizeof((param_aray)[0]) instead of sizeof(param_type).
ARRAY_SIZE already checks for you that it's a real array via
__must_be_array().


The other question is, will kunit_param_generator_helper() find much use
without the KUNIT_PARAM_GENERATOR_HELPER() macro? If I have some
complicated generator protocol to generate params, then I'd just
directly write the generator function. If your intent is to simplify the
common-case array based generators, why not just have a macro generate
the generator function?

More specifically, have this macro here:

+#define KUNIT_ARRAY_PARAM(name, array)								\
+	static void *name##_gen_params(struct kunit *test, void *prev)				\
+	{											\
+		typeof((array)[0]) *__next = prev ? ((typeof(__next)) prev) + 1 : (array);	\
+		return __next - (array) < ARRAY_SIZE((array)) ? __next : NULL;			\
+	}

[ It is entirely untested, but if it works verbatim you'll probably need my

	Co-developed-by: Marco Elver <elver@google.com>
	Signed-off-by: Marco Elver <elver@google.com>
 
 just in case... ]

Then, it can be used as follows:

	static int num_cpus[] = {1, 2, 3, 4, 5};
	KUNIT_ARRAY_PARAM(num_cpus, num_cpus);

Then somewhere else:

	KUNIT_CASE_PARAM(some_test, num_cpus_gen_params);

>  #endif /* _KUNIT_TEST_H */
> diff --git a/lib/kunit/test.c b/lib/kunit/test.c
> index 750704abe89a..0e6ffe6384a7 100644
> --- a/lib/kunit/test.c
> +++ b/lib/kunit/test.c
> @@ -127,6 +127,11 @@ unsigned int kunit_test_case_num(struct kunit_suite *suite,
>  }
>  EXPORT_SYMBOL_GPL(kunit_test_case_num);
>  
> +static void kunit_print_failed_param(struct kunit *test)
> +{
> +	kunit_err(test, "\n\tTest failed at parameter: %d\n", test->current_param + 1);
> +}
> +
>  static void kunit_print_string_stream(struct kunit *test,
>  				      struct string_stream *stream)
>  {
> @@ -168,6 +173,8 @@ static void kunit_fail(struct kunit *test, struct kunit_assert *assert)
>  	assert->format(assert, stream);
>  
>  	kunit_print_string_stream(test, stream);
> +	if (test->param_values)
> +		kunit_print_failed_param(test);
>  
>  	WARN_ON(string_stream_destroy(stream));
>  }
> @@ -239,7 +246,18 @@ static void kunit_run_case_internal(struct kunit *test,
>  		}
>  	}
>  
> -	test_case->run_case(test);
> +	if (!test_case->generate_params) {
> +		test_case->run_case(test);
> +	} else {
> +		test->param_values = test_case->generate_params(test, NULL);
> +		test->current_param = 0;
> +
> +		while (test->param_values) {
> +			test_case->run_case(test);
> +			test->param_values = test_case->generate_params(test, test->param_values);
> +			test->current_param++;
> +		}
> +	}
>  }
>  
>  static void kunit_case_internal_cleanup(struct kunit *test)

Otherwise looks fine.

Thanks,
-- Marco

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] kunit: Support for Parameterized Testing
  2020-10-23 18:48 ` Marco Elver
@ 2020-10-23 18:56   ` Marco Elver
  2020-10-24  5:23   ` Arpitha Raghunandan
  1 sibling, 0 replies; 10+ messages in thread
From: Marco Elver @ 2020-10-23 18:56 UTC (permalink / raw)
  To: Arpitha Raghunandan
  Cc: Brendan Higgins, skhan, Iurii Zaikin, Theodore Ts'o,
	Andreas Dilger, open list:KERNEL SELFTEST FRAMEWORK,
	KUnit Development, LKML, linux-kernel-mentees, linux-ext4

On Fri, 23 Oct 2020 at 20:48, Marco Elver <elver@google.com> wrote:
[...]
> > + */
> > +static inline void *kunit_param_generator_helper(struct kunit *test,
>
> I don't think this needs to be inline, but see my other suggestion
> below, which might make this function obsolete.

Ah sorry, it's in a header so we might get complaints if it's not
inline. But in any case, if you use the KUNIT_ARRAY_PARAM() macro I
proposed, this function will become obsolete.

Thanks,
-- Marco

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] kunit: Support for Parameterized Testing
  2020-10-23 18:48 ` Marco Elver
  2020-10-23 18:56   ` Marco Elver
@ 2020-10-24  5:23   ` Arpitha Raghunandan
  1 sibling, 0 replies; 10+ messages in thread
From: Arpitha Raghunandan @ 2020-10-24  5:23 UTC (permalink / raw)
  To: Marco Elver
  Cc: brendanhiggins, skhan, yzaikin, tytso, adilger.kernel,
	linux-kselftest, kunit-dev, linux-kernel, linux-kernel-mentees,
	linux-ext4

On 24/10/20 12:18 am, Marco Elver wrote:
> On Fri, Oct 23, 2020 at 08:35PM +0530, Arpitha Raghunandan wrote:
>> Implementation of support for parameterized testing in KUnit.
> 
> Already looks much cleaner, thanks for using this approach!
> 
> I think the commit message needs a brief summary of the approach.
> 

Okay, I will add a more detailed commit message for the next version.

>> Signed-off-by: Arpitha Raghunandan <98.arpi@gmail.com>
>> ---
>> Changes v1->v2:
>> - Use of a generator method to access test case parameters
>>
>>  include/kunit/test.h | 45 ++++++++++++++++++++++++++++++++++++++++++++
>>  lib/kunit/test.c     | 20 +++++++++++++++++++-
>>  2 files changed, 64 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/kunit/test.h b/include/kunit/test.h
>> index a423fffefea0..c417ac140326 100644
>> --- a/include/kunit/test.h
>> +++ b/include/kunit/test.h
>> @@ -141,6 +141,7 @@ struct kunit;
>>  struct kunit_case {
>>  	void (*run_case)(struct kunit *test);
>>  	const char *name;
>> +	void* (*generate_params)(struct kunit *test, void *prev);
> 
> Would adding documentation above this field be the right place, or
> somewhere else? In any case, some explanation of the protocol would be
> good.
> 

I will include this.

>>  	/* private: internal use only. */
>>  	bool success;
>> @@ -162,6 +163,9 @@ static inline char *kunit_status_to_string(bool status)
>>   * &struct kunit_case for an example on how to use it.
>>   */
>>  #define KUNIT_CASE(test_name) { .run_case = test_name, .name = #test_name }
>> +#define KUNIT_CASE_PARAM(test_name, gen_params)			\
>> +		{ .run_case = test_name, .name = #test_name,	\
>> +		  .generate_params = gen_params }
>>  
>>  /**
>>   * struct kunit_suite - describes a related collection of &struct kunit_case
>> @@ -208,6 +212,15 @@ struct kunit {
>>  	const char *name; /* Read only after initialization! */
>>  	char *log; /* Points at case log after initialization */
>>  	struct kunit_try_catch try_catch;
>> +	/* param_values points to test case parameters in parameterized tests */
>> +	void *param_values;
>> +	/*
>> +	 * current_param stores the index of the parameter in
>> +	 * the array of parameters in parameterized tests.
>> +	 * current_param + 1 is printed to indicate the parameter
>> +	 * that causes the test to fail in case of test failure.
>> +	 */
>> +	int current_param;
>>  	/*
>>  	 * success starts as true, and may only be set to false during a
>>  	 * test case; thus, it is safe to update this across multiple
>> @@ -1742,4 +1755,36 @@ do {									       \
>>  						fmt,			       \
>>  						##__VA_ARGS__)
>>  
>> +/**
>> + * kunit_param_generator_helper() - Helper method for test parameter generators
>> + * 				    required in parameterized tests.
>> + * @test: The test context object.
>> + * @prev_param: a pointer to the previous test parameter, NULL for first parameter.
>> + * @param_array: a user-supplied pointer to an array of test parameters.
>> + * @array_size: number of test parameters in the array.
>> + * @type_size: size of one test parameter.
>> + */
>> +static inline void *kunit_param_generator_helper(struct kunit *test,
> 
> I don't think this needs to be inline, but see my other suggestion
> below, which might make this function obsolete.
> 
>> +					void *prev_param,
>> +					void *param_array,
>> +					size_t array_size,
>> +					size_t type_size)
>> +{
>> +	KUNIT_ASSERT_EQ(test, (prev_param - param_array) % type_size, 0);
>> +
>> +	if (!prev_param)
>> +		return param_array;
>> +
>> +	KUNIT_ASSERT_GE(test, prev_param, param_array);
>> +
>> +	if (prev_param + type_size < param_array + (array_size * type_size))
>> +		return prev_param + type_size;
>> +	else
>> +		return NULL;
>> +}
>> +
>> +#define KUNIT_PARAM_GENERATOR_HELPER(test, prev_param, param_array, param_type) \
>> +	kunit_param_generator_helper(test, prev_param, param_array,		\
>> +				ARRAY_SIZE(param_array), sizeof(param_type))
> 
> You do not need param_type, you can use the same trick that ARRAY_SIZE
> uses:
> 
> 	#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
> 
> So you could use sizeof((param_aray)[0]) instead of sizeof(param_type).
> ARRAY_SIZE already checks for you that it's a real array via
> __must_be_array().
> 
> 
> The other question is, will kunit_param_generator_helper() find much use
> without the KUNIT_PARAM_GENERATOR_HELPER() macro? If I have some
> complicated generator protocol to generate params, then I'd just
> directly write the generator function. If your intent is to simplify the
> common-case array based generators, why not just have a macro generate
> the generator function?
> 
> More specifically, have this macro here:
> 
> +#define KUNIT_ARRAY_PARAM(name, array)								\
> +	static void *name##_gen_params(struct kunit *test, void *prev)				\
> +	{											\
> +		typeof((array)[0]) *__next = prev ? ((typeof(__next)) prev) + 1 : (array);	\
> +		return __next - (array) < ARRAY_SIZE((array)) ? __next : NULL;			\
> +	}
> 
> [ It is entirely untested, but if it works verbatim you'll probably need my
> 
> 	Co-developed-by: Marco Elver <elver@google.com>
> 	Signed-off-by: Marco Elver <elver@google.com>
>  
>  just in case... ]
> 
> Then, it can be used as follows:
> 
> 	static int num_cpus[] = {1, 2, 3, 4, 5};
> 	KUNIT_ARRAY_PARAM(num_cpus, num_cpus);
> 
> Then somewhere else:
> 
> 	KUNIT_CASE_PARAM(some_test, num_cpus_gen_params);
> 

Yes, a macro can be used to generate the generator function. I will work with this
for the next version.

>>  #endif /* _KUNIT_TEST_H */
>> diff --git a/lib/kunit/test.c b/lib/kunit/test.c
>> index 750704abe89a..0e6ffe6384a7 100644
>> --- a/lib/kunit/test.c
>> +++ b/lib/kunit/test.c
>> @@ -127,6 +127,11 @@ unsigned int kunit_test_case_num(struct kunit_suite *suite,
>>  }
>>  EXPORT_SYMBOL_GPL(kunit_test_case_num);
>>  
>> +static void kunit_print_failed_param(struct kunit *test)
>> +{
>> +	kunit_err(test, "\n\tTest failed at parameter: %d\n", test->current_param + 1);
>> +}
>> +
>>  static void kunit_print_string_stream(struct kunit *test,
>>  				      struct string_stream *stream)
>>  {
>> @@ -168,6 +173,8 @@ static void kunit_fail(struct kunit *test, struct kunit_assert *assert)
>>  	assert->format(assert, stream);
>>  
>>  	kunit_print_string_stream(test, stream);
>> +	if (test->param_values)
>> +		kunit_print_failed_param(test);
>>  
>>  	WARN_ON(string_stream_destroy(stream));
>>  }
>> @@ -239,7 +246,18 @@ static void kunit_run_case_internal(struct kunit *test,
>>  		}
>>  	}
>>  
>> -	test_case->run_case(test);
>> +	if (!test_case->generate_params) {
>> +		test_case->run_case(test);
>> +	} else {
>> +		test->param_values = test_case->generate_params(test, NULL);
>> +		test->current_param = 0;
>> +
>> +		while (test->param_values) {
>> +			test_case->run_case(test);
>> +			test->param_values = test_case->generate_params(test, test->param_values);
>> +			test->current_param++;
>> +		}
>> +	}
>>  }
>>  
>>  static void kunit_case_internal_cleanup(struct kunit *test)
> 
> Otherwise looks fine.
> 
> Thanks,
> -- Marco
> 

Thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature
  2020-10-23 15:06 ` [PATCH v2 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature Arpitha Raghunandan
  2020-10-23 17:33   ` kernel test robot
@ 2020-10-26 18:11   ` Iurii Zaikin
  2020-10-26 18:19     ` Arpitha Raghunandan
  1 sibling, 1 reply; 10+ messages in thread
From: Iurii Zaikin @ 2020-10-26 18:11 UTC (permalink / raw)
  To: Arpitha Raghunandan
  Cc: Brendan Higgins, Shuah Khan, Marco Elver, Theodore Ts'o,
	Andreas Dilger, open list:KERNEL SELFTEST FRAMEWORK,
	KUnit Development, Linux Kernel Mailing List,
	linux-kernel-mentees, Ext4 Developers List

> +static struct timestamp_expectation test_data[] = {
Can you mark this and the rest of the hardcoded values as the const they are?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature
  2020-10-26 18:11   ` Iurii Zaikin
@ 2020-10-26 18:19     ` Arpitha Raghunandan
  0 siblings, 0 replies; 10+ messages in thread
From: Arpitha Raghunandan @ 2020-10-26 18:19 UTC (permalink / raw)
  To: Iurii Zaikin
  Cc: Brendan Higgins, Shuah Khan, Marco Elver, Theodore Ts'o,
	Andreas Dilger, open list:KERNEL SELFTEST FRAMEWORK,
	KUnit Development, Linux Kernel Mailing List,
	linux-kernel-mentees, Ext4 Developers List

On 26/10/20 11:41 pm, Iurii Zaikin wrote:
>> +static struct timestamp_expectation test_data[] = {
> Can you mark this and the rest of the hardcoded values as the const they are?
> 

Sure, I will make this change for the next version.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-10-26 18:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23 15:05 [PATCH v2 1/2] kunit: Support for Parameterized Testing Arpitha Raghunandan
2020-10-23 15:06 ` [PATCH v2 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature Arpitha Raghunandan
2020-10-23 17:33   ` kernel test robot
2020-10-26 18:11   ` Iurii Zaikin
2020-10-26 18:19     ` Arpitha Raghunandan
2020-10-23 18:08 ` [PATCH v2 1/2] kunit: Support for Parameterized Testing kernel test robot
2020-10-23 18:14 ` kernel test robot
2020-10-23 18:48 ` Marco Elver
2020-10-23 18:56   ` Marco Elver
2020-10-24  5:23   ` Arpitha Raghunandan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).