aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/tests/builtin-test.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-11-09 19:46:49 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-11-14 14:50:09 -0500
commitdc447eed59037c1c65feab9c72d372b6249af978 (patch)
tree4fb7b3552da074ff6f741fdd014b0a4333e6dd55 /tools/perf/tests/builtin-test.c
parent5e24a0904ed4029f6778a214b6fe41b9265fd620 (diff)
perf tests: Move test__syscall_open_tp_fields into separate object
Separating test__syscall_open_tp_fields test from the builtin-test into open-syscall-tp-fields 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-10-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.c112
1 files changed, 0 insertions, 112 deletions
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index c66caa79c622..bab849039852 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -35,118 +35,6 @@ static int test__perf_pmu(void)
35 return perf_pmu__test(); 35 return perf_pmu__test();
36} 36}
37 37
38static int test__syscall_open_tp_fields(void)
39{
40 struct perf_record_opts opts = {
41 .target = {
42 .uid = UINT_MAX,
43 .uses_mmap = true,
44 },
45 .no_delay = true,
46 .freq = 1,
47 .mmap_pages = 256,
48 .raw_samples = true,
49 };
50 const char *filename = "/etc/passwd";
51 int flags = O_RDONLY | O_DIRECTORY;
52 struct perf_evlist *evlist = perf_evlist__new(NULL, NULL);
53 struct perf_evsel *evsel;
54 int err = -1, i, nr_events = 0, nr_polls = 0;
55
56 if (evlist == NULL) {
57 pr_debug("%s: perf_evlist__new\n", __func__);
58 goto out;
59 }
60
61 evsel = perf_evsel__newtp("syscalls", "sys_enter_open", 0);
62 if (evsel == NULL) {
63 pr_debug("%s: perf_evsel__newtp\n", __func__);
64 goto out_delete_evlist;
65 }
66
67 perf_evlist__add(evlist, evsel);
68
69 err = perf_evlist__create_maps(evlist, &opts.target);
70 if (err < 0) {
71 pr_debug("%s: perf_evlist__create_maps\n", __func__);
72 goto out_delete_evlist;
73 }
74
75 perf_evsel__config(evsel, &opts, evsel);
76
77 evlist->threads->map[0] = getpid();
78
79 err = perf_evlist__open(evlist);
80 if (err < 0) {
81 pr_debug("perf_evlist__open: %s\n", strerror(errno));
82 goto out_delete_evlist;
83 }
84
85 err = perf_evlist__mmap(evlist, UINT_MAX, false);
86 if (err < 0) {
87 pr_debug("perf_evlist__mmap: %s\n", strerror(errno));
88 goto out_delete_evlist;
89 }
90
91 perf_evlist__enable(evlist);
92
93 /*
94 * Generate the event:
95 */
96 open(filename, flags);
97
98 while (1) {
99 int before = nr_events;
100
101 for (i = 0; i < evlist->nr_mmaps; i++) {
102 union perf_event *event;
103
104 while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
105 const u32 type = event->header.type;
106 int tp_flags;
107 struct perf_sample sample;
108
109 ++nr_events;
110
111 if (type != PERF_RECORD_SAMPLE)
112 continue;
113
114 err = perf_evsel__parse_sample(evsel, event, &sample);
115 if (err) {
116 pr_err("Can't parse sample, err = %d\n", err);
117 goto out_munmap;
118 }
119
120 tp_flags = perf_evsel__intval(evsel, &sample, "flags");
121
122 if (flags != tp_flags) {
123 pr_debug("%s: Expected flags=%#x, got %#x\n",
124 __func__, flags, tp_flags);
125 goto out_munmap;
126 }
127
128 goto out_ok;
129 }
130 }
131
132 if (nr_events == before)
133 poll(evlist->pollfd, evlist->nr_fds, 10);
134
135 if (++nr_polls > 5) {
136 pr_debug("%s: no events!\n", __func__);
137 goto out_munmap;
138 }
139 }
140out_ok:
141 err = 0;
142out_munmap:
143 perf_evlist__munmap(evlist);
144out_delete_evlist:
145 perf_evlist__delete(evlist);
146out:
147 return err;
148}
149
150static struct test { 38static struct test {
151 const char *desc; 39 const char *desc;
152 int (*func)(void); 40 int (*func)(void);