tools/testing/selftests/bpf/testing_helpers.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/testing_helpers.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/testing_helpers.c- Extension
.c- Size
- 11134 bytes
- Lines
- 537
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ctype.hstdlib.hstring.herrno.hsys/mman.halloca.hbpf/bpf.hbpf/libbpf.hdisasm.htest_progs.htesting_helpers.hlinux/membarrier.h
Detected Declarations
function parse_num_listfunction do_insert_testfunction insert_testfunction parse_test_list_filefunction parse_test_listfunction link_info_prog_idfunction testing_prog_flagsfunction bpf_prog_test_loadfunction bpf_test_load_programfunction read_perf_max_sample_freqfunction finit_modulefunction delete_modulefunction try_unload_modulefunction unload_modulefunction __load_modulefunction load_module_paramsfunction load_modulefunction unload_bpf_testmodfunction load_bpf_testmodfunction synchronize_rcufunction get_xlated_programfunction is_jit_enabledfunction stack_mprotect
Annotated Snippet
if (!parsing_end && *next == '-') {
s = next + 1;
parsing_end = true;
continue;
} else if (*next == ',') {
parsing_end = false;
s = next + 1;
end = num;
} else if (*next == '\0') {
parsing_end = false;
s = next;
end = num;
} else {
return -EINVAL;
}
if (start > end)
return -EINVAL;
if (end + 1 > set_len) {
new_len = end + 1;
tmp = realloc(set, new_len);
if (!tmp) {
free(set);
return -ENOMEM;
}
for (i = set_len; i < start; i++)
tmp[i] = false;
set = tmp;
set_len = new_len;
}
for (i = start; i <= end; i++)
set[i] = true;
}
if (!set || parsing_end)
return -EINVAL;
*num_set = set;
*num_set_len = set_len;
return 0;
}
static int do_insert_test(struct test_filter_set *set,
char *test_str,
char *subtest_str)
{
struct test_filter *tmp, *test;
char **ctmp;
int i;
for (i = 0; i < set->cnt; i++) {
test = &set->tests[i];
if (strcmp(test_str, test->name) == 0) {
free(test_str);
goto subtest;
}
}
tmp = realloc(set->tests, sizeof(*test) * (set->cnt + 1));
if (!tmp)
return -ENOMEM;
set->tests = tmp;
test = &set->tests[set->cnt];
test->name = test_str;
test->subtests = NULL;
test->subtest_cnt = 0;
set->cnt++;
subtest:
if (!subtest_str)
return 0;
for (i = 0; i < test->subtest_cnt; i++) {
if (strcmp(subtest_str, test->subtests[i]) == 0) {
free(subtest_str);
return 0;
}
}
ctmp = realloc(test->subtests,
sizeof(*test->subtests) * (test->subtest_cnt + 1));
if (!ctmp)
return -ENOMEM;
Annotation
- Immediate include surface: `ctype.h`, `stdlib.h`, `string.h`, `errno.h`, `sys/mman.h`, `alloca.h`, `bpf/bpf.h`, `bpf/libbpf.h`.
- Detected declarations: `function parse_num_list`, `function do_insert_test`, `function insert_test`, `function parse_test_list_file`, `function parse_test_list`, `function link_info_prog_id`, `function testing_prog_flags`, `function bpf_prog_test_load`, `function bpf_test_load_program`, `function read_perf_max_sample_freq`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.