tools/testing/selftests/bpf/prog_tests/kprobe_multi_testmod_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/kprobe_multi_testmod_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/kprobe_multi_testmod_test.c- Extension
.c- Size
- 2763 bytes
- Lines
- 96
- 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.hkprobe_multi.skel.htrace_helpers.hbpf/libbpf_internal.h
Detected Declarations
function kprobe_multi_testmod_checkfunction test_testmod_attach_apifunction test_testmod_attach_api_addrsfunction test_testmod_attach_api_symsfunction serial_test_kprobe_multi_testmod_test
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <test_progs.h>
#include "kprobe_multi.skel.h"
#include "trace_helpers.h"
#include "bpf/libbpf_internal.h"
static struct ksyms *ksyms;
static void kprobe_multi_testmod_check(struct kprobe_multi *skel)
{
ASSERT_EQ(skel->bss->kprobe_testmod_test1_result, 1, "kprobe_test1_result");
ASSERT_EQ(skel->bss->kprobe_testmod_test2_result, 1, "kprobe_test2_result");
ASSERT_EQ(skel->bss->kprobe_testmod_test3_result, 1, "kprobe_test3_result");
ASSERT_EQ(skel->bss->kretprobe_testmod_test1_result, 1, "kretprobe_test1_result");
ASSERT_EQ(skel->bss->kretprobe_testmod_test2_result, 1, "kretprobe_test2_result");
ASSERT_EQ(skel->bss->kretprobe_testmod_test3_result, 1, "kretprobe_test3_result");
}
static void test_testmod_attach_api(struct bpf_kprobe_multi_opts *opts)
{
struct kprobe_multi *skel = NULL;
skel = kprobe_multi__open_and_load();
if (!ASSERT_OK_PTR(skel, "fentry_raw_skel_load"))
return;
skel->bss->pid = getpid();
skel->links.test_kprobe_testmod = bpf_program__attach_kprobe_multi_opts(
skel->progs.test_kprobe_testmod,
NULL, opts);
if (!skel->links.test_kprobe_testmod)
goto cleanup;
opts->retprobe = true;
skel->links.test_kretprobe_testmod = bpf_program__attach_kprobe_multi_opts(
skel->progs.test_kretprobe_testmod,
NULL, opts);
if (!skel->links.test_kretprobe_testmod)
goto cleanup;
ASSERT_OK(trigger_module_test_read(1), "trigger_read");
kprobe_multi_testmod_check(skel);
cleanup:
kprobe_multi__destroy(skel);
}
static void test_testmod_attach_api_addrs(void)
{
LIBBPF_OPTS(bpf_kprobe_multi_opts, opts);
unsigned long long addrs[3];
addrs[0] = ksym_get_addr_local(ksyms, "bpf_testmod_fentry_test1");
ASSERT_NEQ(addrs[0], 0, "ksym_get_addr_local");
addrs[1] = ksym_get_addr_local(ksyms, "bpf_testmod_fentry_test2");
ASSERT_NEQ(addrs[1], 0, "ksym_get_addr_local");
addrs[2] = ksym_get_addr_local(ksyms, "bpf_testmod_fentry_test3");
ASSERT_NEQ(addrs[2], 0, "ksym_get_addr_local");
opts.addrs = (const unsigned long *) addrs;
opts.cnt = ARRAY_SIZE(addrs);
test_testmod_attach_api(&opts);
}
static void test_testmod_attach_api_syms(void)
{
LIBBPF_OPTS(bpf_kprobe_multi_opts, opts);
const char *syms[3] = {
"bpf_testmod_fentry_test1",
"bpf_testmod_fentry_test2",
"bpf_testmod_fentry_test3",
};
opts.syms = syms;
opts.cnt = ARRAY_SIZE(syms);
test_testmod_attach_api(&opts);
}
void serial_test_kprobe_multi_testmod_test(void)
{
ksyms = load_kallsyms_local();
if (!ASSERT_OK_PTR(ksyms, "load_kallsyms_local"))
return;
if (test__start_subtest("testmod_attach_api_syms"))
test_testmod_attach_api_syms();
Annotation
- Immediate include surface: `test_progs.h`, `kprobe_multi.skel.h`, `trace_helpers.h`, `bpf/libbpf_internal.h`.
- Detected declarations: `function kprobe_multi_testmod_check`, `function test_testmod_attach_api`, `function test_testmod_attach_api_addrs`, `function test_testmod_attach_api_syms`, `function serial_test_kprobe_multi_testmod_test`.
- 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.