kunit: test: create a single centralized executor for all tests
[linux-2.6-microblaze.git] / include / kunit / test.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Base unit test (KUnit) API.
4  *
5  * Copyright (C) 2019, Google LLC.
6  * Author: Brendan Higgins <brendanhiggins@google.com>
7  */
8
9 #ifndef _KUNIT_TEST_H
10 #define _KUNIT_TEST_H
11
12 #include <kunit/assert.h>
13 #include <kunit/try-catch.h>
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/slab.h>
17 #include <linux/types.h>
18 #include <linux/kref.h>
19
20 struct kunit_resource;
21
22 typedef int (*kunit_resource_init_t)(struct kunit_resource *, void *);
23 typedef void (*kunit_resource_free_t)(struct kunit_resource *);
24
25 /**
26  * struct kunit_resource - represents a *test managed resource*
27  * @data: for the user to store arbitrary data.
28  * @free: a user supplied function to free the resource. Populated by
29  * kunit_resource_alloc().
30  *
31  * Represents a *test managed resource*, a resource which will automatically be
32  * cleaned up at the end of a test case.
33  *
34  * Resources are reference counted so if a resource is retrieved via
35  * kunit_alloc_and_get_resource() or kunit_find_resource(), we need
36  * to call kunit_put_resource() to reduce the resource reference count
37  * when finished with it.  Note that kunit_alloc_resource() does not require a
38  * kunit_resource_put() because it does not retrieve the resource itself.
39  *
40  * Example:
41  *
42  * .. code-block:: c
43  *
44  *      struct kunit_kmalloc_params {
45  *              size_t size;
46  *              gfp_t gfp;
47  *      };
48  *
49  *      static int kunit_kmalloc_init(struct kunit_resource *res, void *context)
50  *      {
51  *              struct kunit_kmalloc_params *params = context;
52  *              res->data = kmalloc(params->size, params->gfp);
53  *
54  *              if (!res->data)
55  *                      return -ENOMEM;
56  *
57  *              return 0;
58  *      }
59  *
60  *      static void kunit_kmalloc_free(struct kunit_resource *res)
61  *      {
62  *              kfree(res->data);
63  *      }
64  *
65  *      void *kunit_kmalloc(struct kunit *test, size_t size, gfp_t gfp)
66  *      {
67  *              struct kunit_kmalloc_params params;
68  *
69  *              params.size = size;
70  *              params.gfp = gfp;
71  *
72  *              return kunit_alloc_resource(test, kunit_kmalloc_init,
73  *                      kunit_kmalloc_free, &params);
74  *      }
75  *
76  * Resources can also be named, with lookup/removal done on a name
77  * basis also.  kunit_add_named_resource(), kunit_find_named_resource()
78  * and kunit_destroy_named_resource().  Resource names must be
79  * unique within the test instance.
80  */
81 struct kunit_resource {
82         void *data;
83         const char *name;               /* optional name */
84
85         /* private: internal use only. */
86         kunit_resource_free_t free;
87         struct kref refcount;
88         struct list_head node;
89 };
90
91 struct kunit;
92
93 /* Size of log associated with test. */
94 #define KUNIT_LOG_SIZE  512
95
96 /*
97  * TAP specifies subtest stream indentation of 4 spaces, 8 spaces for a
98  * sub-subtest.  See the "Subtests" section in
99  * https://node-tap.org/tap-protocol/
100  */
101 #define KUNIT_SUBTEST_INDENT            "    "
102 #define KUNIT_SUBSUBTEST_INDENT         "        "
103
104 /**
105  * struct kunit_case - represents an individual test case.
106  *
107  * @run_case: the function representing the actual test case.
108  * @name:     the name of the test case.
109  *
110  * A test case is a function with the signature,
111  * ``void (*)(struct kunit *)``
112  * that makes expectations and assertions (see KUNIT_EXPECT_TRUE() and
113  * KUNIT_ASSERT_TRUE()) about code under test. Each test case is associated
114  * with a &struct kunit_suite and will be run after the suite's init
115  * function and followed by the suite's exit function.
116  *
117  * A test case should be static and should only be created with the
118  * KUNIT_CASE() macro; additionally, every array of test cases should be
119  * terminated with an empty test case.
120  *
121  * Example:
122  *
123  * .. code-block:: c
124  *
125  *      void add_test_basic(struct kunit *test)
126  *      {
127  *              KUNIT_EXPECT_EQ(test, 1, add(1, 0));
128  *              KUNIT_EXPECT_EQ(test, 2, add(1, 1));
129  *              KUNIT_EXPECT_EQ(test, 0, add(-1, 1));
130  *              KUNIT_EXPECT_EQ(test, INT_MAX, add(0, INT_MAX));
131  *              KUNIT_EXPECT_EQ(test, -1, add(INT_MAX, INT_MIN));
132  *      }
133  *
134  *      static struct kunit_case example_test_cases[] = {
135  *              KUNIT_CASE(add_test_basic),
136  *              {}
137  *      };
138  *
139  */
140 struct kunit_case {
141         void (*run_case)(struct kunit *test);
142         const char *name;
143
144         /* private: internal use only. */
145         bool success;
146         char *log;
147 };
148
149 static inline char *kunit_status_to_string(bool status)
150 {
151         return status ? "ok" : "not ok";
152 }
153
154 /**
155  * KUNIT_CASE - A helper for creating a &struct kunit_case
156  *
157  * @test_name: a reference to a test case function.
158  *
159  * Takes a symbol for a function representing a test case and creates a
160  * &struct kunit_case object from it. See the documentation for
161  * &struct kunit_case for an example on how to use it.
162  */
163 #define KUNIT_CASE(test_name) { .run_case = test_name, .name = #test_name }
164
165 /**
166  * struct kunit_suite - describes a related collection of &struct kunit_case
167  *
168  * @name:       the name of the test. Purely informational.
169  * @init:       called before every test case.
170  * @exit:       called after every test case.
171  * @test_cases: a null terminated array of test cases.
172  *
173  * A kunit_suite is a collection of related &struct kunit_case s, such that
174  * @init is called before every test case and @exit is called after every
175  * test case, similar to the notion of a *test fixture* or a *test class*
176  * in other unit testing frameworks like JUnit or Googletest.
177  *
178  * Every &struct kunit_case must be associated with a kunit_suite for KUnit
179  * to run it.
180  */
181 struct kunit_suite {
182         const char name[256];
183         int (*init)(struct kunit *test);
184         void (*exit)(struct kunit *test);
185         struct kunit_case *test_cases;
186
187         /* private: internal use only */
188         struct dentry *debugfs;
189         char *log;
190 };
191
192 /**
193  * struct kunit - represents a running instance of a test.
194  *
195  * @priv: for user to store arbitrary data. Commonly used to pass data
196  *        created in the init function (see &struct kunit_suite).
197  *
198  * Used to store information about the current context under which the test
199  * is running. Most of this data is private and should only be accessed
200  * indirectly via public functions; the one exception is @priv which can be
201  * used by the test writer to store arbitrary data.
202  */
203 struct kunit {
204         void *priv;
205
206         /* private: internal use only. */
207         const char *name; /* Read only after initialization! */
208         char *log; /* Points at case log after initialization */
209         struct kunit_try_catch try_catch;
210         /*
211          * success starts as true, and may only be set to false during a
212          * test case; thus, it is safe to update this across multiple
213          * threads using WRITE_ONCE; however, as a consequence, it may only
214          * be read after the test case finishes once all threads associated
215          * with the test case have terminated.
216          */
217         bool success; /* Read only after test_case finishes! */
218         spinlock_t lock; /* Guards all mutable test state. */
219         /*
220          * Because resources is a list that may be updated multiple times (with
221          * new resources) from any thread associated with a test case, we must
222          * protect it with some type of lock.
223          */
224         struct list_head resources; /* Protected by lock. */
225 };
226
227 void kunit_init_test(struct kunit *test, const char *name, char *log);
228
229 int kunit_run_tests(struct kunit_suite *suite);
230
231 size_t kunit_suite_num_test_cases(struct kunit_suite *suite);
232
233 unsigned int kunit_test_case_num(struct kunit_suite *suite,
234                                  struct kunit_case *test_case);
235
236 int __kunit_test_suites_init(struct kunit_suite * const * const suites);
237
238 void __kunit_test_suites_exit(struct kunit_suite **suites);
239
240 /**
241  * kunit_test_suites() - used to register one or more &struct kunit_suite
242  *                       with KUnit.
243  *
244  * @suites_list...: a statically allocated list of &struct kunit_suite.
245  *
246  * Registers @suites_list with the test framework. See &struct kunit_suite for
247  * more information.
248  *
249  * If a test suite is built-in, module_init() gets translated into
250  * an initcall which we don't want as the idea is that for builtins
251  * the executor will manage execution.  So ensure we do not define
252  * module_{init|exit} functions for the builtin case when registering
253  * suites via kunit_test_suites() below.
254  */
255 #ifdef MODULE
256 #define kunit_test_suites_for_module(__suites)                          \
257         static int __init kunit_test_suites_init(void)                  \
258         {                                                               \
259                 return __kunit_test_suites_init(__suites);              \
260         }                                                               \
261         module_init(kunit_test_suites_init);                            \
262                                                                         \
263         static void __exit kunit_test_suites_exit(void)                 \
264         {                                                               \
265                 return __kunit_test_suites_exit(__suites);              \
266         }                                                               \
267         module_exit(kunit_test_suites_exit)
268 #else
269 #define kunit_test_suites_for_module(__suites)
270 #endif /* MODULE */
271
272 #define __kunit_test_suites(unique_array, unique_suites, ...)                  \
273         static struct kunit_suite *unique_array[] = { __VA_ARGS__, NULL };     \
274         kunit_test_suites_for_module(unique_array);                            \
275         static struct kunit_suite **unique_suites                              \
276         __used __section(.kunit_test_suites) = unique_array
277
278 /**
279  * kunit_test_suites() - used to register one or more &struct kunit_suite
280  *                       with KUnit.
281  *
282  * @suites: a statically allocated list of &struct kunit_suite.
283  *
284  * Registers @suites with the test framework. See &struct kunit_suite for
285  * more information.
286  *
287  * When builtin,  KUnit tests are all run via executor; this is done
288  * by placing the array of struct kunit_suite * in the .kunit_test_suites
289  * ELF section.
290  *
291  * An alternative is to build the tests as a module.  Because modules do not
292  * support multiple initcall()s, we need to initialize an array of suites for a
293  * module.
294  *
295  */
296 #define kunit_test_suites(...)                                          \
297         __kunit_test_suites(__UNIQUE_ID(array),                         \
298                             __UNIQUE_ID(suites),                        \
299                             __VA_ARGS__)
300
301 #define kunit_test_suite(suite) kunit_test_suites(&suite)
302
303 #define kunit_suite_for_each_test_case(suite, test_case)                \
304         for (test_case = suite->test_cases; test_case->run_case; test_case++)
305
306 bool kunit_suite_has_succeeded(struct kunit_suite *suite);
307
308 /*
309  * Like kunit_alloc_resource() below, but returns the struct kunit_resource
310  * object that contains the allocation. This is mostly for testing purposes.
311  */
312 struct kunit_resource *kunit_alloc_and_get_resource(struct kunit *test,
313                                                     kunit_resource_init_t init,
314                                                     kunit_resource_free_t free,
315                                                     gfp_t internal_gfp,
316                                                     void *context);
317
318 /**
319  * kunit_get_resource() - Hold resource for use.  Should not need to be used
320  *                        by most users as we automatically get resources
321  *                        retrieved by kunit_find_resource*().
322  * @res: resource
323  */
324 static inline void kunit_get_resource(struct kunit_resource *res)
325 {
326         kref_get(&res->refcount);
327 }
328
329 /*
330  * Called when refcount reaches zero via kunit_put_resources();
331  * should not be called directly.
332  */
333 static inline void kunit_release_resource(struct kref *kref)
334 {
335         struct kunit_resource *res = container_of(kref, struct kunit_resource,
336                                                   refcount);
337
338         /* If free function is defined, resource was dynamically allocated. */
339         if (res->free) {
340                 res->free(res);
341                 kfree(res);
342         }
343 }
344
345 /**
346  * kunit_put_resource() - When caller is done with retrieved resource,
347  *                        kunit_put_resource() should be called to drop
348  *                        reference count.  The resource list maintains
349  *                        a reference count on resources, so if no users
350  *                        are utilizing a resource and it is removed from
351  *                        the resource list, it will be freed via the
352  *                        associated free function (if any).  Only
353  *                        needs to be used if we alloc_and_get() or
354  *                        find() resource.
355  * @res: resource
356  */
357 static inline void kunit_put_resource(struct kunit_resource *res)
358 {
359         kref_put(&res->refcount, kunit_release_resource);
360 }
361
362 /**
363  * kunit_add_resource() - Add a *test managed resource*.
364  * @test: The test context object.
365  * @init: a user-supplied function to initialize the result (if needed).  If
366  *        none is supplied, the resource data value is simply set to @data.
367  *        If an init function is supplied, @data is passed to it instead.
368  * @free: a user-supplied function to free the resource (if needed).
369  * @data: value to pass to init function or set in resource data field.
370  */
371 int kunit_add_resource(struct kunit *test,
372                        kunit_resource_init_t init,
373                        kunit_resource_free_t free,
374                        struct kunit_resource *res,
375                        void *data);
376
377 /**
378  * kunit_add_named_resource() - Add a named *test managed resource*.
379  * @test: The test context object.
380  * @init: a user-supplied function to initialize the resource data, if needed.
381  * @free: a user-supplied function to free the resource data, if needed.
382  * @name_data: name and data to be set for resource.
383  */
384 int kunit_add_named_resource(struct kunit *test,
385                              kunit_resource_init_t init,
386                              kunit_resource_free_t free,
387                              struct kunit_resource *res,
388                              const char *name,
389                              void *data);
390
391 /**
392  * kunit_alloc_resource() - Allocates a *test managed resource*.
393  * @test: The test context object.
394  * @init: a user supplied function to initialize the resource.
395  * @free: a user supplied function to free the resource.
396  * @internal_gfp: gfp to use for internal allocations, if unsure, use GFP_KERNEL
397  * @context: for the user to pass in arbitrary data to the init function.
398  *
399  * Allocates a *test managed resource*, a resource which will automatically be
400  * cleaned up at the end of a test case. See &struct kunit_resource for an
401  * example.
402  *
403  * Note: KUnit needs to allocate memory for a kunit_resource object. You must
404  * specify an @internal_gfp that is compatible with the use context of your
405  * resource.
406  */
407 static inline void *kunit_alloc_resource(struct kunit *test,
408                                          kunit_resource_init_t init,
409                                          kunit_resource_free_t free,
410                                          gfp_t internal_gfp,
411                                          void *context)
412 {
413         struct kunit_resource *res;
414
415         res = kzalloc(sizeof(*res), internal_gfp);
416         if (!res)
417                 return NULL;
418
419         if (!kunit_add_resource(test, init, free, res, context))
420                 return res->data;
421
422         return NULL;
423 }
424
425 typedef bool (*kunit_resource_match_t)(struct kunit *test,
426                                        struct kunit_resource *res,
427                                        void *match_data);
428
429 /**
430  * kunit_resource_instance_match() - Match a resource with the same instance.
431  * @test: Test case to which the resource belongs.
432  * @res: The resource.
433  * @match_data: The resource pointer to match against.
434  *
435  * An instance of kunit_resource_match_t that matches a resource whose
436  * allocation matches @match_data.
437  */
438 static inline bool kunit_resource_instance_match(struct kunit *test,
439                                                  struct kunit_resource *res,
440                                                  void *match_data)
441 {
442         return res->data == match_data;
443 }
444
445 /**
446  * kunit_resource_name_match() - Match a resource with the same name.
447  * @test: Test case to which the resource belongs.
448  * @res: The resource.
449  * @match_name: The name to match against.
450  */
451 static inline bool kunit_resource_name_match(struct kunit *test,
452                                              struct kunit_resource *res,
453                                              void *match_name)
454 {
455         return res->name && strcmp(res->name, match_name) == 0;
456 }
457
458 /**
459  * kunit_find_resource() - Find a resource using match function/data.
460  * @test: Test case to which the resource belongs.
461  * @match: match function to be applied to resources/match data.
462  * @match_data: data to be used in matching.
463  */
464 static inline struct kunit_resource *
465 kunit_find_resource(struct kunit *test,
466                     kunit_resource_match_t match,
467                     void *match_data)
468 {
469         struct kunit_resource *res, *found = NULL;
470
471         spin_lock(&test->lock);
472
473         list_for_each_entry_reverse(res, &test->resources, node) {
474                 if (match(test, res, (void *)match_data)) {
475                         found = res;
476                         kunit_get_resource(found);
477                         break;
478                 }
479         }
480
481         spin_unlock(&test->lock);
482
483         return found;
484 }
485
486 /**
487  * kunit_find_named_resource() - Find a resource using match name.
488  * @test: Test case to which the resource belongs.
489  * @name: match name.
490  */
491 static inline struct kunit_resource *
492 kunit_find_named_resource(struct kunit *test,
493                           const char *name)
494 {
495         return kunit_find_resource(test, kunit_resource_name_match,
496                                    (void *)name);
497 }
498
499 /**
500  * kunit_destroy_resource() - Find a kunit_resource and destroy it.
501  * @test: Test case to which the resource belongs.
502  * @match: Match function. Returns whether a given resource matches @match_data.
503  * @match_data: Data passed into @match.
504  *
505  * RETURNS:
506  * 0 if kunit_resource is found and freed, -ENOENT if not found.
507  */
508 int kunit_destroy_resource(struct kunit *test,
509                            kunit_resource_match_t match,
510                            void *match_data);
511
512 static inline int kunit_destroy_named_resource(struct kunit *test,
513                                                const char *name)
514 {
515         return kunit_destroy_resource(test, kunit_resource_name_match,
516                                       (void *)name);
517 }
518
519 /**
520  * kunit_remove_resource: remove resource from resource list associated with
521  *                        test.
522  * @test: The test context object.
523  * @res: The resource to be removed.
524  *
525  * Note that the resource will not be immediately freed since it is likely
526  * the caller has a reference to it via alloc_and_get() or find();
527  * in this case a final call to kunit_put_resource() is required.
528  */
529 void kunit_remove_resource(struct kunit *test, struct kunit_resource *res);
530
531 /**
532  * kunit_kmalloc() - Like kmalloc() except the allocation is *test managed*.
533  * @test: The test context object.
534  * @size: The size in bytes of the desired memory.
535  * @gfp: flags passed to underlying kmalloc().
536  *
537  * Just like `kmalloc(...)`, except the allocation is managed by the test case
538  * and is automatically cleaned up after the test case concludes. See &struct
539  * kunit_resource for more information.
540  */
541 void *kunit_kmalloc(struct kunit *test, size_t size, gfp_t gfp);
542
543 /**
544  * kunit_kfree() - Like kfree except for allocations managed by KUnit.
545  * @test: The test case to which the resource belongs.
546  * @ptr: The memory allocation to free.
547  */
548 void kunit_kfree(struct kunit *test, const void *ptr);
549
550 /**
551  * kunit_kzalloc() - Just like kunit_kmalloc(), but zeroes the allocation.
552  * @test: The test context object.
553  * @size: The size in bytes of the desired memory.
554  * @gfp: flags passed to underlying kmalloc().
555  *
556  * See kzalloc() and kunit_kmalloc() for more information.
557  */
558 static inline void *kunit_kzalloc(struct kunit *test, size_t size, gfp_t gfp)
559 {
560         return kunit_kmalloc(test, size, gfp | __GFP_ZERO);
561 }
562
563 void kunit_cleanup(struct kunit *test);
564
565 void kunit_log_append(char *log, const char *fmt, ...);
566
567 /*
568  * printk and log to per-test or per-suite log buffer.  Logging only done
569  * if CONFIG_KUNIT_DEBUGFS is 'y'; if it is 'n', no log is allocated/used.
570  */
571 #define kunit_log(lvl, test_or_suite, fmt, ...)                         \
572         do {                                                            \
573                 printk(lvl fmt, ##__VA_ARGS__);                         \
574                 kunit_log_append((test_or_suite)->log,  fmt "\n",       \
575                                  ##__VA_ARGS__);                        \
576         } while (0)
577
578 #define kunit_printk(lvl, test, fmt, ...)                               \
579         kunit_log(lvl, test, KUNIT_SUBTEST_INDENT "# %s: " fmt,         \
580                   (test)->name, ##__VA_ARGS__)
581
582 /**
583  * kunit_info() - Prints an INFO level message associated with @test.
584  *
585  * @test: The test context object.
586  * @fmt:  A printk() style format string.
587  *
588  * Prints an info level message associated with the test suite being run.
589  * Takes a variable number of format parameters just like printk().
590  */
591 #define kunit_info(test, fmt, ...) \
592         kunit_printk(KERN_INFO, test, fmt, ##__VA_ARGS__)
593
594 /**
595  * kunit_warn() - Prints a WARN level message associated with @test.
596  *
597  * @test: The test context object.
598  * @fmt:  A printk() style format string.
599  *
600  * Prints a warning level message.
601  */
602 #define kunit_warn(test, fmt, ...) \
603         kunit_printk(KERN_WARNING, test, fmt, ##__VA_ARGS__)
604
605 /**
606  * kunit_err() - Prints an ERROR level message associated with @test.
607  *
608  * @test: The test context object.
609  * @fmt:  A printk() style format string.
610  *
611  * Prints an error level message.
612  */
613 #define kunit_err(test, fmt, ...) \
614         kunit_printk(KERN_ERR, test, fmt, ##__VA_ARGS__)
615
616 /**
617  * KUNIT_SUCCEED() - A no-op expectation. Only exists for code clarity.
618  * @test: The test context object.
619  *
620  * The opposite of KUNIT_FAIL(), it is an expectation that cannot fail. In other
621  * words, it does nothing and only exists for code clarity. See
622  * KUNIT_EXPECT_TRUE() for more information.
623  */
624 #define KUNIT_SUCCEED(test) do {} while (0)
625
626 void kunit_do_assertion(struct kunit *test,
627                         struct kunit_assert *assert,
628                         bool pass,
629                         const char *fmt, ...);
630
631 #define KUNIT_ASSERTION(test, pass, assert_class, INITIALIZER, fmt, ...) do {  \
632         struct assert_class __assertion = INITIALIZER;                         \
633         kunit_do_assertion(test,                                               \
634                            &__assertion.assert,                                \
635                            pass,                                               \
636                            fmt,                                                \
637                            ##__VA_ARGS__);                                     \
638 } while (0)
639
640
641 #define KUNIT_FAIL_ASSERTION(test, assert_type, fmt, ...)                      \
642         KUNIT_ASSERTION(test,                                                  \
643                         false,                                                 \
644                         kunit_fail_assert,                                     \
645                         KUNIT_INIT_FAIL_ASSERT_STRUCT(test, assert_type),      \
646                         fmt,                                                   \
647                         ##__VA_ARGS__)
648
649 /**
650  * KUNIT_FAIL() - Always causes a test to fail when evaluated.
651  * @test: The test context object.
652  * @fmt: an informational message to be printed when the assertion is made.
653  * @...: string format arguments.
654  *
655  * The opposite of KUNIT_SUCCEED(), it is an expectation that always fails. In
656  * other words, it always results in a failed expectation, and consequently
657  * always causes the test case to fail when evaluated. See KUNIT_EXPECT_TRUE()
658  * for more information.
659  */
660 #define KUNIT_FAIL(test, fmt, ...)                                             \
661         KUNIT_FAIL_ASSERTION(test,                                             \
662                              KUNIT_EXPECTATION,                                \
663                              fmt,                                              \
664                              ##__VA_ARGS__)
665
666 #define KUNIT_UNARY_ASSERTION(test,                                            \
667                               assert_type,                                     \
668                               condition,                                       \
669                               expected_true,                                   \
670                               fmt,                                             \
671                               ...)                                             \
672         KUNIT_ASSERTION(test,                                                  \
673                         !!(condition) == !!expected_true,                      \
674                         kunit_unary_assert,                                    \
675                         KUNIT_INIT_UNARY_ASSERT_STRUCT(test,                   \
676                                                        assert_type,            \
677                                                        #condition,             \
678                                                        expected_true),         \
679                         fmt,                                                   \
680                         ##__VA_ARGS__)
681
682 #define KUNIT_TRUE_MSG_ASSERTION(test, assert_type, condition, fmt, ...)       \
683         KUNIT_UNARY_ASSERTION(test,                                            \
684                               assert_type,                                     \
685                               condition,                                       \
686                               true,                                            \
687                               fmt,                                             \
688                               ##__VA_ARGS__)
689
690 #define KUNIT_TRUE_ASSERTION(test, assert_type, condition) \
691         KUNIT_TRUE_MSG_ASSERTION(test, assert_type, condition, NULL)
692
693 #define KUNIT_FALSE_MSG_ASSERTION(test, assert_type, condition, fmt, ...)      \
694         KUNIT_UNARY_ASSERTION(test,                                            \
695                               assert_type,                                     \
696                               condition,                                       \
697                               false,                                           \
698                               fmt,                                             \
699                               ##__VA_ARGS__)
700
701 #define KUNIT_FALSE_ASSERTION(test, assert_type, condition) \
702         KUNIT_FALSE_MSG_ASSERTION(test, assert_type, condition, NULL)
703
704 /*
705  * A factory macro for defining the assertions and expectations for the basic
706  * comparisons defined for the built in types.
707  *
708  * Unfortunately, there is no common type that all types can be promoted to for
709  * which all the binary operators behave the same way as for the actual types
710  * (for example, there is no type that long long and unsigned long long can
711  * both be cast to where the comparison result is preserved for all values). So
712  * the best we can do is do the comparison in the original types and then coerce
713  * everything to long long for printing; this way, the comparison behaves
714  * correctly and the printed out value usually makes sense without
715  * interpretation, but can always be interpreted to figure out the actual
716  * value.
717  */
718 #define KUNIT_BASE_BINARY_ASSERTION(test,                                      \
719                                     assert_class,                              \
720                                     ASSERT_CLASS_INIT,                         \
721                                     assert_type,                               \
722                                     left,                                      \
723                                     op,                                        \
724                                     right,                                     \
725                                     fmt,                                       \
726                                     ...)                                       \
727 do {                                                                           \
728         typeof(left) __left = (left);                                          \
729         typeof(right) __right = (right);                                       \
730         ((void)__typecheck(__left, __right));                                  \
731                                                                                \
732         KUNIT_ASSERTION(test,                                                  \
733                         __left op __right,                                     \
734                         assert_class,                                          \
735                         ASSERT_CLASS_INIT(test,                                \
736                                           assert_type,                         \
737                                           #op,                                 \
738                                           #left,                               \
739                                           __left,                              \
740                                           #right,                              \
741                                           __right),                            \
742                         fmt,                                                   \
743                         ##__VA_ARGS__);                                        \
744 } while (0)
745
746 #define KUNIT_BASE_EQ_MSG_ASSERTION(test,                                      \
747                                     assert_class,                              \
748                                     ASSERT_CLASS_INIT,                         \
749                                     assert_type,                               \
750                                     left,                                      \
751                                     right,                                     \
752                                     fmt,                                       \
753                                     ...)                                       \
754         KUNIT_BASE_BINARY_ASSERTION(test,                                      \
755                                     assert_class,                              \
756                                     ASSERT_CLASS_INIT,                         \
757                                     assert_type,                               \
758                                     left, ==, right,                           \
759                                     fmt,                                       \
760                                     ##__VA_ARGS__)
761
762 #define KUNIT_BASE_NE_MSG_ASSERTION(test,                                      \
763                                     assert_class,                              \
764                                     ASSERT_CLASS_INIT,                         \
765                                     assert_type,                               \
766                                     left,                                      \
767                                     right,                                     \
768                                     fmt,                                       \
769                                     ...)                                       \
770         KUNIT_BASE_BINARY_ASSERTION(test,                                      \
771                                     assert_class,                              \
772                                     ASSERT_CLASS_INIT,                         \
773                                     assert_type,                               \
774                                     left, !=, right,                           \
775                                     fmt,                                       \
776                                     ##__VA_ARGS__)
777
778 #define KUNIT_BASE_LT_MSG_ASSERTION(test,                                      \
779                                     assert_class,                              \
780                                     ASSERT_CLASS_INIT,                         \
781                                     assert_type,                               \
782                                     left,                                      \
783                                     right,                                     \
784                                     fmt,                                       \
785                                     ...)                                       \
786         KUNIT_BASE_BINARY_ASSERTION(test,                                      \
787                                     assert_class,                              \
788                                     ASSERT_CLASS_INIT,                         \
789                                     assert_type,                               \
790                                     left, <, right,                            \
791                                     fmt,                                       \
792                                     ##__VA_ARGS__)
793
794 #define KUNIT_BASE_LE_MSG_ASSERTION(test,                                      \
795                                     assert_class,                              \
796                                     ASSERT_CLASS_INIT,                         \
797                                     assert_type,                               \
798                                     left,                                      \
799                                     right,                                     \
800                                     fmt,                                       \
801                                     ...)                                       \
802         KUNIT_BASE_BINARY_ASSERTION(test,                                      \
803                                     assert_class,                              \
804                                     ASSERT_CLASS_INIT,                         \
805                                     assert_type,                               \
806                                     left, <=, right,                           \
807                                     fmt,                                       \
808                                     ##__VA_ARGS__)
809
810 #define KUNIT_BASE_GT_MSG_ASSERTION(test,                                      \
811                                     assert_class,                              \
812                                     ASSERT_CLASS_INIT,                         \
813                                     assert_type,                               \
814                                     left,                                      \
815                                     right,                                     \
816                                     fmt,                                       \
817                                     ...)                                       \
818         KUNIT_BASE_BINARY_ASSERTION(test,                                      \
819                                     assert_class,                              \
820                                     ASSERT_CLASS_INIT,                         \
821                                     assert_type,                               \
822                                     left, >, right,                            \
823                                     fmt,                                       \
824                                     ##__VA_ARGS__)
825
826 #define KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
827                                     assert_class,                              \
828                                     ASSERT_CLASS_INIT,                         \
829                                     assert_type,                               \
830                                     left,                                      \
831                                     right,                                     \
832                                     fmt,                                       \
833                                     ...)                                       \
834         KUNIT_BASE_BINARY_ASSERTION(test,                                      \
835                                     assert_class,                              \
836                                     ASSERT_CLASS_INIT,                         \
837                                     assert_type,                               \
838                                     left, >=, right,                           \
839                                     fmt,                                       \
840                                     ##__VA_ARGS__)
841
842 #define KUNIT_BINARY_EQ_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
843         KUNIT_BASE_EQ_MSG_ASSERTION(test,                                      \
844                                     kunit_binary_assert,                       \
845                                     KUNIT_INIT_BINARY_ASSERT_STRUCT,           \
846                                     assert_type,                               \
847                                     left,                                      \
848                                     right,                                     \
849                                     fmt,                                       \
850                                     ##__VA_ARGS__)
851
852 #define KUNIT_BINARY_EQ_ASSERTION(test, assert_type, left, right)              \
853         KUNIT_BINARY_EQ_MSG_ASSERTION(test,                                    \
854                                       assert_type,                             \
855                                       left,                                    \
856                                       right,                                   \
857                                       NULL)
858
859 #define KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test,                                \
860                                           assert_type,                         \
861                                           left,                                \
862                                           right,                               \
863                                           fmt,                                 \
864                                           ...)                                 \
865         KUNIT_BASE_EQ_MSG_ASSERTION(test,                                      \
866                                     kunit_binary_ptr_assert,                   \
867                                     KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT,       \
868                                     assert_type,                               \
869                                     left,                                      \
870                                     right,                                     \
871                                     fmt,                                       \
872                                     ##__VA_ARGS__)
873
874 #define KUNIT_BINARY_PTR_EQ_ASSERTION(test, assert_type, left, right)          \
875         KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test,                                \
876                                           assert_type,                         \
877                                           left,                                \
878                                           right,                               \
879                                           NULL)
880
881 #define KUNIT_BINARY_NE_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
882         KUNIT_BASE_NE_MSG_ASSERTION(test,                                      \
883                                     kunit_binary_assert,                       \
884                                     KUNIT_INIT_BINARY_ASSERT_STRUCT,           \
885                                     assert_type,                               \
886                                     left,                                      \
887                                     right,                                     \
888                                     fmt,                                       \
889                                     ##__VA_ARGS__)
890
891 #define KUNIT_BINARY_NE_ASSERTION(test, assert_type, left, right)              \
892         KUNIT_BINARY_NE_MSG_ASSERTION(test,                                    \
893                                       assert_type,                             \
894                                       left,                                    \
895                                       right,                                   \
896                                       NULL)
897
898 #define KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test,                                \
899                                           assert_type,                         \
900                                           left,                                \
901                                           right,                               \
902                                           fmt,                                 \
903                                           ...)                                 \
904         KUNIT_BASE_NE_MSG_ASSERTION(test,                                      \
905                                     kunit_binary_ptr_assert,                   \
906                                     KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT,       \
907                                     assert_type,                               \
908                                     left,                                      \
909                                     right,                                     \
910                                     fmt,                                       \
911                                     ##__VA_ARGS__)
912
913 #define KUNIT_BINARY_PTR_NE_ASSERTION(test, assert_type, left, right)          \
914         KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test,                                \
915                                           assert_type,                         \
916                                           left,                                \
917                                           right,                               \
918                                           NULL)
919
920 #define KUNIT_BINARY_LT_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
921         KUNIT_BASE_LT_MSG_ASSERTION(test,                                      \
922                                     kunit_binary_assert,                       \
923                                     KUNIT_INIT_BINARY_ASSERT_STRUCT,           \
924                                     assert_type,                               \
925                                     left,                                      \
926                                     right,                                     \
927                                     fmt,                                       \
928                                     ##__VA_ARGS__)
929
930 #define KUNIT_BINARY_LT_ASSERTION(test, assert_type, left, right)              \
931         KUNIT_BINARY_LT_MSG_ASSERTION(test,                                    \
932                                       assert_type,                             \
933                                       left,                                    \
934                                       right,                                   \
935                                       NULL)
936
937 #define KUNIT_BINARY_PTR_LT_MSG_ASSERTION(test,                                \
938                                           assert_type,                         \
939                                           left,                                \
940                                           right,                               \
941                                           fmt,                                 \
942                                           ...)                                 \
943         KUNIT_BASE_LT_MSG_ASSERTION(test,                                      \
944                                     kunit_binary_ptr_assert,                   \
945                                     KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT,       \
946                                     assert_type,                               \
947                                     left,                                      \
948                                     right,                                     \
949                                     fmt,                                       \
950                                     ##__VA_ARGS__)
951
952 #define KUNIT_BINARY_PTR_LT_ASSERTION(test, assert_type, left, right)          \
953         KUNIT_BINARY_PTR_LT_MSG_ASSERTION(test,                                \
954                                           assert_type,                         \
955                                           left,                                \
956                                           right,                               \
957                                           NULL)
958
959 #define KUNIT_BINARY_LE_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
960         KUNIT_BASE_LE_MSG_ASSERTION(test,                                      \
961                                     kunit_binary_assert,                       \
962                                     KUNIT_INIT_BINARY_ASSERT_STRUCT,           \
963                                     assert_type,                               \
964                                     left,                                      \
965                                     right,                                     \
966                                     fmt,                                       \
967                                     ##__VA_ARGS__)
968
969 #define KUNIT_BINARY_LE_ASSERTION(test, assert_type, left, right)              \
970         KUNIT_BINARY_LE_MSG_ASSERTION(test,                                    \
971                                       assert_type,                             \
972                                       left,                                    \
973                                       right,                                   \
974                                       NULL)
975
976 #define KUNIT_BINARY_PTR_LE_MSG_ASSERTION(test,                                \
977                                           assert_type,                         \
978                                           left,                                \
979                                           right,                               \
980                                           fmt,                                 \
981                                           ...)                                 \
982         KUNIT_BASE_LE_MSG_ASSERTION(test,                                      \
983                                     kunit_binary_ptr_assert,                   \
984                                     KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT,       \
985                                     assert_type,                               \
986                                     left,                                      \
987                                     right,                                     \
988                                     fmt,                                       \
989                                     ##__VA_ARGS__)
990
991 #define KUNIT_BINARY_PTR_LE_ASSERTION(test, assert_type, left, right)          \
992         KUNIT_BINARY_PTR_LE_MSG_ASSERTION(test,                                \
993                                           assert_type,                         \
994                                           left,                                \
995                                           right,                               \
996                                           NULL)
997
998 #define KUNIT_BINARY_GT_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
999         KUNIT_BASE_GT_MSG_ASSERTION(test,                                      \
1000                                     kunit_binary_assert,                       \
1001                                     KUNIT_INIT_BINARY_ASSERT_STRUCT,           \
1002                                     assert_type,                               \
1003                                     left,                                      \
1004                                     right,                                     \
1005                                     fmt,                                       \
1006                                     ##__VA_ARGS__)
1007
1008 #define KUNIT_BINARY_GT_ASSERTION(test, assert_type, left, right)              \
1009         KUNIT_BINARY_GT_MSG_ASSERTION(test,                                    \
1010                                       assert_type,                             \
1011                                       left,                                    \
1012                                       right,                                   \
1013                                       NULL)
1014
1015 #define KUNIT_BINARY_PTR_GT_MSG_ASSERTION(test,                                \
1016                                           assert_type,                         \
1017                                           left,                                \
1018                                           right,                               \
1019                                           fmt,                                 \
1020                                           ...)                                 \
1021         KUNIT_BASE_GT_MSG_ASSERTION(test,                                      \
1022                                     kunit_binary_ptr_assert,                   \
1023                                     KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT,       \
1024                                     assert_type,                               \
1025                                     left,                                      \
1026                                     right,                                     \
1027                                     fmt,                                       \
1028                                     ##__VA_ARGS__)
1029
1030 #define KUNIT_BINARY_PTR_GT_ASSERTION(test, assert_type, left, right)          \
1031         KUNIT_BINARY_PTR_GT_MSG_ASSERTION(test,                                \
1032                                           assert_type,                         \
1033                                           left,                                \
1034                                           right,                               \
1035                                           NULL)
1036
1037 #define KUNIT_BINARY_GE_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
1038         KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
1039                                     kunit_binary_assert,                       \
1040                                     KUNIT_INIT_BINARY_ASSERT_STRUCT,           \
1041                                     assert_type,                               \
1042                                     left,                                      \
1043                                     right,                                     \
1044                                     fmt,                                       \
1045                                     ##__VA_ARGS__)
1046
1047 #define KUNIT_BINARY_GE_ASSERTION(test, assert_type, left, right)              \
1048         KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
1049                                       assert_type,                             \
1050                                       left,                                    \
1051                                       right,                                   \
1052                                       NULL)
1053
1054 #define KUNIT_BINARY_PTR_GE_MSG_ASSERTION(test,                                \
1055                                           assert_type,                         \
1056                                           left,                                \
1057                                           right,                               \
1058                                           fmt,                                 \
1059                                           ...)                                 \
1060         KUNIT_BASE_GE_MSG_ASSERTION(test,                                      \
1061                                     kunit_binary_ptr_assert,                   \
1062                                     KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT,       \
1063                                     assert_type,                               \
1064                                     left,                                      \
1065                                     right,                                     \
1066                                     fmt,                                       \
1067                                     ##__VA_ARGS__)
1068
1069 #define KUNIT_BINARY_PTR_GE_ASSERTION(test, assert_type, left, right)          \
1070         KUNIT_BINARY_PTR_GE_MSG_ASSERTION(test,                                \
1071                                           assert_type,                         \
1072                                           left,                                \
1073                                           right,                               \
1074                                           NULL)
1075
1076 #define KUNIT_BINARY_STR_ASSERTION(test,                                       \
1077                                    assert_type,                                \
1078                                    left,                                       \
1079                                    op,                                         \
1080                                    right,                                      \
1081                                    fmt,                                        \
1082                                    ...)                                        \
1083 do {                                                                           \
1084         typeof(left) __left = (left);                                          \
1085         typeof(right) __right = (right);                                       \
1086                                                                                \
1087         KUNIT_ASSERTION(test,                                                  \
1088                         strcmp(__left, __right) op 0,                          \
1089                         kunit_binary_str_assert,                               \
1090                         KUNIT_INIT_BINARY_ASSERT_STRUCT(test,                  \
1091                                                         assert_type,           \
1092                                                         #op,                   \
1093                                                         #left,                 \
1094                                                         __left,                \
1095                                                         #right,                \
1096                                                         __right),              \
1097                         fmt,                                                   \
1098                         ##__VA_ARGS__);                                        \
1099 } while (0)
1100
1101 #define KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,                                \
1102                                           assert_type,                         \
1103                                           left,                                \
1104                                           right,                               \
1105                                           fmt,                                 \
1106                                           ...)                                 \
1107         KUNIT_BINARY_STR_ASSERTION(test,                                       \
1108                                    assert_type,                                \
1109                                    left, ==, right,                            \
1110                                    fmt,                                        \
1111                                    ##__VA_ARGS__)
1112
1113 #define KUNIT_BINARY_STR_EQ_ASSERTION(test, assert_type, left, right)          \
1114         KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,                                \
1115                                           assert_type,                         \
1116                                           left,                                \
1117                                           right,                               \
1118                                           NULL)
1119
1120 #define KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,                                \
1121                                           assert_type,                         \
1122                                           left,                                \
1123                                           right,                               \
1124                                           fmt,                                 \
1125                                           ...)                                 \
1126         KUNIT_BINARY_STR_ASSERTION(test,                                       \
1127                                    assert_type,                                \
1128                                    left, !=, right,                            \
1129                                    fmt,                                        \
1130                                    ##__VA_ARGS__)
1131
1132 #define KUNIT_BINARY_STR_NE_ASSERTION(test, assert_type, left, right)          \
1133         KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,                                \
1134                                           assert_type,                         \
1135                                           left,                                \
1136                                           right,                               \
1137                                           NULL)
1138
1139 #define KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,                          \
1140                                                 assert_type,                   \
1141                                                 ptr,                           \
1142                                                 fmt,                           \
1143                                                 ...)                           \
1144 do {                                                                           \
1145         typeof(ptr) __ptr = (ptr);                                             \
1146                                                                                \
1147         KUNIT_ASSERTION(test,                                                  \
1148                         !IS_ERR_OR_NULL(__ptr),                                \
1149                         kunit_ptr_not_err_assert,                              \
1150                         KUNIT_INIT_PTR_NOT_ERR_STRUCT(test,                    \
1151                                                       assert_type,             \
1152                                                       #ptr,                    \
1153                                                       __ptr),                  \
1154                         fmt,                                                   \
1155                         ##__VA_ARGS__);                                        \
1156 } while (0)
1157
1158 #define KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, assert_type, ptr)            \
1159         KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,                          \
1160                                                 assert_type,                   \
1161                                                 ptr,                           \
1162                                                 NULL)
1163
1164 /**
1165  * KUNIT_EXPECT_TRUE() - Causes a test failure when the expression is not true.
1166  * @test: The test context object.
1167  * @condition: an arbitrary boolean expression. The test fails when this does
1168  * not evaluate to true.
1169  *
1170  * This and expectations of the form `KUNIT_EXPECT_*` will cause the test case
1171  * to fail when the specified condition is not met; however, it will not prevent
1172  * the test case from continuing to run; this is otherwise known as an
1173  * *expectation failure*.
1174  */
1175 #define KUNIT_EXPECT_TRUE(test, condition) \
1176         KUNIT_TRUE_ASSERTION(test, KUNIT_EXPECTATION, condition)
1177
1178 #define KUNIT_EXPECT_TRUE_MSG(test, condition, fmt, ...)                       \
1179         KUNIT_TRUE_MSG_ASSERTION(test,                                         \
1180                                  KUNIT_EXPECTATION,                            \
1181                                  condition,                                    \
1182                                  fmt,                                          \
1183                                  ##__VA_ARGS__)
1184
1185 /**
1186  * KUNIT_EXPECT_FALSE() - Makes a test failure when the expression is not false.
1187  * @test: The test context object.
1188  * @condition: an arbitrary boolean expression. The test fails when this does
1189  * not evaluate to false.
1190  *
1191  * Sets an expectation that @condition evaluates to false. See
1192  * KUNIT_EXPECT_TRUE() for more information.
1193  */
1194 #define KUNIT_EXPECT_FALSE(test, condition) \
1195         KUNIT_FALSE_ASSERTION(test, KUNIT_EXPECTATION, condition)
1196
1197 #define KUNIT_EXPECT_FALSE_MSG(test, condition, fmt, ...)                      \
1198         KUNIT_FALSE_MSG_ASSERTION(test,                                        \
1199                                   KUNIT_EXPECTATION,                           \
1200                                   condition,                                   \
1201                                   fmt,                                         \
1202                                   ##__VA_ARGS__)
1203
1204 /**
1205  * KUNIT_EXPECT_EQ() - Sets an expectation that @left and @right are equal.
1206  * @test: The test context object.
1207  * @left: an arbitrary expression that evaluates to a primitive C type.
1208  * @right: an arbitrary expression that evaluates to a primitive C type.
1209  *
1210  * Sets an expectation that the values that @left and @right evaluate to are
1211  * equal. This is semantically equivalent to
1212  * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
1213  * more information.
1214  */
1215 #define KUNIT_EXPECT_EQ(test, left, right) \
1216         KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1217
1218 #define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...)                       \
1219         KUNIT_BINARY_EQ_MSG_ASSERTION(test,                                    \
1220                                       KUNIT_EXPECTATION,                       \
1221                                       left,                                    \
1222                                       right,                                   \
1223                                       fmt,                                     \
1224                                       ##__VA_ARGS__)
1225
1226 /**
1227  * KUNIT_EXPECT_PTR_EQ() - Expects that pointers @left and @right are equal.
1228  * @test: The test context object.
1229  * @left: an arbitrary expression that evaluates to a pointer.
1230  * @right: an arbitrary expression that evaluates to a pointer.
1231  *
1232  * Sets an expectation that the values that @left and @right evaluate to are
1233  * equal. This is semantically equivalent to
1234  * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
1235  * more information.
1236  */
1237 #define KUNIT_EXPECT_PTR_EQ(test, left, right)                                 \
1238         KUNIT_BINARY_PTR_EQ_ASSERTION(test,                                    \
1239                                       KUNIT_EXPECTATION,                       \
1240                                       left,                                    \
1241                                       right)
1242
1243 #define KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, fmt, ...)                   \
1244         KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test,                                \
1245                                           KUNIT_EXPECTATION,                   \
1246                                           left,                                \
1247                                           right,                               \
1248                                           fmt,                                 \
1249                                           ##__VA_ARGS__)
1250
1251 /**
1252  * KUNIT_EXPECT_NE() - An expectation that @left and @right are not equal.
1253  * @test: The test context object.
1254  * @left: an arbitrary expression that evaluates to a primitive C type.
1255  * @right: an arbitrary expression that evaluates to a primitive C type.
1256  *
1257  * Sets an expectation that the values that @left and @right evaluate to are not
1258  * equal. This is semantically equivalent to
1259  * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
1260  * more information.
1261  */
1262 #define KUNIT_EXPECT_NE(test, left, right) \
1263         KUNIT_BINARY_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1264
1265 #define KUNIT_EXPECT_NE_MSG(test, left, right, fmt, ...)                       \
1266         KUNIT_BINARY_NE_MSG_ASSERTION(test,                                    \
1267                                       KUNIT_EXPECTATION,                       \
1268                                       left,                                    \
1269                                       right,                                   \
1270                                       fmt,                                     \
1271                                       ##__VA_ARGS__)
1272
1273 /**
1274  * KUNIT_EXPECT_PTR_NE() - Expects that pointers @left and @right are not equal.
1275  * @test: The test context object.
1276  * @left: an arbitrary expression that evaluates to a pointer.
1277  * @right: an arbitrary expression that evaluates to a pointer.
1278  *
1279  * Sets an expectation that the values that @left and @right evaluate to are not
1280  * equal. This is semantically equivalent to
1281  * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
1282  * more information.
1283  */
1284 #define KUNIT_EXPECT_PTR_NE(test, left, right)                                 \
1285         KUNIT_BINARY_PTR_NE_ASSERTION(test,                                    \
1286                                       KUNIT_EXPECTATION,                       \
1287                                       left,                                    \
1288                                       right)
1289
1290 #define KUNIT_EXPECT_PTR_NE_MSG(test, left, right, fmt, ...)                   \
1291         KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test,                                \
1292                                           KUNIT_EXPECTATION,                   \
1293                                           left,                                \
1294                                           right,                               \
1295                                           fmt,                                 \
1296                                           ##__VA_ARGS__)
1297
1298 /**
1299  * KUNIT_EXPECT_LT() - An expectation that @left is less than @right.
1300  * @test: The test context object.
1301  * @left: an arbitrary expression that evaluates to a primitive C type.
1302  * @right: an arbitrary expression that evaluates to a primitive C type.
1303  *
1304  * Sets an expectation that the value that @left evaluates to is less than the
1305  * value that @right evaluates to. This is semantically equivalent to
1306  * KUNIT_EXPECT_TRUE(@test, (@left) < (@right)). See KUNIT_EXPECT_TRUE() for
1307  * more information.
1308  */
1309 #define KUNIT_EXPECT_LT(test, left, right) \
1310         KUNIT_BINARY_LT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1311
1312 #define KUNIT_EXPECT_LT_MSG(test, left, right, fmt, ...)                       \
1313         KUNIT_BINARY_LT_MSG_ASSERTION(test,                                    \
1314                                       KUNIT_EXPECTATION,                       \
1315                                       left,                                    \
1316                                       right,                                   \
1317                                       fmt,                                     \
1318                                       ##__VA_ARGS__)
1319
1320 /**
1321  * KUNIT_EXPECT_LE() - Expects that @left is less than or equal to @right.
1322  * @test: The test context object.
1323  * @left: an arbitrary expression that evaluates to a primitive C type.
1324  * @right: an arbitrary expression that evaluates to a primitive C type.
1325  *
1326  * Sets an expectation that the value that @left evaluates to is less than or
1327  * equal to the value that @right evaluates to. Semantically this is equivalent
1328  * to KUNIT_EXPECT_TRUE(@test, (@left) <= (@right)). See KUNIT_EXPECT_TRUE() for
1329  * more information.
1330  */
1331 #define KUNIT_EXPECT_LE(test, left, right) \
1332         KUNIT_BINARY_LE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1333
1334 #define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...)                       \
1335         KUNIT_BINARY_LE_MSG_ASSERTION(test,                                    \
1336                                       KUNIT_EXPECTATION,                       \
1337                                       left,                                    \
1338                                       right,                                   \
1339                                       fmt,                                     \
1340                                       ##__VA_ARGS__)
1341
1342 /**
1343  * KUNIT_EXPECT_GT() - An expectation that @left is greater than @right.
1344  * @test: The test context object.
1345  * @left: an arbitrary expression that evaluates to a primitive C type.
1346  * @right: an arbitrary expression that evaluates to a primitive C type.
1347  *
1348  * Sets an expectation that the value that @left evaluates to is greater than
1349  * the value that @right evaluates to. This is semantically equivalent to
1350  * KUNIT_EXPECT_TRUE(@test, (@left) > (@right)). See KUNIT_EXPECT_TRUE() for
1351  * more information.
1352  */
1353 #define KUNIT_EXPECT_GT(test, left, right) \
1354         KUNIT_BINARY_GT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1355
1356 #define KUNIT_EXPECT_GT_MSG(test, left, right, fmt, ...)                       \
1357         KUNIT_BINARY_GT_MSG_ASSERTION(test,                                    \
1358                                       KUNIT_EXPECTATION,                       \
1359                                       left,                                    \
1360                                       right,                                   \
1361                                       fmt,                                     \
1362                                       ##__VA_ARGS__)
1363
1364 /**
1365  * KUNIT_EXPECT_GE() - Expects that @left is greater than or equal to @right.
1366  * @test: The test context object.
1367  * @left: an arbitrary expression that evaluates to a primitive C type.
1368  * @right: an arbitrary expression that evaluates to a primitive C type.
1369  *
1370  * Sets an expectation that the value that @left evaluates to is greater than
1371  * the value that @right evaluates to. This is semantically equivalent to
1372  * KUNIT_EXPECT_TRUE(@test, (@left) >= (@right)). See KUNIT_EXPECT_TRUE() for
1373  * more information.
1374  */
1375 #define KUNIT_EXPECT_GE(test, left, right) \
1376         KUNIT_BINARY_GE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1377
1378 #define KUNIT_EXPECT_GE_MSG(test, left, right, fmt, ...)                       \
1379         KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
1380                                       KUNIT_EXPECTATION,                       \
1381                                       left,                                    \
1382                                       right,                                   \
1383                                       fmt,                                     \
1384                                       ##__VA_ARGS__)
1385
1386 /**
1387  * KUNIT_EXPECT_STREQ() - Expects that strings @left and @right are equal.
1388  * @test: The test context object.
1389  * @left: an arbitrary expression that evaluates to a null terminated string.
1390  * @right: an arbitrary expression that evaluates to a null terminated string.
1391  *
1392  * Sets an expectation that the values that @left and @right evaluate to are
1393  * equal. This is semantically equivalent to
1394  * KUNIT_EXPECT_TRUE(@test, !strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
1395  * for more information.
1396  */
1397 #define KUNIT_EXPECT_STREQ(test, left, right) \
1398         KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1399
1400 #define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...)                    \
1401         KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,                                \
1402                                           KUNIT_EXPECTATION,                   \
1403                                           left,                                \
1404                                           right,                               \
1405                                           fmt,                                 \
1406                                           ##__VA_ARGS__)
1407
1408 /**
1409  * KUNIT_EXPECT_STRNEQ() - Expects that strings @left and @right are not equal.
1410  * @test: The test context object.
1411  * @left: an arbitrary expression that evaluates to a null terminated string.
1412  * @right: an arbitrary expression that evaluates to a null terminated string.
1413  *
1414  * Sets an expectation that the values that @left and @right evaluate to are
1415  * not equal. This is semantically equivalent to
1416  * KUNIT_EXPECT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
1417  * for more information.
1418  */
1419 #define KUNIT_EXPECT_STRNEQ(test, left, right) \
1420         KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
1421
1422 #define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...)                   \
1423         KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,                                \
1424                                           KUNIT_EXPECTATION,                   \
1425                                           left,                                \
1426                                           right,                               \
1427                                           fmt,                                 \
1428                                           ##__VA_ARGS__)
1429
1430 /**
1431  * KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err.
1432  * @test: The test context object.
1433  * @ptr: an arbitrary pointer.
1434  *
1435  * Sets an expectation that the value that @ptr evaluates to is not null and not
1436  * an errno stored in a pointer. This is semantically equivalent to
1437  * KUNIT_EXPECT_TRUE(@test, !IS_ERR_OR_NULL(@ptr)). See KUNIT_EXPECT_TRUE() for
1438  * more information.
1439  */
1440 #define KUNIT_EXPECT_NOT_ERR_OR_NULL(test, ptr) \
1441         KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, KUNIT_EXPECTATION, ptr)
1442
1443 #define KUNIT_EXPECT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...)                  \
1444         KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,                          \
1445                                                 KUNIT_EXPECTATION,             \
1446                                                 ptr,                           \
1447                                                 fmt,                           \
1448                                                 ##__VA_ARGS__)
1449
1450 #define KUNIT_ASSERT_FAILURE(test, fmt, ...) \
1451         KUNIT_FAIL_ASSERTION(test, KUNIT_ASSERTION, fmt, ##__VA_ARGS__)
1452
1453 /**
1454  * KUNIT_ASSERT_TRUE() - Sets an assertion that @condition is true.
1455  * @test: The test context object.
1456  * @condition: an arbitrary boolean expression. The test fails and aborts when
1457  * this does not evaluate to true.
1458  *
1459  * This and assertions of the form `KUNIT_ASSERT_*` will cause the test case to
1460  * fail *and immediately abort* when the specified condition is not met. Unlike
1461  * an expectation failure, it will prevent the test case from continuing to run;
1462  * this is otherwise known as an *assertion failure*.
1463  */
1464 #define KUNIT_ASSERT_TRUE(test, condition) \
1465         KUNIT_TRUE_ASSERTION(test, KUNIT_ASSERTION, condition)
1466
1467 #define KUNIT_ASSERT_TRUE_MSG(test, condition, fmt, ...)                       \
1468         KUNIT_TRUE_MSG_ASSERTION(test,                                         \
1469                                  KUNIT_ASSERTION,                              \
1470                                  condition,                                    \
1471                                  fmt,                                          \
1472                                  ##__VA_ARGS__)
1473
1474 /**
1475  * KUNIT_ASSERT_FALSE() - Sets an assertion that @condition is false.
1476  * @test: The test context object.
1477  * @condition: an arbitrary boolean expression.
1478  *
1479  * Sets an assertion that the value that @condition evaluates to is false. This
1480  * is the same as KUNIT_EXPECT_FALSE(), except it causes an assertion failure
1481  * (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
1482  */
1483 #define KUNIT_ASSERT_FALSE(test, condition) \
1484         KUNIT_FALSE_ASSERTION(test, KUNIT_ASSERTION, condition)
1485
1486 #define KUNIT_ASSERT_FALSE_MSG(test, condition, fmt, ...)                      \
1487         KUNIT_FALSE_MSG_ASSERTION(test,                                        \
1488                                   KUNIT_ASSERTION,                             \
1489                                   condition,                                   \
1490                                   fmt,                                         \
1491                                   ##__VA_ARGS__)
1492
1493 /**
1494  * KUNIT_ASSERT_EQ() - Sets an assertion that @left and @right are equal.
1495  * @test: The test context object.
1496  * @left: an arbitrary expression that evaluates to a primitive C type.
1497  * @right: an arbitrary expression that evaluates to a primitive C type.
1498  *
1499  * Sets an assertion that the values that @left and @right evaluate to are
1500  * equal. This is the same as KUNIT_EXPECT_EQ(), except it causes an assertion
1501  * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
1502  */
1503 #define KUNIT_ASSERT_EQ(test, left, right) \
1504         KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
1505
1506 #define KUNIT_ASSERT_EQ_MSG(test, left, right, fmt, ...)                       \
1507         KUNIT_BINARY_EQ_MSG_ASSERTION(test,                                    \
1508                                       KUNIT_ASSERTION,                         \
1509                                       left,                                    \
1510                                       right,                                   \
1511                                       fmt,                                     \
1512                                       ##__VA_ARGS__)
1513
1514 /**
1515  * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
1516  * @test: The test context object.
1517  * @left: an arbitrary expression that evaluates to a pointer.
1518  * @right: an arbitrary expression that evaluates to a pointer.
1519  *
1520  * Sets an assertion that the values that @left and @right evaluate to are
1521  * equal. This is the same as KUNIT_EXPECT_EQ(), except it causes an assertion
1522  * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
1523  */
1524 #define KUNIT_ASSERT_PTR_EQ(test, left, right) \
1525         KUNIT_BINARY_PTR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
1526
1527 #define KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, fmt, ...)                   \
1528         KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test,                                \
1529                                           KUNIT_ASSERTION,                     \
1530                                           left,                                \
1531                                           right,                               \
1532                                           fmt,                                 \
1533                                           ##__VA_ARGS__)
1534
1535 /**
1536  * KUNIT_ASSERT_NE() - An assertion that @left and @right are not equal.
1537  * @test: The test context object.
1538  * @left: an arbitrary expression that evaluates to a primitive C type.
1539  * @right: an arbitrary expression that evaluates to a primitive C type.
1540  *
1541  * Sets an assertion that the values that @left and @right evaluate to are not
1542  * equal. This is the same as KUNIT_EXPECT_NE(), except it causes an assertion
1543  * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
1544  */
1545 #define KUNIT_ASSERT_NE(test, left, right) \
1546         KUNIT_BINARY_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
1547
1548 #define KUNIT_ASSERT_NE_MSG(test, left, right, fmt, ...)                       \
1549         KUNIT_BINARY_NE_MSG_ASSERTION(test,                                    \
1550                                       KUNIT_ASSERTION,                         \
1551                                       left,                                    \
1552                                       right,                                   \
1553                                       fmt,                                     \
1554                                       ##__VA_ARGS__)
1555
1556 /**
1557  * KUNIT_ASSERT_PTR_NE() - Asserts that pointers @left and @right are not equal.
1558  * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
1559  * @test: The test context object.
1560  * @left: an arbitrary expression that evaluates to a pointer.
1561  * @right: an arbitrary expression that evaluates to a pointer.
1562  *
1563  * Sets an assertion that the values that @left and @right evaluate to are not
1564  * equal. This is the same as KUNIT_EXPECT_NE(), except it causes an assertion
1565  * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
1566  */
1567 #define KUNIT_ASSERT_PTR_NE(test, left, right) \
1568         KUNIT_BINARY_PTR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
1569
1570 #define KUNIT_ASSERT_PTR_NE_MSG(test, left, right, fmt, ...)                   \
1571         KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test,                                \
1572                                           KUNIT_ASSERTION,                     \
1573                                           left,                                \
1574                                           right,                               \
1575                                           fmt,                                 \
1576                                           ##__VA_ARGS__)
1577 /**
1578  * KUNIT_ASSERT_LT() - An assertion that @left is less than @right.
1579  * @test: The test context object.
1580  * @left: an arbitrary expression that evaluates to a primitive C type.
1581  * @right: an arbitrary expression that evaluates to a primitive C type.
1582  *
1583  * Sets an assertion that the value that @left evaluates to is less than the
1584  * value that @right evaluates to. This is the same as KUNIT_EXPECT_LT(), except
1585  * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
1586  * is not met.
1587  */
1588 #define KUNIT_ASSERT_LT(test, left, right) \
1589         KUNIT_BINARY_LT_ASSERTION(test, KUNIT_ASSERTION, left, right)
1590
1591 #define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...)                       \
1592         KUNIT_BINARY_LT_MSG_ASSERTION(test,                                    \
1593                                       KUNIT_ASSERTION,                         \
1594                                       left,                                    \
1595                                       right,                                   \
1596                                       fmt,                                     \
1597                                       ##__VA_ARGS__)
1598 /**
1599  * KUNIT_ASSERT_LE() - An assertion that @left is less than or equal to @right.
1600  * @test: The test context object.
1601  * @left: an arbitrary expression that evaluates to a primitive C type.
1602  * @right: an arbitrary expression that evaluates to a primitive C type.
1603  *
1604  * Sets an assertion that the value that @left evaluates to is less than or
1605  * equal to the value that @right evaluates to. This is the same as
1606  * KUNIT_EXPECT_LE(), except it causes an assertion failure (see
1607  * KUNIT_ASSERT_TRUE()) when the assertion is not met.
1608  */
1609 #define KUNIT_ASSERT_LE(test, left, right) \
1610         KUNIT_BINARY_LE_ASSERTION(test, KUNIT_ASSERTION, left, right)
1611
1612 #define KUNIT_ASSERT_LE_MSG(test, left, right, fmt, ...)                       \
1613         KUNIT_BINARY_LE_MSG_ASSERTION(test,                                    \
1614                                       KUNIT_ASSERTION,                         \
1615                                       left,                                    \
1616                                       right,                                   \
1617                                       fmt,                                     \
1618                                       ##__VA_ARGS__)
1619
1620 /**
1621  * KUNIT_ASSERT_GT() - An assertion that @left is greater than @right.
1622  * @test: The test context object.
1623  * @left: an arbitrary expression that evaluates to a primitive C type.
1624  * @right: an arbitrary expression that evaluates to a primitive C type.
1625  *
1626  * Sets an assertion that the value that @left evaluates to is greater than the
1627  * value that @right evaluates to. This is the same as KUNIT_EXPECT_GT(), except
1628  * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
1629  * is not met.
1630  */
1631 #define KUNIT_ASSERT_GT(test, left, right) \
1632         KUNIT_BINARY_GT_ASSERTION(test, KUNIT_ASSERTION, left, right)
1633
1634 #define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...)                       \
1635         KUNIT_BINARY_GT_MSG_ASSERTION(test,                                    \
1636                                       KUNIT_ASSERTION,                         \
1637                                       left,                                    \
1638                                       right,                                   \
1639                                       fmt,                                     \
1640                                       ##__VA_ARGS__)
1641
1642 /**
1643  * KUNIT_ASSERT_GE() - Assertion that @left is greater than or equal to @right.
1644  * @test: The test context object.
1645  * @left: an arbitrary expression that evaluates to a primitive C type.
1646  * @right: an arbitrary expression that evaluates to a primitive C type.
1647  *
1648  * Sets an assertion that the value that @left evaluates to is greater than the
1649  * value that @right evaluates to. This is the same as KUNIT_EXPECT_GE(), except
1650  * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
1651  * is not met.
1652  */
1653 #define KUNIT_ASSERT_GE(test, left, right) \
1654         KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
1655
1656 #define KUNIT_ASSERT_GE_MSG(test, left, right, fmt, ...)                       \
1657         KUNIT_BINARY_GE_MSG_ASSERTION(test,                                    \
1658                                       KUNIT_ASSERTION,                         \
1659                                       left,                                    \
1660                                       right,                                   \
1661                                       fmt,                                     \
1662                                       ##__VA_ARGS__)
1663
1664 /**
1665  * KUNIT_ASSERT_STREQ() - An assertion that strings @left and @right are equal.
1666  * @test: The test context object.
1667  * @left: an arbitrary expression that evaluates to a null terminated string.
1668  * @right: an arbitrary expression that evaluates to a null terminated string.
1669  *
1670  * Sets an assertion that the values that @left and @right evaluate to are
1671  * equal. This is the same as KUNIT_EXPECT_STREQ(), except it causes an
1672  * assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
1673  */
1674 #define KUNIT_ASSERT_STREQ(test, left, right) \
1675         KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
1676
1677 #define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...)                    \
1678         KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,                                \
1679                                           KUNIT_ASSERTION,                     \
1680                                           left,                                \
1681                                           right,                               \
1682                                           fmt,                                 \
1683                                           ##__VA_ARGS__)
1684
1685 /**
1686  * KUNIT_ASSERT_STRNEQ() - Expects that strings @left and @right are not equal.
1687  * @test: The test context object.
1688  * @left: an arbitrary expression that evaluates to a null terminated string.
1689  * @right: an arbitrary expression that evaluates to a null terminated string.
1690  *
1691  * Sets an expectation that the values that @left and @right evaluate to are
1692  * not equal. This is semantically equivalent to
1693  * KUNIT_ASSERT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_ASSERT_TRUE()
1694  * for more information.
1695  */
1696 #define KUNIT_ASSERT_STRNEQ(test, left, right) \
1697         KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
1698
1699 #define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...)                   \
1700         KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,                                \
1701                                           KUNIT_ASSERTION,                     \
1702                                           left,                                \
1703                                           right,                               \
1704                                           fmt,                                 \
1705                                           ##__VA_ARGS__)
1706
1707 /**
1708  * KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err.
1709  * @test: The test context object.
1710  * @ptr: an arbitrary pointer.
1711  *
1712  * Sets an assertion that the value that @ptr evaluates to is not null and not
1713  * an errno stored in a pointer. This is the same as
1714  * KUNIT_EXPECT_NOT_ERR_OR_NULL(), except it causes an assertion failure (see
1715  * KUNIT_ASSERT_TRUE()) when the assertion is not met.
1716  */
1717 #define KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr) \
1718         KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, KUNIT_ASSERTION, ptr)
1719
1720 #define KUNIT_ASSERT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...)                  \
1721         KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,                          \
1722                                                 KUNIT_ASSERTION,               \
1723                                                 ptr,                           \
1724                                                 fmt,                           \
1725                                                 ##__VA_ARGS__)
1726
1727 #endif /* _KUNIT_TEST_H */