tools/testing/selftests/bpf/prog_tests/sleepable_tracepoints.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/sleepable_tracepoints.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/sleepable_tracepoints.c- Extension
.c- Size
- 4079 bytes
- Lines
- 143
- 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.hunistd.htest_sleepable_tracepoints.skel.htest_sleepable_tracepoints_fail.skel.h
Detected Declarations
function run_testfunction run_auto_attach_testfunction test_attach_onlyfunction test_attach_rejectfunction test_raw_tp_barefunction test_tp_barefunction test_test_runfunction test_test_run_on_cpu_rejectfunction test_sleepable_tracepoints
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
#include <test_progs.h>
#include <unistd.h>
#include "test_sleepable_tracepoints.skel.h"
#include "test_sleepable_tracepoints_fail.skel.h"
static void run_test(struct test_sleepable_tracepoints *skel)
{
char buf[PATH_MAX] = "/";
skel->bss->target_pid = getpid();
skel->bss->prog_triggered = 0;
skel->bss->err = 0;
skel->bss->copied_byte = 0;
syscall(__NR_getcwd, buf, sizeof(buf));
ASSERT_EQ(skel->bss->prog_triggered, 1, "prog_triggered");
ASSERT_EQ(skel->bss->err, 0, "err");
ASSERT_EQ(skel->bss->copied_byte, '/', "copied_byte");
}
static void run_auto_attach_test(struct bpf_program *prog,
struct test_sleepable_tracepoints *skel)
{
struct bpf_link *link;
link = bpf_program__attach(prog);
if (!ASSERT_OK_PTR(link, "prog_attach"))
return;
run_test(skel);
bpf_link__destroy(link);
}
static void test_attach_only(struct bpf_program *prog)
{
struct bpf_link *link;
link = bpf_program__attach(prog);
if (ASSERT_OK_PTR(link, "attach"))
bpf_link__destroy(link);
}
static void test_attach_reject(struct bpf_program *prog)
{
struct bpf_link *link;
link = bpf_program__attach(prog);
if (!ASSERT_ERR_PTR(link, "attach_should_fail"))
bpf_link__destroy(link);
}
static void test_raw_tp_bare(struct test_sleepable_tracepoints *skel)
{
struct bpf_link *link;
link = bpf_program__attach_raw_tracepoint(skel->progs.handle_raw_tp_bare,
"sys_enter");
if (ASSERT_OK_PTR(link, "attach"))
bpf_link__destroy(link);
}
static void test_tp_bare(struct test_sleepable_tracepoints *skel)
{
struct bpf_link *link;
link = bpf_program__attach_tracepoint(skel->progs.handle_tp_bare,
"syscalls", "sys_enter_getcwd");
if (ASSERT_OK_PTR(link, "attach"))
bpf_link__destroy(link);
}
static void test_test_run(struct test_sleepable_tracepoints *skel)
{
__u64 args[2] = {0x1234ULL, 0x5678ULL};
LIBBPF_OPTS(bpf_test_run_opts, topts,
.ctx_in = args,
.ctx_size_in = sizeof(args),
);
int fd, err;
fd = bpf_program__fd(skel->progs.handle_test_run);
err = bpf_prog_test_run_opts(fd, &topts);
ASSERT_OK(err, "test_run");
ASSERT_EQ(topts.retval, args[0] + args[1], "test_run_retval");
}
Annotation
- Immediate include surface: `test_progs.h`, `unistd.h`, `test_sleepable_tracepoints.skel.h`, `test_sleepable_tracepoints_fail.skel.h`.
- Detected declarations: `function run_test`, `function run_auto_attach_test`, `function test_attach_only`, `function test_attach_reject`, `function test_raw_tp_bare`, `function test_tp_bare`, `function test_test_run`, `function test_test_run_on_cpu_reject`, `function test_sleepable_tracepoints`.
- 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.