lib/tests/stackinit_kunit.c
Source file repositories/reference/linux-study-clean/lib/tests/stackinit_kunit.c
File Facts
- System
- Linux kernel
- Corpus path
lib/tests/stackinit_kunit.c- Extension
.c- Size
- 18591 bytes
- Lines
- 587
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: implementation source
- Status
- source implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hlinux/init.hlinux/kernel.hlinux/module.hlinux/string.h
Detected Declarations
struct test_packedstruct test_small_holestruct test_big_holestruct test_trailing_holestruct test_userstruct big_structfunction stackinit_range_containsfunction __leaf_switch_nonefunction leaf_switch_1_nonefunction leaf_switch_2_none
Annotated Snippet
struct test_packed {
unsigned long one;
unsigned long two;
unsigned long three;
unsigned long four;
};
/* Simple structure with padding likely to be covered by compiler. */
struct test_small_hole {
size_t one;
char two;
/* 3 byte padding hole here. */
int three;
unsigned long four;
};
/* Trigger unhandled padding in a structure. */
struct test_big_hole {
u8 one;
u8 two;
u8 three;
/* 61 byte padding hole here. */
u8 four __aligned(64);
} __aligned(64);
struct test_trailing_hole {
char *one;
char *two;
char *three;
char four;
/* "sizeof(unsigned long) - 1" byte padding hole here. */
};
/* Test if STRUCTLEAK is clearing structs with __user fields. */
struct test_user {
u8 one;
unsigned long two;
char __user *three;
unsigned long four;
};
/* No padding: all members are the same size. */
union test_same_sizes {
unsigned long one;
unsigned long two;
unsigned long three;
unsigned long four;
};
/* Mismatched sizes, with one and two being small */
union test_small_start {
char one:1;
char two;
short three;
unsigned long four;
struct big_struct {
unsigned long array[FILL_SIZE_ARRAY];
} big;
};
/* Mismatched sizes, with three and four being small */
union test_small_end {
short one;
unsigned long two;
char three:1;
char four;
};
#define ALWAYS_PASS WANT_SUCCESS
#define ALWAYS_FAIL XFAIL
#ifdef CONFIG_INIT_STACK_NONE
# define USER_PASS XFAIL
# define BYREF_PASS XFAIL
# define STRONG_PASS XFAIL
#else
# define USER_PASS WANT_SUCCESS
# define BYREF_PASS WANT_SUCCESS
# define STRONG_PASS WANT_SUCCESS
#endif
#define DEFINE_SCALAR_TEST(name, init, xfail) \
DEFINE_TEST(name ## _ ## init, name, SCALAR, \
init, xfail)
#define DEFINE_SCALAR_TESTS(init, xfail) \
DEFINE_SCALAR_TEST(u8, init, xfail); \
DEFINE_SCALAR_TEST(u16, init, xfail); \
DEFINE_SCALAR_TEST(u32, init, xfail); \
DEFINE_SCALAR_TEST(u64, init, xfail); \
Annotation
- Immediate include surface: `kunit/test.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/string.h`.
- Detected declarations: `struct test_packed`, `struct test_small_hole`, `struct test_big_hole`, `struct test_trailing_hole`, `struct test_user`, `struct big_struct`, `function stackinit_range_contains`, `function __leaf_switch_none`, `function leaf_switch_1_none`, `function leaf_switch_2_none`.
- Atlas domain: Kernel Services / lib.
- 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.