1 #include "thread_map.h"
6 int test__open_syscall_event(void)
9 struct perf_evsel
*evsel
;
10 unsigned int nr_open_calls
= 111, i
;
11 struct thread_map
*threads
= thread_map__new(-1, getpid(), UINT_MAX
);
13 if (threads
== NULL
) {
14 pr_debug("thread_map__new\n");
18 evsel
= perf_evsel__newtp("syscalls", "sys_enter_open", 0);
20 pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
21 goto out_thread_map_delete
;
24 if (perf_evsel__open_per_thread(evsel
, threads
) < 0) {
25 pr_debug("failed to open counter: %s, "
26 "tweak /proc/sys/kernel/perf_event_paranoid?\n",
28 goto out_evsel_delete
;
31 for (i
= 0; i
< nr_open_calls
; ++i
) {
32 fd
= open("/etc/passwd", O_RDONLY
);
36 if (perf_evsel__read_on_cpu(evsel
, 0, 0) < 0) {
37 pr_debug("perf_evsel__read_on_cpu\n");
41 if (evsel
->counts
->cpu
[0].val
!= nr_open_calls
) {
42 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64
"\n",
43 nr_open_calls
, evsel
->counts
->cpu
[0].val
);
49 perf_evsel__close_fd(evsel
, 1, threads
->nr
);
51 perf_evsel__delete(evsel
);
52 out_thread_map_delete
:
53 thread_map__delete(threads
);