Skip to content

Commit 37c68d7

Browse files
tohojokernel-patches-bot
authored andcommitted
selftests/bpf_iter: don't fail test due to missing __builtin_btf_type_id
The new test for task iteration in bpf_iter checks (in do_btf_read()) if it should be skipped due to missing __builtin_btf_type_id. However, this 'skip' verdict is not propagated to the caller, so the parent test will still fail. Fix this by also skipping the rest of the parent test if the skip condition was reached. Fixes: b72091b ("selftests/bpf: Add test for bpf_seq_printf_btf helper") Signed-off-by: Toke Høiland-Jørgensen <[email protected]> Reviewed-by: Alan Maguire <[email protected]>
1 parent 1c7ecf0 commit 37c68d7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,18 @@ static void test_task_file(void)
172172

173173
static char taskbuf[TASKBUFSZ];
174174

175-
static void do_btf_read(struct bpf_iter_task_btf *skel)
175+
static int do_btf_read(struct bpf_iter_task_btf *skel)
176176
{
177177
struct bpf_program *prog = skel->progs.dump_task_struct;
178178
struct bpf_iter_task_btf__bss *bss = skel->bss;
179179
int iter_fd = -1, len = 0, bufleft = TASKBUFSZ;
180180
struct bpf_link *link;
181181
char *buf = taskbuf;
182+
int ret = 0;
182183

183184
link = bpf_program__attach_iter(prog, NULL);
184185
if (CHECK(IS_ERR(link), "attach_iter", "attach_iter failed\n"))
185-
return;
186+
return ret;
186187

187188
iter_fd = bpf_iter_create(bpf_link__fd(link));
188189
if (CHECK(iter_fd < 0, "create_iter", "create_iter failed\n"))
@@ -198,6 +199,7 @@ static void do_btf_read(struct bpf_iter_task_btf *skel)
198199

199200
if (bss->skip) {
200201
printf("%s:SKIP:no __builtin_btf_type_id\n", __func__);
202+
ret = 1;
201203
test__skip();
202204
goto free_link;
203205
}
@@ -212,12 +214,14 @@ static void do_btf_read(struct bpf_iter_task_btf *skel)
212214
if (iter_fd > 0)
213215
close(iter_fd);
214216
bpf_link__destroy(link);
217+
return ret;
215218
}
216219

217220
static void test_task_btf(void)
218221
{
219222
struct bpf_iter_task_btf__bss *bss;
220223
struct bpf_iter_task_btf *skel;
224+
int ret;
221225

222226
skel = bpf_iter_task_btf__open_and_load();
223227
if (CHECK(!skel, "bpf_iter_task_btf__open_and_load",
@@ -226,7 +230,9 @@ static void test_task_btf(void)
226230

227231
bss = skel->bss;
228232

229-
do_btf_read(skel);
233+
ret = do_btf_read(skel);
234+
if (ret)
235+
goto cleanup;
230236

231237
if (CHECK(bss->tasks == 0, "check if iterated over tasks",
232238
"no task iteration, did BPF program run?\n"))

0 commit comments

Comments
 (0)