1*a6e52817SJiri Olsa #include <linux/compiler.h> 2*a6e52817SJiri Olsa #include "evlist.h" 3*a6e52817SJiri Olsa #include "evsel.h" 4*a6e52817SJiri Olsa #include "machine.h" 5*a6e52817SJiri Olsa #include "tests.h" 6*a6e52817SJiri Olsa #include "debug.h" 7*a6e52817SJiri Olsa 8*a6e52817SJiri Olsa static int process_event_unit(struct perf_tool *tool __maybe_unused, 9*a6e52817SJiri Olsa union perf_event *event, 10*a6e52817SJiri Olsa struct perf_sample *sample __maybe_unused, 11*a6e52817SJiri Olsa struct machine *machine __maybe_unused) 12*a6e52817SJiri Olsa { 13*a6e52817SJiri Olsa struct event_update_event *ev = (struct event_update_event *) event; 14*a6e52817SJiri Olsa 15*a6e52817SJiri Olsa TEST_ASSERT_VAL("wrong id", ev->id == 123); 16*a6e52817SJiri Olsa TEST_ASSERT_VAL("wrong id", ev->type == PERF_EVENT_UPDATE__UNIT); 17*a6e52817SJiri Olsa TEST_ASSERT_VAL("wrong unit", !strcmp(ev->data, "KRAVA")); 18*a6e52817SJiri Olsa return 0; 19*a6e52817SJiri Olsa } 20*a6e52817SJiri Olsa 21*a6e52817SJiri Olsa int test__event_update(int subtest __maybe_unused) 22*a6e52817SJiri Olsa { 23*a6e52817SJiri Olsa struct perf_evlist *evlist; 24*a6e52817SJiri Olsa struct perf_evsel *evsel; 25*a6e52817SJiri Olsa 26*a6e52817SJiri Olsa evlist = perf_evlist__new_default(); 27*a6e52817SJiri Olsa TEST_ASSERT_VAL("failed to get evlist", evlist); 28*a6e52817SJiri Olsa 29*a6e52817SJiri Olsa evsel = perf_evlist__first(evlist); 30*a6e52817SJiri Olsa 31*a6e52817SJiri Olsa TEST_ASSERT_VAL("failed to allos ids", 32*a6e52817SJiri Olsa !perf_evsel__alloc_id(evsel, 1, 1)); 33*a6e52817SJiri Olsa 34*a6e52817SJiri Olsa perf_evlist__id_add(evlist, evsel, 0, 0, 123); 35*a6e52817SJiri Olsa 36*a6e52817SJiri Olsa evsel->unit = strdup("KRAVA"); 37*a6e52817SJiri Olsa 38*a6e52817SJiri Olsa TEST_ASSERT_VAL("failed to synthesize attr update unit", 39*a6e52817SJiri Olsa !perf_event__synthesize_event_update_unit(NULL, evsel, process_event_unit)); 40*a6e52817SJiri Olsa 41*a6e52817SJiri Olsa return 0; 42*a6e52817SJiri Olsa } 43