diff options
Diffstat (limited to 'tools/perf/tests/event_update.c')
-rw-r--r-- | tools/perf/tests/event_update.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c index a91fcefc9f67..482b89650bbe 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c @@ -34,10 +34,30 @@ static int process_event_scale(struct perf_tool *tool __maybe_unused, return 0; } +struct event_name { + struct perf_tool tool; + const char *name; +}; + +static int process_event_name(struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample __maybe_unused, + struct machine *machine __maybe_unused) +{ + struct event_name *tmp = container_of(tool, struct event_name, tool); + struct event_update_event *ev = (struct event_update_event*) event; + + TEST_ASSERT_VAL("wrong id", ev->id == 123); + TEST_ASSERT_VAL("wrong id", ev->type == PERF_EVENT_UPDATE__NAME); + TEST_ASSERT_VAL("wrong name", !strcmp(ev->data, tmp->name)); + return 0; +} + int test__event_update(int subtest __maybe_unused) { struct perf_evlist *evlist; struct perf_evsel *evsel; + struct event_name tmp; evlist = perf_evlist__new_default(); TEST_ASSERT_VAL("failed to get evlist", evlist); @@ -59,5 +79,10 @@ int test__event_update(int subtest __maybe_unused) TEST_ASSERT_VAL("failed to synthesize attr update scale", !perf_event__synthesize_event_update_scale(NULL, evsel, process_event_scale)); + tmp.name = perf_evsel__name(evsel); + + TEST_ASSERT_VAL("failed to synthesize attr update name", + !perf_event__synthesize_event_update_name(&tmp.tool, evsel, process_event_name)); + return 0; } |