tools/perf/tests/evsel-roundtrip-name.c
Source file repositories/reference/linux-study-clean/tools/perf/tests/evsel-roundtrip-name.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/evsel-roundtrip-name.c- Extension
.c- Size
- 2467 bytes
- Lines
- 105
- 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
evlist.hevsel.hparse-events.htests.hdebug.hlinux/kernel.h
Detected Declarations
function perf_evsel__roundtrip_cache_name_testfunction evlist__for_each_entryfunction perf_evsel__name_array_testfunction evlist__for_each_entryfunction test__perf_evsel__roundtrip_name_test
Annotated Snippet
if (evlist == NULL) {
pr_debug("Failed to alloc evlist");
return TEST_FAIL;
}
__evsel__hw_cache_type_op_res_name(type, op, res,
name, sizeof(name));
err = parse_event(evlist, name);
if (err) {
pr_debug("Failure to parse cache event '%s' possibly as PMUs don't support it",
name);
evlist__delete(evlist);
continue;
}
evlist__for_each_entry(evlist, evsel) {
if (!evsel__name_is(evsel, name)) {
pr_debug("%s != %s\n", evsel__name(evsel), name);
ret = TEST_FAIL;
}
}
evlist__delete(evlist);
}
}
}
return ret;
}
static int perf_evsel__name_array_test(const char *const names[], int nr_names)
{
int ret = TEST_OK;
for (int i = 0; i < nr_names; ++i) {
struct evlist *evlist = evlist__new();
struct evsel *evsel;
int err;
if (evlist == NULL) {
pr_debug("Failed to alloc evlist");
return TEST_FAIL;
}
err = parse_event(evlist, names[i]);
if (err) {
pr_debug("failed to parse event '%s', err %d\n",
names[i], err);
evlist__delete(evlist);
ret = TEST_FAIL;
continue;
}
evlist__for_each_entry(evlist, evsel) {
if (!evsel__name_is(evsel, names[i])) {
pr_debug("%s != %s\n", evsel__name(evsel), names[i]);
ret = TEST_FAIL;
}
}
evlist__delete(evlist);
}
return ret;
}
static int test__perf_evsel__roundtrip_name_test(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
int err = 0, ret = TEST_OK;
err = perf_evsel__name_array_test(evsel__hw_names, PERF_COUNT_HW_MAX);
if (err)
ret = err;
err = perf_evsel__name_array_test(evsel__sw_names, PERF_COUNT_SW_DUMMY + 1);
if (err)
ret = err;
err = perf_evsel__roundtrip_cache_name_test();
if (err)
ret = err;
return ret;
}
DEFINE_SUITE("Roundtrip evsel->name", perf_evsel__roundtrip_name_test);
Annotation
- Immediate include surface: `evlist.h`, `evsel.h`, `parse-events.h`, `tests.h`, `debug.h`, `linux/kernel.h`.
- Detected declarations: `function perf_evsel__roundtrip_cache_name_test`, `function evlist__for_each_entry`, `function perf_evsel__name_array_test`, `function evlist__for_each_entry`, `function test__perf_evsel__roundtrip_name_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.