tools/testing/selftests/bpf/prog_tests/dummy_st_ops.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/dummy_st_ops.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/dummy_st_ops.c- Extension
.c- Size
- 5052 bytes
- Lines
- 192
- 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.hdummy_st_ops_success.skel.hdummy_st_ops_fail.skel.htrace_dummy_st_ops.skel.h
Detected Declarations
struct bpf_dummy_ops_statefunction test_dummy_st_ops_attachfunction test_dummy_init_ret_valuefunction test_dummy_init_ptr_argfunction test_dummy_multiple_argsfunction test_dummy_sleepablefunction bpf_prog_test_run_optsfunction test_dummy_st_ops
Annotated Snippet
struct bpf_dummy_ops_state {
int val;
};
static void test_dummy_st_ops_attach(void)
{
struct dummy_st_ops_success *skel;
struct bpf_link *link;
skel = dummy_st_ops_success__open_and_load();
if (!ASSERT_OK_PTR(skel, "dummy_st_ops_load"))
return;
link = bpf_map__attach_struct_ops(skel->maps.dummy_1);
ASSERT_EQ(libbpf_get_error(link), -EOPNOTSUPP, "dummy_st_ops_attach");
dummy_st_ops_success__destroy(skel);
}
static void test_dummy_init_ret_value(void)
{
__u64 args[1] = {0};
LIBBPF_OPTS(bpf_test_run_opts, attr,
.ctx_in = args,
.ctx_size_in = sizeof(args),
);
struct dummy_st_ops_success *skel;
int fd, err;
skel = dummy_st_ops_success__open_and_load();
if (!ASSERT_OK_PTR(skel, "dummy_st_ops_load"))
return;
fd = bpf_program__fd(skel->progs.test_1);
err = bpf_prog_test_run_opts(fd, &attr);
ASSERT_OK(err, "test_run");
ASSERT_EQ(attr.retval, 0xf2f3f4f5, "test_ret");
dummy_st_ops_success__destroy(skel);
}
static void test_dummy_init_ptr_arg(void)
{
int exp_retval = 0xbeef;
struct bpf_dummy_ops_state in_state = {
.val = exp_retval,
};
__u64 args[1] = {(unsigned long)&in_state};
LIBBPF_OPTS(bpf_test_run_opts, attr,
.ctx_in = args,
.ctx_size_in = sizeof(args),
);
struct trace_dummy_st_ops *trace_skel;
struct dummy_st_ops_success *skel;
int fd, err;
skel = dummy_st_ops_success__open_and_load();
if (!ASSERT_OK_PTR(skel, "dummy_st_ops_load"))
return;
fd = bpf_program__fd(skel->progs.test_1);
trace_skel = trace_dummy_st_ops__open();
if (!ASSERT_OK_PTR(trace_skel, "trace_dummy_st_ops__open"))
goto done;
err = bpf_program__set_attach_target(trace_skel->progs.fentry_test_1,
fd, "test_1");
if (!ASSERT_OK(err, "set_attach_target(fentry_test_1)"))
goto done;
err = trace_dummy_st_ops__load(trace_skel);
if (!ASSERT_OK(err, "load(trace_skel)"))
goto done;
err = trace_dummy_st_ops__attach(trace_skel);
if (!ASSERT_OK(err, "attach(trace_skel)"))
goto done;
err = bpf_prog_test_run_opts(fd, &attr);
ASSERT_OK(err, "test_run");
ASSERT_EQ(in_state.val, 0x5a, "test_ptr_ret");
ASSERT_EQ(attr.retval, exp_retval, "test_ret");
ASSERT_EQ(trace_skel->bss->val, exp_retval, "fentry_val");
done:
dummy_st_ops_success__destroy(skel);
trace_dummy_st_ops__destroy(trace_skel);
}
Annotation
- Immediate include surface: `test_progs.h`, `dummy_st_ops_success.skel.h`, `dummy_st_ops_fail.skel.h`, `trace_dummy_st_ops.skel.h`.
- Detected declarations: `struct bpf_dummy_ops_state`, `function test_dummy_st_ops_attach`, `function test_dummy_init_ret_value`, `function test_dummy_init_ptr_arg`, `function test_dummy_multiple_args`, `function test_dummy_sleepable`, `function bpf_prog_test_run_opts`, `function test_dummy_st_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.