lib/kunit/executor.c
Source file repositories/reference/linux-study-clean/lib/kunit/executor.c
File Facts
- System
- Linux kernel
- Corpus path
lib/kunit/executor.c- Extension
.c- Size
- 11880 bytes
- Lines
- 443
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/reboot.hkunit/test.hkunit/attributes.hlinux/glob.hlinux/moduleparam.hexecutor_test.c
Detected Declarations
struct kunit_glob_filterfunction kunit_free_boot_suitesfunction kunit_autorunfunction kunit_parse_glob_filterfunction kunit_filter_glob_testsfunction kunit_suite_for_each_test_casefunction kunit_free_suite_setfunction kunit_filter_suitesfunction kunit_exec_run_testsfunction kunit_exec_list_testsfunction kunit_suite_for_each_test_casefunction kunit_merge_suite_setsfunction kunit_handle_shutdownfunction kunit_run_all_tests
Annotated Snippet
struct kunit_glob_filter {
char *suite_glob;
char *test_glob;
};
/* Split "suite_glob.test_glob" into two. Assumes filter_glob is not empty. */
static int kunit_parse_glob_filter(struct kunit_glob_filter *parsed,
const char *filter_glob)
{
const char *period = strchr(filter_glob, '.');
if (!period) {
parsed->suite_glob = kstrdup(filter_glob, GFP_KERNEL);
if (!parsed->suite_glob)
return -ENOMEM;
parsed->test_glob = NULL;
return 0;
}
parsed->suite_glob = kstrndup(filter_glob, period - filter_glob, GFP_KERNEL);
if (!parsed->suite_glob)
return -ENOMEM;
parsed->test_glob = kstrdup(period + 1, GFP_KERNEL);
if (!parsed->test_glob) {
kfree(parsed->suite_glob);
return -ENOMEM;
}
return 0;
}
/* Create a copy of suite with only tests that match test_glob. */
static struct kunit_suite *
kunit_filter_glob_tests(const struct kunit_suite *const suite, const char *test_glob)
{
int n = 0;
struct kunit_case *filtered, *test_case;
struct kunit_suite *copy;
kunit_suite_for_each_test_case(suite, test_case) {
if (!test_glob || glob_match(test_glob, test_case->name))
++n;
}
if (n == 0)
return NULL;
copy = kmemdup(suite, sizeof(*copy), GFP_KERNEL);
if (!copy)
return ERR_PTR(-ENOMEM);
filtered = kzalloc_objs(*filtered, n + 1);
if (!filtered) {
kfree(copy);
return ERR_PTR(-ENOMEM);
}
n = 0;
kunit_suite_for_each_test_case(suite, test_case) {
if (!test_glob || glob_match(test_glob, test_case->name))
filtered[n++] = *test_case;
}
copy->test_cases = filtered;
return copy;
}
void kunit_free_suite_set(struct kunit_suite_set suite_set)
{
struct kunit_suite * const *suites;
for (suites = suite_set.start; suites < suite_set.end; suites++) {
kfree((*suites)->test_cases);
kfree(*suites);
}
kfree(suite_set.start);
}
/*
* Filter and reallocate test suites. Must return the filtered test suites set
* allocated at a valid virtual address or NULL in case of error.
*/
struct kunit_suite_set
kunit_filter_suites(const struct kunit_suite_set *suite_set,
const char *filter_glob,
char *filters,
char *filter_action,
int *err)
{
Annotation
- Immediate include surface: `linux/reboot.h`, `kunit/test.h`, `kunit/attributes.h`, `linux/glob.h`, `linux/moduleparam.h`, `executor_test.c`.
- Detected declarations: `struct kunit_glob_filter`, `function kunit_free_boot_suites`, `function kunit_autorun`, `function kunit_parse_glob_filter`, `function kunit_filter_glob_tests`, `function kunit_suite_for_each_test_case`, `function kunit_free_suite_set`, `function kunit_filter_suites`, `function kunit_exec_run_tests`, `function kunit_exec_list_tests`.
- 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.