include/kunit/assert.h
Source file repositories/reference/linux-study-clean/include/kunit/assert.h
File Facts
- System
- Linux kernel
- Corpus path
include/kunit/assert.h- Extension
.h- Size
- 8052 bytes
- Lines
- 233
- Domain
- Repository Root And Misc
- Bucket
- include
- Inferred role
- Repository Root And Misc: implementation source
- Status
- source implementation candidate
Why This File Exists
Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.
- Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/printk.h
Detected Declarations
struct kunitstruct string_streamstruct kunit_locstruct kunit_assertstruct kunit_fail_assertstruct kunit_unary_assertstruct kunit_ptr_not_err_assertstruct kunit_binary_assert_textstruct kunit_binary_assertstruct kunit_binary_ptr_assertstruct kunit_binary_str_assertstruct kunit_mem_assertenum kunit_assert_type
Annotated Snippet
struct kunit_loc {
int line;
const char *file;
};
#define KUNIT_CURRENT_LOC { .file = __FILE__, .line = __LINE__ }
/**
* struct kunit_assert - Data for printing a failed assertion or expectation.
*
* Represents a failed expectation/assertion. Contains all the data necessary to
* format a string to a user reporting the failure.
*/
struct kunit_assert {};
typedef void (*assert_format_t)(const struct kunit_assert *assert,
const struct va_format *message,
struct string_stream *stream);
void kunit_assert_prologue(const struct kunit_loc *loc,
enum kunit_assert_type type,
struct string_stream *stream);
/**
* struct kunit_fail_assert - Represents a plain fail expectation/assertion.
* @assert: The parent of this type.
*
* Represents a simple KUNIT_FAIL/KUNIT_FAIL_AND_ABORT that always fails.
*/
struct kunit_fail_assert {
struct kunit_assert assert;
};
void kunit_fail_assert_format(const struct kunit_assert *assert,
const struct va_format *message,
struct string_stream *stream);
/**
* struct kunit_unary_assert - Represents a KUNIT_{EXPECT|ASSERT}_{TRUE|FALSE}
* @assert: The parent of this type.
* @condition: A string representation of a conditional expression.
* @expected_true: True if of type KUNIT_{EXPECT|ASSERT}_TRUE, false otherwise.
*
* Represents a simple expectation or assertion that simply asserts something is
* true or false. In other words, represents the expectations:
* KUNIT_{EXPECT|ASSERT}_{TRUE|FALSE}
*/
struct kunit_unary_assert {
struct kunit_assert assert;
const char *condition;
bool expected_true;
};
void kunit_unary_assert_format(const struct kunit_assert *assert,
const struct va_format *message,
struct string_stream *stream);
/**
* struct kunit_ptr_not_err_assert - An expectation/assertion that a pointer is
* not NULL and not a -errno.
* @assert: The parent of this type.
* @text: A string representation of the expression passed to the expectation.
* @value: The actual evaluated pointer value of the expression.
*
* Represents an expectation/assertion that a pointer is not null and is does
* not contain a -errno. (See IS_ERR_OR_NULL().)
*/
struct kunit_ptr_not_err_assert {
struct kunit_assert assert;
const char *text;
const void *value;
};
void kunit_ptr_not_err_assert_format(const struct kunit_assert *assert,
const struct va_format *message,
struct string_stream *stream);
/**
* struct kunit_binary_assert_text - holds strings for &struct
* kunit_binary_assert and friends to try and make the structs smaller.
* @operation: A string representation of the comparison operator (e.g. "==").
* @left_text: A string representation of the left expression (e.g. "2+2").
* @right_text: A string representation of the right expression (e.g. "2+2").
*/
struct kunit_binary_assert_text {
const char *operation;
const char *left_text;
const char *right_text;
};
Annotation
- Immediate include surface: `linux/err.h`, `linux/printk.h`.
- Detected declarations: `struct kunit`, `struct string_stream`, `struct kunit_loc`, `struct kunit_assert`, `struct kunit_fail_assert`, `struct kunit_unary_assert`, `struct kunit_ptr_not_err_assert`, `struct kunit_binary_assert_text`, `struct kunit_binary_assert`, `struct kunit_binary_ptr_assert`.
- Atlas domain: Repository Root And Misc / include.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.