Skip to content

Commit acbf1b8

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
selftests/bpf: Skip ENOTSUPP in ASSERT_OK
Just like handling ENOTSUPP in test_lsm_cgroup_functional(), this patch checks ENOTSUPP (524) and ENOTSUP (95) in ASSERT_OK(), invoke test__skip() in this case instead of test__fail(). Signed-off-by: Geliang Tang <[email protected]>
1 parent 1bc3250 commit acbf1b8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,8 @@ static void test_lsm_cgroup_functional(void)
102102
ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 0, "prog count");
103103
ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 0, "total prog count");
104104
err = bpf_prog_attach(alloc_prog_fd, cgroup_fd, BPF_LSM_CGROUP, 0);
105-
if (err == -ENOTSUPP) {
106-
test__skip();
107-
goto close_cgroup;
108-
}
109105
if (!ASSERT_OK(err, "attach alloc_prog_fd"))
110-
goto detach_cgroup;
106+
goto close_cgroup;
111107
ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 1, "prog count");
112108
ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 1, "total prog count");
113109

tools/testing/selftests/bpf/test_progs.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,13 @@ int test__join_cgroup(const char *path);
338338
static int duration = 0; \
339339
long long ___res = (res); \
340340
bool ___ok = ___res == 0; \
341-
CHECK(!___ok, (name), "unexpected error: %lld (errno %d)\n", \
342-
___res, errno); \
341+
if (___res == -ENOTSUPP || ___res == -ENOTSUP || \
342+
errno == ENOTSUPP || errno == ENOTSUP) \
343+
test__skip(); \
344+
else \
345+
CHECK(!___ok, (name), \
346+
"unexpected error: %lld (errno %d)\n", \
347+
___res, errno); \
343348
___ok; \
344349
})
345350

0 commit comments

Comments
 (0)