Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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