diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-10-31 10:52:47 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-31 14:20:58 -0400 |
commit | 52502bf201a85b5b51a384037a002d0b39093df0 (patch) | |
tree | c4d2bcbc4c1f7c10693b132ad70951c06c2cee86 /tools/perf/perf.h | |
parent | 945aea220bb8f4bb37950549cc0b93bbec24c460 (diff) |
perf tests: Add framework for automated perf_event_attr tests
The idea is run perf session with kidnapping sys_perf_event_open
function. For each sys_perf_event_open call we store the perf_event_attr
data to the file to be checked later against what we expect.
You can run this by:
$ python ./tests/attr.py -d ./tests/attr/ -p ./perf -v
v2 changes:
- preserve errno value in the hook
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
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/20121031145247.GB1027@krava.brq.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/perf.h')
-rw-r--r-- | tools/perf/perf.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 469fbf2daea4..00472646b3bf 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h | |||
@@ -174,13 +174,25 @@ static inline unsigned long long rdclock(void) | |||
174 | (void) (&_min1 == &_min2); \ | 174 | (void) (&_min1 == &_min2); \ |
175 | _min1 < _min2 ? _min1 : _min2; }) | 175 | _min1 < _min2 ? _min1 : _min2; }) |
176 | 176 | ||
177 | extern bool test_attr__enabled; | ||
178 | void test_attr__init(void); | ||
179 | void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, | ||
180 | int fd, int group_fd, unsigned long flags); | ||
181 | |||
177 | static inline int | 182 | static inline int |
178 | sys_perf_event_open(struct perf_event_attr *attr, | 183 | sys_perf_event_open(struct perf_event_attr *attr, |
179 | pid_t pid, int cpu, int group_fd, | 184 | pid_t pid, int cpu, int group_fd, |
180 | unsigned long flags) | 185 | unsigned long flags) |
181 | { | 186 | { |
182 | return syscall(__NR_perf_event_open, attr, pid, cpu, | 187 | int fd; |
183 | group_fd, flags); | 188 | |
189 | fd = syscall(__NR_perf_event_open, attr, pid, cpu, | ||
190 | group_fd, flags); | ||
191 | |||
192 | if (unlikely(test_attr__enabled)) | ||
193 | test_attr__open(attr, pid, cpu, fd, group_fd, flags); | ||
194 | |||
195 | return fd; | ||
184 | } | 196 | } |
185 | 197 | ||
186 | #define MAX_COUNTERS 256 | 198 | #define MAX_COUNTERS 256 |