3 #include <api/fs/tracing_path.h>
8 #include "thread_map.h"
13 int test__openat_syscall_event(int subtest __maybe_unused)
16 struct perf_evsel *evsel;
17 unsigned int nr_openat_calls = 111, i;
18 struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
19 char sbuf[STRERR_BUFSIZE];
22 if (threads == NULL) {
23 pr_debug("thread_map__new\n");
27 evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
29 tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat");
30 pr_debug("%s\n", errbuf);
31 goto out_thread_map_delete;
34 if (perf_evsel__open_per_thread(evsel, threads) < 0) {
35 pr_debug("failed to open counter: %s, "
36 "tweak /proc/sys/kernel/perf_event_paranoid?\n",
37 str_error_r(errno, sbuf, sizeof(sbuf)));
38 goto out_evsel_delete;
41 for (i = 0; i < nr_openat_calls; ++i) {
42 fd = openat(0, "/etc/passwd", O_RDONLY);
46 if (perf_evsel__read_on_cpu(evsel, 0, 0) < 0) {
47 pr_debug("perf_evsel__read_on_cpu\n");
51 if (perf_counts(evsel->counts, 0, 0)->val != nr_openat_calls) {
52 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n",
53 nr_openat_calls, perf_counts(evsel->counts, 0, 0)->val);
59 perf_evsel__close_fd(evsel, 1, threads->nr);
61 perf_evsel__delete(evsel);
62 out_thread_map_delete:
63 thread_map__put(threads);