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)  * Assertion and expectation serialization 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_ASSERT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define _KUNIT_ASSERT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) struct kunit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) struct string_stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * enum kunit_assert_type - Type of expectation/assertion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * @KUNIT_ASSERTION: Used to denote that a kunit_assert represents an assertion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * @KUNIT_EXPECTATION: Denotes that a kunit_assert represents an expectation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * Used in conjunction with a &struct kunit_assert to denote whether it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * represents an expectation or an assertion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) enum kunit_assert_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	KUNIT_ASSERTION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	KUNIT_EXPECTATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * struct kunit_assert - Data for printing a failed assertion or expectation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * @test: the test case this expectation/assertion is associated with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * @type: the type (either an expectation or an assertion) of this kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * @line: the source code line number that the expectation/assertion is at.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * @file: the file path of the source file that the expectation/assertion is in.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * @message: an optional message to provide additional context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * @format: a function which formats the data in this kunit_assert to a string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * Represents a failed expectation/assertion. Contains all the data necessary to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * format a string to a user reporting the failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct kunit_assert {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	struct kunit *test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	enum kunit_assert_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	int line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	const char *file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	struct va_format message;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	void (*format)(const struct kunit_assert *assert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		       struct string_stream *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * KUNIT_INIT_VA_FMT_NULL - Default initializer for struct va_format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * Used inside a struct initialization block to initialize struct va_format to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * default values where fmt and va are null.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define KUNIT_INIT_VA_FMT_NULL { .fmt = NULL, .va = NULL }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * KUNIT_INIT_ASSERT_STRUCT() - Initializer for a &struct kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * @kunit: The test case that this expectation/assertion is associated with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  * @assert_type: The type (assertion or expectation) of this kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * @fmt: The formatting function which builds a string out of this kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * The base initializer for a &struct kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define KUNIT_INIT_ASSERT_STRUCT(kunit, assert_type, fmt) {		       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	.test = kunit,							       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	.type = assert_type,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	.file = __FILE__,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	.line = __LINE__,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	.message = KUNIT_INIT_VA_FMT_NULL,				       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	.format = fmt							       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) void kunit_base_assert_format(const struct kunit_assert *assert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			      struct string_stream *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) void kunit_assert_print_msg(const struct kunit_assert *assert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			    struct string_stream *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * struct kunit_fail_assert - Represents a plain fail expectation/assertion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * @assert: The parent of this type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * Represents a simple KUNIT_FAIL/KUNIT_ASSERT_FAILURE that always fails.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) struct kunit_fail_assert {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	struct kunit_assert assert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) void kunit_fail_assert_format(const struct kunit_assert *assert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			      struct string_stream *stream);
^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)  * KUNIT_INIT_FAIL_ASSERT_STRUCT() - Initializer for &struct kunit_fail_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * @test: The test case that this expectation/assertion is associated with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  * @type: The type (assertion or expectation) of this kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  * Initializes a &struct kunit_fail_assert. Intended to be used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define KUNIT_INIT_FAIL_ASSERT_STRUCT(test, type) {			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	.assert = KUNIT_INIT_ASSERT_STRUCT(test,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 					   type,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 					   kunit_fail_assert_format)	       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  * struct kunit_unary_assert - Represents a KUNIT_{EXPECT|ASSERT}_{TRUE|FALSE}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * @assert: The parent of this type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * @condition: A string representation of a conditional expression.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * @expected_true: True if of type KUNIT_{EXPECT|ASSERT}_TRUE, false otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * Represents a simple expectation or assertion that simply asserts something is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  * true or false. In other words, represents the expectations:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  * KUNIT_{EXPECT|ASSERT}_{TRUE|FALSE}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct kunit_unary_assert {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	struct kunit_assert assert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	const char *condition;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	bool expected_true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) void kunit_unary_assert_format(const struct kunit_assert *assert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			       struct string_stream *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * KUNIT_INIT_UNARY_ASSERT_STRUCT() - Initializes &struct kunit_unary_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  * @test: The test case that this expectation/assertion is associated with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  * @type: The type (assertion or expectation) of this kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * @cond: A string representation of the expression asserted true or false.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  * @expect_true: True if of type KUNIT_{EXPECT|ASSERT}_TRUE, false otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  * Initializes a &struct kunit_unary_assert. Intended to be used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define KUNIT_INIT_UNARY_ASSERT_STRUCT(test, type, cond, expect_true) {	       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	.assert = KUNIT_INIT_ASSERT_STRUCT(test,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 					   type,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 					   kunit_unary_assert_format),	       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	.condition = cond,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	.expected_true = expect_true					       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * struct kunit_ptr_not_err_assert - An expectation/assertion that a pointer is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  *	not NULL and not a -errno.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * @assert: The parent of this type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  * @text: A string representation of the expression passed to the expectation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * @value: The actual evaluated pointer value of the expression.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * Represents an expectation/assertion that a pointer is not null and is does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * not contain a -errno. (See IS_ERR_OR_NULL().)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct kunit_ptr_not_err_assert {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	struct kunit_assert assert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	const char *text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	const void *value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) void kunit_ptr_not_err_assert_format(const struct kunit_assert *assert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 				     struct string_stream *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  * KUNIT_INIT_PTR_NOT_ERR_ASSERT_STRUCT() - Initializes a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  *	&struct kunit_ptr_not_err_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * @test: The test case that this expectation/assertion is associated with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  * @type: The type (assertion or expectation) of this kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * @txt: A string representation of the expression passed to the expectation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  * @val: The actual evaluated pointer value of the expression.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  * Initializes a &struct kunit_ptr_not_err_assert. Intended to be used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) #define KUNIT_INIT_PTR_NOT_ERR_STRUCT(test, type, txt, val) {		       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	.assert = KUNIT_INIT_ASSERT_STRUCT(test,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 					   type,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 					   kunit_ptr_not_err_assert_format),   \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	.text = txt,							       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	.value = val							       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  * struct kunit_binary_assert - An expectation/assertion that compares two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  *	non-pointer values (for example, KUNIT_EXPECT_EQ(test, 1 + 1, 2)).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  * @assert: The parent of this type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * @operation: A string representation of the comparison operator (e.g. "==").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * @left_text: A string representation of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  * @left_value: The actual evaluated value of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * @right_text: A string representation of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  * @right_value: The actual evaluated value of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  * Represents an expectation/assertion that compares two non-pointer values. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  * example, to expect that 1 + 1 == 2, you can use the expectation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  * KUNIT_EXPECT_EQ(test, 1 + 1, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct kunit_binary_assert {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	struct kunit_assert assert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	const char *operation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	const char *left_text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	long long left_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	const char *right_text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	long long right_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) void kunit_binary_assert_format(const struct kunit_assert *assert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 				struct string_stream *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  * KUNIT_INIT_BINARY_ASSERT_STRUCT() - Initializes a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  *	&struct kunit_binary_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  * @test: The test case that this expectation/assertion is associated with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  * @type: The type (assertion or expectation) of this kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  * @op_str: A string representation of the comparison operator (e.g. "==").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  * @left_str: A string representation of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  * @left_val: The actual evaluated value of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  * @right_str: A string representation of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  * @right_val: The actual evaluated value of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  * Initializes a &struct kunit_binary_assert. Intended to be used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) #define KUNIT_INIT_BINARY_ASSERT_STRUCT(test,				       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 					type,				       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 					op_str,				       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 					left_str,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 					left_val,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 					right_str,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 					right_val) {			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	.assert = KUNIT_INIT_ASSERT_STRUCT(test,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 					   type,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 					   kunit_binary_assert_format),	       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	.operation = op_str,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	.left_text = left_str,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	.left_value = left_val,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	.right_text = right_str,					       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	.right_value = right_val					       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  * struct kunit_binary_ptr_assert - An expectation/assertion that compares two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  *	pointer values (for example, KUNIT_EXPECT_PTR_EQ(test, foo, bar)).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)  * @assert: The parent of this type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)  * @operation: A string representation of the comparison operator (e.g. "==").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)  * @left_text: A string representation of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)  * @left_value: The actual evaluated value of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)  * @right_text: A string representation of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)  * @right_value: The actual evaluated value of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)  * Represents an expectation/assertion that compares two pointer values. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)  * example, to expect that foo and bar point to the same thing, you can use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)  * expectation KUNIT_EXPECT_PTR_EQ(test, foo, bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) struct kunit_binary_ptr_assert {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	struct kunit_assert assert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	const char *operation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	const char *left_text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	const void *left_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	const char *right_text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	const void *right_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) void kunit_binary_ptr_assert_format(const struct kunit_assert *assert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 				    struct string_stream *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  * KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT() - Initializes a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  *	&struct kunit_binary_ptr_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  * @test: The test case that this expectation/assertion is associated with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  * @type: The type (assertion or expectation) of this kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)  * @op_str: A string representation of the comparison operator (e.g. "==").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)  * @left_str: A string representation of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  * @left_val: The actual evaluated value of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)  * @right_str: A string representation of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  * @right_val: The actual evaluated value of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  * Initializes a &struct kunit_binary_ptr_assert. Intended to be used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  * KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) #define KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT(test,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 					    type,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 					    op_str,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 					    left_str,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 					    left_val,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 					    right_str,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 					    right_val) {		       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	.assert = KUNIT_INIT_ASSERT_STRUCT(test,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 					   type,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 					   kunit_binary_ptr_assert_format),    \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	.operation = op_str,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	.left_text = left_str,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	.left_value = left_val,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	.right_text = right_str,					       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	.right_value = right_val					       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)  * struct kunit_binary_str_assert - An expectation/assertion that compares two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)  *	string values (for example, KUNIT_EXPECT_STREQ(test, foo, "bar")).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)  * @assert: The parent of this type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)  * @operation: A string representation of the comparison operator (e.g. "==").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)  * @left_text: A string representation of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)  * @left_value: The actual evaluated value of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)  * @right_text: A string representation of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)  * @right_value: The actual evaluated value of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)  * Represents an expectation/assertion that compares two string values. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)  * example, to expect that the string in foo is equal to "bar", you can use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)  * expectation KUNIT_EXPECT_STREQ(test, foo, "bar");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) struct kunit_binary_str_assert {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	struct kunit_assert assert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	const char *operation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	const char *left_text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	const char *left_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	const char *right_text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	const char *right_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) void kunit_binary_str_assert_format(const struct kunit_assert *assert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 				    struct string_stream *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)  * KUNIT_INIT_BINARY_STR_ASSERT_STRUCT() - Initializes a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  *	&struct kunit_binary_str_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  * @test: The test case that this expectation/assertion is associated with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  * @type: The type (assertion or expectation) of this kunit_assert.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  * @op_str: A string representation of the comparison operator (e.g. "==").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)  * @left_str: A string representation of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)  * @left_val: The actual evaluated value of the expression in the left slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)  * @right_str: A string representation of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)  * @right_val: The actual evaluated value of the expression in the right slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)  * Initializes a &struct kunit_binary_str_assert. Intended to be used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)  * KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) #define KUNIT_INIT_BINARY_STR_ASSERT_STRUCT(test,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 					    type,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 					    op_str,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 					    left_str,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 					    left_val,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 					    right_str,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 					    right_val) {		       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	.assert = KUNIT_INIT_ASSERT_STRUCT(test,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 					   type,			       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 					   kunit_binary_str_assert_format),    \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	.operation = op_str,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	.left_text = left_str,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	.left_value = left_val,						       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	.right_text = right_str,					       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	.right_value = right_val					       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) #endif /*  _KUNIT_ASSERT_H */