]> www.infradead.org Git - linux.git/commitdiff
perf test: Skip not fail syscall tp fields test when insufficient permissions
authorIan Rogers <irogers@google.com>
Tue, 1 Oct 2024 05:23:27 +0000 (22:23 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 2 Oct 2024 21:58:03 +0000 (14:58 -0700)
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>
tools/perf/tests/openat-syscall-tp-fields.c

index 888df8eca9812123e48763c43e4ebb697fd14909..3943da441979c0fcd7e90333512681cb3a0dc7ca 100644 (file)
@@ -40,7 +40,7 @@ static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused
        int flags = O_RDONLY | O_DIRECTORY;
        struct evlist *evlist = evlist__new();
        struct evsel *evsel;
-       int err = -1, i, nr_events = 0, nr_polls = 0;
+       int ret = TEST_FAIL, err, i, nr_events = 0, nr_polls = 0;
        char sbuf[STRERR_BUFSIZE];
 
        if (evlist == NULL) {
@@ -51,6 +51,7 @@ static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused
        evsel = evsel__newtp("syscalls", "sys_enter_openat");
        if (IS_ERR(evsel)) {
                pr_debug("%s: evsel__newtp\n", __func__);
+               ret = PTR_ERR(evsel) == -EACCES ? TEST_SKIP : TEST_FAIL;
                goto out_delete_evlist;
        }
 
@@ -138,11 +139,21 @@ static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused
                }
        }
 out_ok:
-       err = 0;
+       ret = TEST_OK;
 out_delete_evlist:
        evlist__delete(evlist);
 out:
-       return err;
+       return ret;
 }
 
-DEFINE_SUITE("syscalls:sys_enter_openat event fields", syscall_openat_tp_fields);
+static struct test_case tests__syscall_openat_tp_fields[] = {
+       TEST_CASE_REASON("syscalls:sys_enter_openat event fields",
+                        syscall_openat_tp_fields,
+                        "permissions"),
+       {       .name = NULL, }
+};
+
+struct test_suite suite__syscall_openat_tp_fields = {
+       .desc = "syscalls:sys_enter_openat event fields",
+       .test_cases = tests__syscall_openat_tp_fields,
+};