Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tests: Add tests of new pinned modifier

Add a negative test to test__checkevent_pmu_events() to get lots of
coverage of the negative case, ie. when the modifier is not specified.

Add a test of a single event, and of the group case.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1375795686-4226-2-git-send-email-michael@ellerman.id.au
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Michael Ellerman and committed by
Arnaldo Carvalho de Melo
c9ee780f e9a7c414

+53
+53
tools/perf/tests/parse-events.c
··· 452 452 evsel->attr.exclude_kernel); 453 453 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 454 454 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 455 + TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 455 456 456 457 return 0; 457 458 } ··· 1071 1070 return 0; 1072 1071 } 1073 1072 1073 + static int test__checkevent_pinned_modifier(struct perf_evlist *evlist) 1074 + { 1075 + struct perf_evsel *evsel = perf_evlist__first(evlist); 1076 + 1077 + TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1078 + TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 1079 + TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 1080 + TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 1081 + TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); 1082 + 1083 + return test__checkevent_symbolic_name(evlist); 1084 + } 1085 + 1086 + static int test__pinned_group(struct perf_evlist *evlist) 1087 + { 1088 + struct perf_evsel *evsel, *leader; 1089 + 1090 + TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); 1091 + 1092 + /* cycles - group leader */ 1093 + evsel = leader = perf_evlist__first(evlist); 1094 + TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1095 + TEST_ASSERT_VAL("wrong config", 1096 + PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 1097 + TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1098 + TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1099 + TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); 1100 + 1101 + /* cache-misses - can not be pinned, but will go on with the leader */ 1102 + evsel = perf_evsel__next(evsel); 1103 + TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1104 + TEST_ASSERT_VAL("wrong config", 1105 + PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 1106 + TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 1107 + 1108 + /* branch-misses - ditto */ 1109 + evsel = perf_evsel__next(evsel); 1110 + TEST_ASSERT_VAL("wrong config", 1111 + PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); 1112 + TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 1113 + 1114 + return 0; 1115 + } 1116 + 1074 1117 static int count_tracepoints(void) 1075 1118 { 1076 1119 char events_path[PATH_MAX]; ··· 1338 1293 [39] = { 1339 1294 .name = "{instructions,branch-misses}:Su", 1340 1295 .check = test__leader_sample2, 1296 + }, 1297 + [40] = { 1298 + .name = "instructions:uDp", 1299 + .check = test__checkevent_pinned_modifier, 1300 + }, 1301 + [41] = { 1302 + .name = "{cycles,cache-misses,branch-misses}:D", 1303 + .check = test__pinned_group, 1341 1304 }, 1342 1305 }; 1343 1306