diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-10-10 08:53:18 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-10-24 04:41:27 -0400 |
commit | 3f3a20648797c3ff49c6ebfe10747ef0acd37c50 (patch) | |
tree | 2aa678f963da80b953898c11b3224de7b04f39bb | |
parent | 1d33d6dce11e2c900daeca8110d56b95f1174188 (diff) |
perf test: Add automated tests for pmu sysfs translated events
Add automated tests for all events found under PMU/events
directory. Tested events are in the 'cpu/event=xxx/u' format,
where 'xxx' is substituted by every event found.
The 'event=xxx' term is translated to the cpu specific term.
We only check that the event is created (not the real config
numbers) and that the modifier is properly set.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1349873598-12583-9-git-send-email-jolsa@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | tools/perf/util/parse-events-test.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c index 516ecd9ddd6e..b49c2eebff33 100644 --- a/tools/perf/util/parse-events-test.c +++ b/tools/perf/util/parse-events-test.c | |||
@@ -443,6 +443,23 @@ static int test__checkevent_pmu_name(struct perf_evlist *evlist) | |||
443 | return 0; | 443 | return 0; |
444 | } | 444 | } |
445 | 445 | ||
446 | static int test__checkevent_pmu_events(struct perf_evlist *evlist) | ||
447 | { | ||
448 | struct perf_evsel *evsel; | ||
449 | |||
450 | evsel = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
451 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | ||
452 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | ||
453 | TEST_ASSERT_VAL("wrong exclude_user", | ||
454 | !evsel->attr.exclude_user); | ||
455 | TEST_ASSERT_VAL("wrong exclude_kernel", | ||
456 | evsel->attr.exclude_kernel); | ||
457 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | ||
458 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | ||
459 | |||
460 | return 0; | ||
461 | } | ||
462 | |||
446 | static int test__checkterms_simple(struct list_head *terms) | 463 | static int test__checkterms_simple(struct list_head *terms) |
447 | { | 464 | { |
448 | struct parse_events__term *term; | 465 | struct parse_events__term *term; |
@@ -1024,6 +1041,51 @@ static int test_pmu(void) | |||
1024 | return !ret; | 1041 | return !ret; |
1025 | } | 1042 | } |
1026 | 1043 | ||
1044 | static int test_pmu_events(void) | ||
1045 | { | ||
1046 | struct stat st; | ||
1047 | char path[PATH_MAX]; | ||
1048 | struct dirent *ent; | ||
1049 | DIR *dir; | ||
1050 | int ret; | ||
1051 | |||
1052 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", | ||
1053 | sysfs_find_mountpoint()); | ||
1054 | |||
1055 | ret = stat(path, &st); | ||
1056 | if (ret) { | ||
1057 | pr_debug("ommiting PMU cpu events tests\n"); | ||
1058 | return 0; | ||
1059 | } | ||
1060 | |||
1061 | dir = opendir(path); | ||
1062 | if (!dir) { | ||
1063 | pr_debug("can't open pmu event dir"); | ||
1064 | return -1; | ||
1065 | } | ||
1066 | |||
1067 | while (!ret && (ent = readdir(dir))) { | ||
1068 | #define MAX_NAME 100 | ||
1069 | struct test__event_st e; | ||
1070 | char name[MAX_NAME]; | ||
1071 | |||
1072 | if (!strcmp(ent->d_name, ".") || | ||
1073 | !strcmp(ent->d_name, "..")) | ||
1074 | continue; | ||
1075 | |||
1076 | snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name); | ||
1077 | |||
1078 | e.name = name; | ||
1079 | e.check = test__checkevent_pmu_events; | ||
1080 | |||
1081 | ret = test_event(&e); | ||
1082 | #undef MAX_NAME | ||
1083 | } | ||
1084 | |||
1085 | closedir(dir); | ||
1086 | return ret; | ||
1087 | } | ||
1088 | |||
1027 | int parse_events__test(void) | 1089 | int parse_events__test(void) |
1028 | { | 1090 | { |
1029 | int ret1, ret2 = 0; | 1091 | int ret1, ret2 = 0; |
@@ -1040,6 +1102,12 @@ do { \ | |||
1040 | if (test_pmu()) | 1102 | if (test_pmu()) |
1041 | TEST_EVENTS(test__events_pmu); | 1103 | TEST_EVENTS(test__events_pmu); |
1042 | 1104 | ||
1105 | if (test_pmu()) { | ||
1106 | int ret = test_pmu_events(); | ||
1107 | if (ret) | ||
1108 | return ret; | ||
1109 | } | ||
1110 | |||
1043 | ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms)); | 1111 | ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms)); |
1044 | if (!ret2) | 1112 | if (!ret2) |
1045 | ret2 = ret1; | 1113 | ret2 = ret1; |