tools/testing/selftests/bpf/prog_tests/fsession_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/fsession_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/fsession_test.c- Extension
.c- Size
- 3039 bytes
- Lines
- 141
- 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.hfsession_test.skel.h
Detected Declarations
function check_resultfunction test_fsession_basicfunction test_fsession_reattachfunction test_fsession_cookiefunction test_fsession_test
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2025 ChinaTelecom */
#include <test_progs.h>
#include "fsession_test.skel.h"
static int check_result(struct fsession_test *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts);
int err, prog_fd;
/* Trigger test function calls */
prog_fd = bpf_program__fd(skel->progs.test1);
err = bpf_prog_test_run_opts(prog_fd, &topts);
if (!ASSERT_OK(err, "test_run_opts err"))
return err;
if (!ASSERT_OK(topts.retval, "test_run_opts retval"))
return topts.retval;
for (int i = 0; i < sizeof(*skel->bss) / sizeof(__u64); i++) {
if (!ASSERT_EQ(((__u64 *)skel->bss)[i], 1, "test_result"))
return -EINVAL;
}
return 0;
}
static void test_fsession_basic(void)
{
struct fsession_test *skel = NULL;
int err;
skel = fsession_test__open();
if (!ASSERT_OK_PTR(skel, "fsession_test__open"))
return;
err = fsession_test__load(skel);
if (err == -EOPNOTSUPP) {
test__skip();
goto cleanup;
}
if (!ASSERT_OK(err, "fsession_test__load"))
goto cleanup;
err = fsession_test__attach(skel);
if (!ASSERT_OK(err, "fsession_attach"))
goto cleanup;
check_result(skel);
cleanup:
fsession_test__destroy(skel);
}
static void test_fsession_reattach(void)
{
struct fsession_test *skel = NULL;
int err;
skel = fsession_test__open();
if (!ASSERT_OK_PTR(skel, "fsession_test__open"))
return;
err = fsession_test__load(skel);
if (err == -EOPNOTSUPP) {
test__skip();
goto cleanup;
}
if (!ASSERT_OK(err, "fsession_test__load"))
goto cleanup;
/* first attach */
err = fsession_test__attach(skel);
if (!ASSERT_OK(err, "fsession_first_attach"))
goto cleanup;
if (check_result(skel))
goto cleanup;
/* detach */
fsession_test__detach(skel);
/* reset counters */
memset(skel->bss, 0, sizeof(*skel->bss));
/* second attach */
err = fsession_test__attach(skel);
if (!ASSERT_OK(err, "fsession_second_attach"))
goto cleanup;
if (check_result(skel))
goto cleanup;
Annotation
- Immediate include surface: `test_progs.h`, `fsession_test.skel.h`.
- Detected declarations: `function check_result`, `function test_fsession_basic`, `function test_fsession_reattach`, `function test_fsession_cookie`, `function test_fsession_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.