Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test: Skip not fail syscall tp fields test when insufficient permissions

Clean up return value to be TEST_* rather than unspecific integer. Add
test case skip reason. Skip test if EACCES comes back from
evsel__newtp.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20241001052327.7052-5-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
ad321b19 7457bcfc

+15 -4
+15 -4
tools/perf/tests/openat-syscall-tp-fields.c
··· 40 40 int flags = O_RDONLY | O_DIRECTORY; 41 41 struct evlist *evlist = evlist__new(); 42 42 struct evsel *evsel; 43 - int err = -1, i, nr_events = 0, nr_polls = 0; 43 + int ret = TEST_FAIL, err, i, nr_events = 0, nr_polls = 0; 44 44 char sbuf[STRERR_BUFSIZE]; 45 45 46 46 if (evlist == NULL) { ··· 51 51 evsel = evsel__newtp("syscalls", "sys_enter_openat"); 52 52 if (IS_ERR(evsel)) { 53 53 pr_debug("%s: evsel__newtp\n", __func__); 54 + ret = PTR_ERR(evsel) == -EACCES ? TEST_SKIP : TEST_FAIL; 54 55 goto out_delete_evlist; 55 56 } 56 57 ··· 139 138 } 140 139 } 141 140 out_ok: 142 - err = 0; 141 + ret = TEST_OK; 143 142 out_delete_evlist: 144 143 evlist__delete(evlist); 145 144 out: 146 - return err; 145 + return ret; 147 146 } 148 147 149 - DEFINE_SUITE("syscalls:sys_enter_openat event fields", syscall_openat_tp_fields); 148 + static struct test_case tests__syscall_openat_tp_fields[] = { 149 + TEST_CASE_REASON("syscalls:sys_enter_openat event fields", 150 + syscall_openat_tp_fields, 151 + "permissions"), 152 + { .name = NULL, } 153 + }; 154 + 155 + struct test_suite suite__syscall_openat_tp_fields = { 156 + .desc = "syscalls:sys_enter_openat event fields", 157 + .test_cases = tests__syscall_openat_tp_fields, 158 + };