diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-11-09 19:46:48 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-11-14 14:50:02 -0500 |
commit | 5e24a0904ed4029f6778a214b6fe41b9265fd620 (patch) | |
tree | a149ab978703c6a6c02ac203daa433f42167afe6 /tools | |
parent | cfffae2ef7029d38e71d337fbc2a9c6cf1fa5aaf (diff) |
perf tests: Move perf_evsel__tp_sched_test into separate object
Separating perf_evsel__tp_sched_test test from the builtin-test into
evsel-tp-sched 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-9-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Makefile | 1 | ||||
-rw-r--r-- | tools/perf/tests/builtin-test.c | 83 | ||||
-rw-r--r-- | tools/perf/tests/evsel-tp-sched.c | 84 | ||||
-rw-r--r-- | tools/perf/tests/tests.h | 1 |
4 files changed, 87 insertions, 82 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index ad6fcb5f582c..e510b53eb8df 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -438,6 +438,7 @@ LIB_OBJS += $(OUTPUT)tests/mmap-basic.o | |||
438 | LIB_OBJS += $(OUTPUT)tests/perf-record.o | 438 | LIB_OBJS += $(OUTPUT)tests/perf-record.o |
439 | LIB_OBJS += $(OUTPUT)tests/rdpmc.o | 439 | LIB_OBJS += $(OUTPUT)tests/rdpmc.o |
440 | LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o | 440 | LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o |
441 | LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o | ||
441 | LIB_OBJS += $(OUTPUT)tests/util.o | 442 | LIB_OBJS += $(OUTPUT)tests/util.o |
442 | 443 | ||
443 | BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o | 444 | BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o |
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 93f5e9176e68..c66caa79c622 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -35,87 +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__test_field(struct perf_evsel *evsel, const char *name, | ||
39 | int size, bool should_be_signed) | ||
40 | { | ||
41 | struct format_field *field = perf_evsel__field(evsel, name); | ||
42 | int is_signed; | ||
43 | int ret = 0; | ||
44 | |||
45 | if (field == NULL) { | ||
46 | pr_debug("%s: \"%s\" field not found!\n", evsel->name, name); | ||
47 | return -1; | ||
48 | } | ||
49 | |||
50 | is_signed = !!(field->flags | FIELD_IS_SIGNED); | ||
51 | if (should_be_signed && !is_signed) { | ||
52 | pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n", | ||
53 | evsel->name, name, is_signed, should_be_signed); | ||
54 | ret = -1; | ||
55 | } | ||
56 | |||
57 | if (field->size != size) { | ||
58 | pr_debug("%s: \"%s\" size (%d) should be %d!\n", | ||
59 | evsel->name, name, field->size, size); | ||
60 | ret = -1; | ||
61 | } | ||
62 | |||
63 | return ret; | ||
64 | } | ||
65 | |||
66 | static int perf_evsel__tp_sched_test(void) | ||
67 | { | ||
68 | struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch", 0); | ||
69 | int ret = 0; | ||
70 | |||
71 | if (evsel == NULL) { | ||
72 | pr_debug("perf_evsel__new\n"); | ||
73 | return -1; | ||
74 | } | ||
75 | |||
76 | if (perf_evsel__test_field(evsel, "prev_comm", 16, true)) | ||
77 | ret = -1; | ||
78 | |||
79 | if (perf_evsel__test_field(evsel, "prev_pid", 4, true)) | ||
80 | ret = -1; | ||
81 | |||
82 | if (perf_evsel__test_field(evsel, "prev_prio", 4, true)) | ||
83 | ret = -1; | ||
84 | |||
85 | if (perf_evsel__test_field(evsel, "prev_state", 8, true)) | ||
86 | ret = -1; | ||
87 | |||
88 | if (perf_evsel__test_field(evsel, "next_comm", 16, true)) | ||
89 | ret = -1; | ||
90 | |||
91 | if (perf_evsel__test_field(evsel, "next_pid", 4, true)) | ||
92 | ret = -1; | ||
93 | |||
94 | if (perf_evsel__test_field(evsel, "next_prio", 4, true)) | ||
95 | ret = -1; | ||
96 | |||
97 | perf_evsel__delete(evsel); | ||
98 | |||
99 | evsel = perf_evsel__newtp("sched", "sched_wakeup", 0); | ||
100 | |||
101 | if (perf_evsel__test_field(evsel, "comm", 16, true)) | ||
102 | ret = -1; | ||
103 | |||
104 | if (perf_evsel__test_field(evsel, "pid", 4, true)) | ||
105 | ret = -1; | ||
106 | |||
107 | if (perf_evsel__test_field(evsel, "prio", 4, true)) | ||
108 | ret = -1; | ||
109 | |||
110 | if (perf_evsel__test_field(evsel, "success", 4, true)) | ||
111 | ret = -1; | ||
112 | |||
113 | if (perf_evsel__test_field(evsel, "target_cpu", 4, true)) | ||
114 | ret = -1; | ||
115 | |||
116 | return ret; | ||
117 | } | ||
118 | |||
119 | static int test__syscall_open_tp_fields(void) | 38 | static int test__syscall_open_tp_fields(void) |
120 | { | 39 | { |
121 | struct perf_record_opts opts = { | 40 | struct perf_record_opts opts = { |
@@ -276,7 +195,7 @@ static struct test { | |||
276 | }, | 195 | }, |
277 | { | 196 | { |
278 | .desc = "Check parsing of sched tracepoints fields", | 197 | .desc = "Check parsing of sched tracepoints fields", |
279 | .func = perf_evsel__tp_sched_test, | 198 | .func = test__perf_evsel__tp_sched_test, |
280 | }, | 199 | }, |
281 | { | 200 | { |
282 | .desc = "Generate and check syscalls:sys_enter_open event fields", | 201 | .desc = "Generate and check syscalls:sys_enter_open event fields", |
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c new file mode 100644 index 000000000000..a5d2fcc5ae35 --- /dev/null +++ b/tools/perf/tests/evsel-tp-sched.c | |||
@@ -0,0 +1,84 @@ | |||
1 | #include "evsel.h" | ||
2 | #include "tests.h" | ||
3 | #include "event-parse.h" | ||
4 | |||
5 | static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, | ||
6 | int size, bool should_be_signed) | ||
7 | { | ||
8 | struct format_field *field = perf_evsel__field(evsel, name); | ||
9 | int is_signed; | ||
10 | int ret = 0; | ||
11 | |||
12 | if (field == NULL) { | ||
13 | pr_debug("%s: \"%s\" field not found!\n", evsel->name, name); | ||
14 | return -1; | ||
15 | } | ||
16 | |||
17 | is_signed = !!(field->flags | FIELD_IS_SIGNED); | ||
18 | if (should_be_signed && !is_signed) { | ||
19 | pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n", | ||
20 | evsel->name, name, is_signed, should_be_signed); | ||
21 | ret = -1; | ||
22 | } | ||
23 | |||
24 | if (field->size != size) { | ||
25 | pr_debug("%s: \"%s\" size (%d) should be %d!\n", | ||
26 | evsel->name, name, field->size, size); | ||
27 | ret = -1; | ||
28 | } | ||
29 | |||
30 | return ret; | ||
31 | } | ||
32 | |||
33 | int test__perf_evsel__tp_sched_test(void) | ||
34 | { | ||
35 | struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch", 0); | ||
36 | int ret = 0; | ||
37 | |||
38 | if (evsel == NULL) { | ||
39 | pr_debug("perf_evsel__new\n"); | ||
40 | return -1; | ||
41 | } | ||
42 | |||
43 | if (perf_evsel__test_field(evsel, "prev_comm", 16, true)) | ||
44 | ret = -1; | ||
45 | |||
46 | if (perf_evsel__test_field(evsel, "prev_pid", 4, true)) | ||
47 | ret = -1; | ||
48 | |||
49 | if (perf_evsel__test_field(evsel, "prev_prio", 4, true)) | ||
50 | ret = -1; | ||
51 | |||
52 | if (perf_evsel__test_field(evsel, "prev_state", 8, true)) | ||
53 | ret = -1; | ||
54 | |||
55 | if (perf_evsel__test_field(evsel, "next_comm", 16, true)) | ||
56 | ret = -1; | ||
57 | |||
58 | if (perf_evsel__test_field(evsel, "next_pid", 4, true)) | ||
59 | ret = -1; | ||
60 | |||
61 | if (perf_evsel__test_field(evsel, "next_prio", 4, true)) | ||
62 | ret = -1; | ||
63 | |||
64 | perf_evsel__delete(evsel); | ||
65 | |||
66 | evsel = perf_evsel__newtp("sched", "sched_wakeup", 0); | ||
67 | |||
68 | if (perf_evsel__test_field(evsel, "comm", 16, true)) | ||
69 | ret = -1; | ||
70 | |||
71 | if (perf_evsel__test_field(evsel, "pid", 4, true)) | ||
72 | ret = -1; | ||
73 | |||
74 | if (perf_evsel__test_field(evsel, "prio", 4, true)) | ||
75 | ret = -1; | ||
76 | |||
77 | if (perf_evsel__test_field(evsel, "success", 4, true)) | ||
78 | ret = -1; | ||
79 | |||
80 | if (perf_evsel__test_field(evsel, "target_cpu", 4, true)) | ||
81 | ret = -1; | ||
82 | |||
83 | return ret; | ||
84 | } | ||
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 5897dd13efa3..1ef265d84a6e 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h | |||
@@ -9,6 +9,7 @@ int test__basic_mmap(void); | |||
9 | int test__PERF_RECORD(void); | 9 | int test__PERF_RECORD(void); |
10 | int test__rdpmc(void); | 10 | int test__rdpmc(void); |
11 | int test__perf_evsel__roundtrip_name_test(void); | 11 | int test__perf_evsel__roundtrip_name_test(void); |
12 | int test__perf_evsel__tp_sched_test(void); | ||
12 | 13 | ||
13 | /* Util */ | 14 | /* Util */ |
14 | int trace_event__id(const char *evname); | 15 | int trace_event__id(const char *evname); |