tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c- Extension
.c- Size
- 2489 bytes
- Lines
- 101
- 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.hstruct_ops_private_stack.skel.hstruct_ops_private_stack_fail.skel.hstruct_ops_private_stack_recur.skel.h
Detected Declarations
function test_private_stackfunction test_private_stack_failfunction test_private_stack_recurfunction __test_struct_ops_private_stackfunction __test_struct_ops_private_stackfunction test_struct_ops_private_stack
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <test_progs.h>
#include "struct_ops_private_stack.skel.h"
#include "struct_ops_private_stack_fail.skel.h"
#include "struct_ops_private_stack_recur.skel.h"
#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)
static void test_private_stack(void)
{
struct struct_ops_private_stack *skel;
struct bpf_link *link;
int err;
skel = struct_ops_private_stack__open();
if (!ASSERT_OK_PTR(skel, "struct_ops_private_stack__open"))
return;
err = struct_ops_private_stack__load(skel);
if (!ASSERT_OK(err, "struct_ops_private_stack__load"))
goto cleanup;
link = bpf_map__attach_struct_ops(skel->maps.testmod_1);
if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
goto cleanup;
ASSERT_OK(trigger_module_test_read(256), "trigger_read");
ASSERT_EQ(skel->bss->val_i, 3, "val_i");
ASSERT_EQ(skel->bss->val_j, 8, "val_j");
bpf_link__destroy(link);
cleanup:
struct_ops_private_stack__destroy(skel);
}
static void test_private_stack_fail(void)
{
struct struct_ops_private_stack_fail *skel;
int err;
skel = struct_ops_private_stack_fail__open();
if (!ASSERT_OK_PTR(skel, "struct_ops_private_stack_fail__open"))
return;
err = struct_ops_private_stack_fail__load(skel);
ASSERT_ERR(err, "struct_ops_private_stack_fail__load");
struct_ops_private_stack_fail__destroy(skel);
}
static void test_private_stack_recur(void)
{
struct struct_ops_private_stack_recur *skel;
struct bpf_link *link;
int err;
skel = struct_ops_private_stack_recur__open();
if (!ASSERT_OK_PTR(skel, "struct_ops_private_stack_recur__open"))
return;
err = struct_ops_private_stack_recur__load(skel);
if (!ASSERT_OK(err, "struct_ops_private_stack_recur__load"))
goto cleanup;
link = bpf_map__attach_struct_ops(skel->maps.testmod_1);
if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
goto cleanup;
ASSERT_OK(trigger_module_test_read(256), "trigger_read");
ASSERT_EQ(skel->bss->val_j, 3, "val_j");
bpf_link__destroy(link);
cleanup:
struct_ops_private_stack_recur__destroy(skel);
}
static void __test_struct_ops_private_stack(void)
{
if (test__start_subtest("private_stack"))
test_private_stack();
if (test__start_subtest("private_stack_fail"))
test_private_stack_fail();
if (test__start_subtest("private_stack_recur"))
test_private_stack_recur();
}
#else
Annotation
- Immediate include surface: `test_progs.h`, `struct_ops_private_stack.skel.h`, `struct_ops_private_stack_fail.skel.h`, `struct_ops_private_stack_recur.skel.h`.
- Detected declarations: `function test_private_stack`, `function test_private_stack_fail`, `function test_private_stack_recur`, `function __test_struct_ops_private_stack`, `function __test_struct_ops_private_stack`, `function test_struct_ops_private_stack`.
- 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.