tools/testing/selftests/bpf/prog_tests/arg_parsing.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/arg_parsing.c- Extension
.c- Size
- 5960 bytes
- Lines
- 182
- 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.htesting_helpers.h
Detected Declarations
function init_test_filter_setfunction free_test_filter_setfunction test_parse_test_listfunction test_parse_test_list_filefunction test_arg_parsing
Annotated Snippet
// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
#include "test_progs.h"
#include "testing_helpers.h"
static void init_test_filter_set(struct test_filter_set *set)
{
set->cnt = 0;
set->tests = NULL;
}
static void free_test_filter_set(struct test_filter_set *set)
{
int i, j;
for (i = 0; i < set->cnt; i++) {
for (j = 0; j < set->tests[i].subtest_cnt; j++)
free((void *)set->tests[i].subtests[j]);
free(set->tests[i].subtests);
free(set->tests[i].name);
}
free(set->tests);
init_test_filter_set(set);
}
static void test_parse_test_list(void)
{
struct test_filter_set set;
init_test_filter_set(&set);
ASSERT_OK(parse_test_list("arg_parsing", &set, true), "parsing");
if (!ASSERT_EQ(set.cnt, 1, "test filters count"))
goto error;
if (!ASSERT_OK_PTR(set.tests, "test filters initialized"))
goto error;
ASSERT_EQ(set.tests[0].subtest_cnt, 0, "subtest filters count");
ASSERT_OK(strcmp("arg_parsing", set.tests[0].name), "subtest name");
free_test_filter_set(&set);
ASSERT_OK(parse_test_list("arg_parsing,bpf_cookie", &set, true),
"parsing");
if (!ASSERT_EQ(set.cnt, 2, "count of test filters"))
goto error;
if (!ASSERT_OK_PTR(set.tests, "test filters initialized"))
goto error;
ASSERT_EQ(set.tests[0].subtest_cnt, 0, "subtest filters count");
ASSERT_EQ(set.tests[1].subtest_cnt, 0, "subtest filters count");
ASSERT_OK(strcmp("arg_parsing", set.tests[0].name), "test name");
ASSERT_OK(strcmp("bpf_cookie", set.tests[1].name), "test name");
free_test_filter_set(&set);
ASSERT_OK(parse_test_list("arg_parsing/arg_parsing,bpf_cookie",
&set,
true),
"parsing");
if (!ASSERT_EQ(set.cnt, 2, "count of test filters"))
goto error;
if (!ASSERT_OK_PTR(set.tests, "test filters initialized"))
goto error;
if (!ASSERT_EQ(set.tests[0].subtest_cnt, 1, "subtest filters count"))
goto error;
ASSERT_EQ(set.tests[1].subtest_cnt, 0, "subtest filters count");
ASSERT_OK(strcmp("arg_parsing", set.tests[0].name), "test name");
ASSERT_OK(strcmp("arg_parsing", set.tests[0].subtests[0]),
"subtest name");
ASSERT_OK(strcmp("bpf_cookie", set.tests[1].name), "test name");
free_test_filter_set(&set);
ASSERT_OK(parse_test_list("arg_parsing/arg_parsing", &set, true),
"parsing");
ASSERT_OK(parse_test_list("bpf_cookie", &set, true), "parsing");
ASSERT_OK(parse_test_list("send_signal", &set, true), "parsing");
if (!ASSERT_EQ(set.cnt, 3, "count of test filters"))
goto error;
if (!ASSERT_OK_PTR(set.tests, "test filters initialized"))
goto error;
if (!ASSERT_EQ(set.tests[0].subtest_cnt, 1, "subtest filters count"))
goto error;
ASSERT_EQ(set.tests[1].subtest_cnt, 0, "subtest filters count");
ASSERT_EQ(set.tests[2].subtest_cnt, 0, "subtest filters count");
ASSERT_OK(strcmp("arg_parsing", set.tests[0].name), "test name");
ASSERT_OK(strcmp("arg_parsing", set.tests[0].subtests[0]),
"subtest name");
ASSERT_OK(strcmp("bpf_cookie", set.tests[1].name), "test name");
ASSERT_OK(strcmp("send_signal", set.tests[2].name), "test name");
free_test_filter_set(&set);
ASSERT_OK(parse_test_list("bpf_cookie/trace", &set, false), "parsing");
Annotation
- Immediate include surface: `test_progs.h`, `testing_helpers.h`.
- Detected declarations: `function init_test_filter_set`, `function free_test_filter_set`, `function test_parse_test_list`, `function test_parse_test_list_file`, `function test_arg_parsing`.
- 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.