diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-20 15:54:11 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-24 14:28:11 -0300 |
commit | ce1d3bc2733224573600e5564203345caea814eb (patch) | |
tree | 328b64218285f9e19a17faa9bd020c3f3ffac383 /tools/perf/tests | |
parent | 9be6ab181b7b8d6114e225ae3c7c01bb6380cf8a (diff) |
perf evsel: Introduce evsel__name_is() method to check if the evsel name is equal to a given string
This makes the logic a bit clear by avoiding the !strcmp() pattern and
also a way to intercept the pointer if we need to do extra validation on
it or to do lazy setting of evsel->name via evsel__name(evsel).
Reviewed-by: "Liang, Kan" <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/ZEGLM8VehJbS0gP2@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests')
-rw-r--r-- | tools/perf/tests/expand-cgroup.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/parse-events.c | 12 | ||||
-rw-r--r-- | tools/perf/tests/parse-metric.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/pmu-events.c | 2 |
4 files changed, 9 insertions, 9 deletions
diff --git a/tools/perf/tests/expand-cgroup.c b/tools/perf/tests/expand-cgroup.c index ec340880a848..9c1a1f18db75 100644 --- a/tools/perf/tests/expand-cgroup.c +++ b/tools/perf/tests/expand-cgroup.c @@ -61,7 +61,7 @@ static int test_expand_events(struct evlist *evlist, i = 0; evlist__for_each_entry(evlist, evsel) { - if (strcmp(evsel->name, ev_name[i % nr_events])) { + if (!evsel__name_is(evsel, ev_name[i % nr_events])) { pr_debug("event name doesn't match:\n"); pr_debug(" evsel[%d]: %s\n expected: %s\n", i, evsel->name, ev_name[i % nr_events]); diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 6eb1400443ad..8068cfd89b84 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -1401,7 +1401,7 @@ static int test__checkevent_config_symbol(struct evlist *evlist) { struct evsel *evsel = evlist__first(evlist); - TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") == 0); + TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "insn")); return TEST_OK; } @@ -1409,7 +1409,7 @@ static int test__checkevent_config_raw(struct evlist *evlist) { struct evsel *evsel = evlist__first(evlist); - TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") == 0); + TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "rawpmu")); return TEST_OK; } @@ -1417,7 +1417,7 @@ static int test__checkevent_config_num(struct evlist *evlist) { struct evsel *evsel = evlist__first(evlist); - TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") == 0); + TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "numpmu")); return TEST_OK; } @@ -1425,7 +1425,7 @@ static int test__checkevent_config_cache(struct evlist *evlist) { struct evsel *evsel = evlist__first(evlist); - TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") == 0); + TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "cachepmu")); return TEST_OK; } @@ -1438,7 +1438,7 @@ static int test__intel_pt(struct evlist *evlist) { struct evsel *evsel = evlist__first(evlist); - TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "intel_pt//u") == 0); + TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "intel_pt//u")); return TEST_OK; } @@ -1446,7 +1446,7 @@ static int test__checkevent_complex_name(struct evlist *evlist) { struct evsel *evsel = evlist__first(evlist); - TEST_ASSERT_VAL("wrong complex name parsing", strcmp(evsel->name, "COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks") == 0); + TEST_ASSERT_VAL("wrong complex name parsing", evsel__name_is(evsel, "COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks")); return TEST_OK; } diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metric.c index c43b056f9fa3..1185b79e6274 100644 --- a/tools/perf/tests/parse-metric.c +++ b/tools/perf/tests/parse-metric.c @@ -39,7 +39,7 @@ static void load_runtime_stat(struct evlist *evlist, struct value *vals) evlist__for_each_entry(evlist, evsel) { count = find_value(evsel->name, vals); evsel->stats->aggr->counts.val = count; - if (!strcmp(evsel->name, "duration_time")) + if (evsel__name_is(evsel, "duration_time")) update_stats(&walltime_nsecs_stats, count); } } diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c index 7f8e86452527..1dff863b9711 100644 --- a/tools/perf/tests/pmu-events.c +++ b/tools/perf/tests/pmu-events.c @@ -866,7 +866,7 @@ static int test__parsing_callback(const struct pmu_metric *pm, evlist__alloc_aggr_stats(evlist, 1); evlist__for_each_entry(evlist, evsel) { evsel->stats->aggr->counts.val = k; - if (!strcmp(evsel->name, "duration_time")) + if (evsel__name_is(evsel, "duration_time")) update_stats(&walltime_nsecs_stats, k); k++; } |