tools/testing/selftests/bpf/prog_tests/map_init.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/map_init.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/map_init.c- Extension
.c- Size
- 10237 bytes
- Lines
- 407
- 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
test_progs.htest_map_init.skel.h
Detected Declarations
struct bpf_common_attr_fakefunction map_populatefunction prog_run_insert_elemfunction check_values_one_cpufunction test_pcpu_map_initfunction test_pcpu_lru_map_initfunction test_map_initfunction test_map_createfunction test_map_create_arrayfunction test_invalid_vmlinux_value_type_id_struct_opsfunction test_invalid_vmlinux_value_type_id_kv_type_idfunction test_invalid_value_type_idfunction test_invalid_map_extrafunction test_invalid_numa_nodefunction test_invalid_map_typefunction test_invalid_token_fdfunction test_invalid_map_namefunction test_invalid_btf_fdfunction test_excl_prog_hash_size_1function test_excl_prog_hash_size_2function test_common_attr_paddingfunction test_map_create_failure
Annotated Snippet
struct bpf_common_attr_fake {
__u8 attrs[offsetofend(struct bpf_common_attr, log_true_size)];
__u32 pad;
} attr_common = {
.pad = 1,
};
union bpf_attr attr = {
.map_type = BPF_MAP_TYPE_ARRAY,
.key_size = 4,
.value_size = 4,
.max_entries = 1,
};
int fd;
fd = syscall(__NR_bpf, BPF_MAP_CREATE | BPF_COMMON_ATTRS, &attr, sizeof(attr), &attr_common,
sizeof(attr_common));
if (!ASSERT_LT(fd, 0, "syscall"))
close(fd);
else
ASSERT_EQ(errno, E2BIG, "errno");
}
void test_map_create_failure(void)
{
if (test__start_subtest("invalid_vmlinux_value_type_id_struct_ops"))
test_invalid_vmlinux_value_type_id_struct_ops();
if (test__start_subtest("invalid_vmlinux_value_type_id_kv_type_id"))
test_invalid_vmlinux_value_type_id_kv_type_id();
if (test__start_subtest("invalid_value_type_id"))
test_invalid_value_type_id();
if (test__start_subtest("invalid_map_extra"))
test_invalid_map_extra();
if (test__start_subtest("invalid_numa_node"))
test_invalid_numa_node();
if (test__start_subtest("invalid_map_type"))
test_invalid_map_type();
if (test__start_subtest("invalid_token_fd"))
test_invalid_token_fd();
if (test__start_subtest("invalid_map_name"))
test_invalid_map_name();
if (test__start_subtest("invalid_btf_fd"))
test_invalid_btf_fd();
if (test__start_subtest("invalid_excl_prog_hash_size_1"))
test_excl_prog_hash_size_1();
if (test__start_subtest("invalid_excl_prog_hash_size_2"))
test_excl_prog_hash_size_2();
if (test__start_subtest("common_attr_padding"))
test_common_attr_padding();
}
Annotation
- Immediate include surface: `test_progs.h`, `test_map_init.skel.h`.
- Detected declarations: `struct bpf_common_attr_fake`, `function map_populate`, `function prog_run_insert_elem`, `function check_values_one_cpu`, `function test_pcpu_map_init`, `function test_pcpu_lru_map_init`, `function test_map_init`, `function test_map_create`, `function test_map_create_array`, `function test_invalid_vmlinux_value_type_id_struct_ops`.
- 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.