1 #include <api/fs/tracing_path.h>
3 #include "thread_map.h"
8 int test__openat_syscall_event(int subtest __maybe_unused
)
11 struct perf_evsel
*evsel
;
12 unsigned int nr_openat_calls
= 111, i
;
13 struct thread_map
*threads
= thread_map__new(-1, getpid(), UINT_MAX
);
14 char sbuf
[STRERR_BUFSIZE
];
17 if (threads
== NULL
) {
18 pr_debug("thread_map__new\n");
22 evsel
= perf_evsel__newtp("syscalls", "sys_enter_openat");
24 tracing_path__strerror_open_tp(errno
, errbuf
, sizeof(errbuf
), "syscalls", "sys_enter_openat");
25 pr_debug("%s\n", errbuf
);
26 goto out_thread_map_delete
;
29 if (perf_evsel__open_per_thread(evsel
, threads
) < 0) {
30 pr_debug("failed to open counter: %s, "
31 "tweak /proc/sys/kernel/perf_event_paranoid?\n",
32 strerror_r(errno
, sbuf
, sizeof(sbuf
)));
33 goto out_evsel_delete
;
36 for (i
= 0; i
< nr_openat_calls
; ++i
) {
37 fd
= openat(0, "/etc/passwd", O_RDONLY
);
41 if (perf_evsel__read_on_cpu(evsel
, 0, 0) < 0) {
42 pr_debug("perf_evsel__read_on_cpu\n");
46 if (perf_counts(evsel
->counts
, 0, 0)->val
!= nr_openat_calls
) {
47 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64
"\n",
48 nr_openat_calls
, perf_counts(evsel
->counts
, 0, 0)->val
);
54 perf_evsel__close_fd(evsel
, 1, threads
->nr
);
56 perf_evsel__delete(evsel
);
57 out_thread_map_delete
:
58 thread_map__put(threads
);