diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-11-09 19:46:47 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-11-14 14:49:56 -0500 |
commit | cfffae2ef7029d38e71d337fbc2a9c6cf1fa5aaf (patch) | |
tree | 1840c55218621ab65ba099919af1f1268fd6e4a5 /tools/perf/tests/builtin-test.c | |
parent | bacf7e5d4055b65506292cf6412ec71e7948a9cf (diff) |
perf tests: Move perf_evsel__roundtrip_name_test into separate object
Separating perf_evsel__roundtrip_name_test test from the builtin-test
into evsel-roundtrip-name object.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1352508412-16914-8-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests/builtin-test.c')
-rw-r--r-- | tools/perf/tests/builtin-test.c | 112 |
1 files changed, 1 insertions, 111 deletions
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 1e9a0ea68fb2..93f5e9176e68 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -35,116 +35,6 @@ static int test__perf_pmu(void) | |||
35 | return perf_pmu__test(); | 35 | return perf_pmu__test(); |
36 | } | 36 | } |
37 | 37 | ||
38 | static int perf_evsel__roundtrip_cache_name_test(void) | ||
39 | { | ||
40 | char name[128]; | ||
41 | int type, op, err = 0, ret = 0, i, idx; | ||
42 | struct perf_evsel *evsel; | ||
43 | struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); | ||
44 | |||
45 | if (evlist == NULL) | ||
46 | return -ENOMEM; | ||
47 | |||
48 | for (type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) { | ||
49 | for (op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) { | ||
50 | /* skip invalid cache type */ | ||
51 | if (!perf_evsel__is_cache_op_valid(type, op)) | ||
52 | continue; | ||
53 | |||
54 | for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) { | ||
55 | __perf_evsel__hw_cache_type_op_res_name(type, op, i, | ||
56 | name, sizeof(name)); | ||
57 | err = parse_events(evlist, name, 0); | ||
58 | if (err) | ||
59 | ret = err; | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | |||
64 | idx = 0; | ||
65 | evsel = perf_evlist__first(evlist); | ||
66 | |||
67 | for (type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) { | ||
68 | for (op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) { | ||
69 | /* skip invalid cache type */ | ||
70 | if (!perf_evsel__is_cache_op_valid(type, op)) | ||
71 | continue; | ||
72 | |||
73 | for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) { | ||
74 | __perf_evsel__hw_cache_type_op_res_name(type, op, i, | ||
75 | name, sizeof(name)); | ||
76 | if (evsel->idx != idx) | ||
77 | continue; | ||
78 | |||
79 | ++idx; | ||
80 | |||
81 | if (strcmp(perf_evsel__name(evsel), name)) { | ||
82 | pr_debug("%s != %s\n", perf_evsel__name(evsel), name); | ||
83 | ret = -1; | ||
84 | } | ||
85 | |||
86 | evsel = perf_evsel__next(evsel); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | perf_evlist__delete(evlist); | ||
92 | return ret; | ||
93 | } | ||
94 | |||
95 | static int __perf_evsel__name_array_test(const char *names[], int nr_names) | ||
96 | { | ||
97 | int i, err; | ||
98 | struct perf_evsel *evsel; | ||
99 | struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); | ||
100 | |||
101 | if (evlist == NULL) | ||
102 | return -ENOMEM; | ||
103 | |||
104 | for (i = 0; i < nr_names; ++i) { | ||
105 | err = parse_events(evlist, names[i], 0); | ||
106 | if (err) { | ||
107 | pr_debug("failed to parse event '%s', err %d\n", | ||
108 | names[i], err); | ||
109 | goto out_delete_evlist; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | err = 0; | ||
114 | list_for_each_entry(evsel, &evlist->entries, node) { | ||
115 | if (strcmp(perf_evsel__name(evsel), names[evsel->idx])) { | ||
116 | --err; | ||
117 | pr_debug("%s != %s\n", perf_evsel__name(evsel), names[evsel->idx]); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | out_delete_evlist: | ||
122 | perf_evlist__delete(evlist); | ||
123 | return err; | ||
124 | } | ||
125 | |||
126 | #define perf_evsel__name_array_test(names) \ | ||
127 | __perf_evsel__name_array_test(names, ARRAY_SIZE(names)) | ||
128 | |||
129 | static int perf_evsel__roundtrip_name_test(void) | ||
130 | { | ||
131 | int err = 0, ret = 0; | ||
132 | |||
133 | err = perf_evsel__name_array_test(perf_evsel__hw_names); | ||
134 | if (err) | ||
135 | ret = err; | ||
136 | |||
137 | err = perf_evsel__name_array_test(perf_evsel__sw_names); | ||
138 | if (err) | ||
139 | ret = err; | ||
140 | |||
141 | err = perf_evsel__roundtrip_cache_name_test(); | ||
142 | if (err) | ||
143 | ret = err; | ||
144 | |||
145 | return ret; | ||
146 | } | ||
147 | |||
148 | static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, | 38 | static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, |
149 | int size, bool should_be_signed) | 39 | int size, bool should_be_signed) |
150 | { | 40 | { |
@@ -382,7 +272,7 @@ static struct test { | |||
382 | }, | 272 | }, |
383 | { | 273 | { |
384 | .desc = "roundtrip evsel->name check", | 274 | .desc = "roundtrip evsel->name check", |
385 | .func = perf_evsel__roundtrip_name_test, | 275 | .func = test__perf_evsel__roundtrip_name_test, |
386 | }, | 276 | }, |
387 | { | 277 | { |
388 | .desc = "Check parsing of sched tracepoints fields", | 278 | .desc = "Check parsing of sched tracepoints fields", |