tools/testing/selftests/bpf/prog_tests/map_ops.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/map_ops.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/map_ops.c- Extension
.c- Size
- 3126 bytes
- Lines
- 163
- 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
errno.hsys/syscall.hunistd.htest_map_ops.skel.htest_progs.h
Detected Declarations
function map_updatefunction map_deletefunction map_pushfunction map_popfunction map_peekfunction map_for_each_passfunction map_for_each_failfunction setupfunction teardownfunction map_ops_update_delete_subtestfunction map_ops_push_peek_pop_subtestfunction map_ops_for_each_subtestfunction test_map_ops
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */
#include <errno.h>
#include <sys/syscall.h>
#include <unistd.h>
#include "test_map_ops.skel.h"
#include "test_progs.h"
static void map_update(void)
{
(void)syscall(__NR_getpid);
}
static void map_delete(void)
{
(void)syscall(__NR_getppid);
}
static void map_push(void)
{
(void)syscall(__NR_getuid);
}
static void map_pop(void)
{
(void)syscall(__NR_geteuid);
}
static void map_peek(void)
{
(void)syscall(__NR_getgid);
}
static void map_for_each_pass(void)
{
(void)syscall(__NR_gettid);
}
static void map_for_each_fail(void)
{
(void)syscall(__NR_getpgid);
}
static int setup(struct test_map_ops **skel)
{
int err = 0;
if (!skel)
return -1;
*skel = test_map_ops__open();
if (!ASSERT_OK_PTR(*skel, "test_map_ops__open"))
return -1;
(*skel)->rodata->pid = getpid();
err = test_map_ops__load(*skel);
if (!ASSERT_OK(err, "test_map_ops__load"))
return err;
err = test_map_ops__attach(*skel);
if (!ASSERT_OK(err, "test_map_ops__attach"))
return err;
return err;
}
static void teardown(struct test_map_ops **skel)
{
if (skel && *skel)
test_map_ops__destroy(*skel);
}
static void map_ops_update_delete_subtest(void)
{
struct test_map_ops *skel;
if (setup(&skel))
goto teardown;
map_update();
ASSERT_OK(skel->bss->err, "map_update_initial");
map_update();
ASSERT_LT(skel->bss->err, 0, "map_update_existing");
ASSERT_EQ(skel->bss->err, -EEXIST, "map_update_existing");
map_delete();
Annotation
- Immediate include surface: `errno.h`, `sys/syscall.h`, `unistd.h`, `test_map_ops.skel.h`, `test_progs.h`.
- Detected declarations: `function map_update`, `function map_delete`, `function map_push`, `function map_pop`, `function map_peek`, `function map_for_each_pass`, `function map_for_each_fail`, `function setup`, `function teardown`, `function map_ops_update_delete_subtest`.
- 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.