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

Configure Feed

Select the types of activity you want to include in your feed.

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: b72091bd4ee4 ("selftests/bpf: Add test for bpf_seq_printf_btf helper")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/bpf/20200929123004.46694-1-toke@redhat.com

authored by

Toke Høiland-Jørgensen and committed by
Alexei Starovoitov
d2197c7f 9d9aae53

+9 -3
+9 -3
tools/testing/selftests/bpf/prog_tests/bpf_iter.c
··· 172 172 173 173 static char taskbuf[TASKBUFSZ]; 174 174 175 - static void do_btf_read(struct bpf_iter_task_btf *skel) 175 + static int do_btf_read(struct bpf_iter_task_btf *skel) 176 176 { 177 177 struct bpf_program *prog = skel->progs.dump_task_struct; 178 178 struct bpf_iter_task_btf__bss *bss = skel->bss; 179 179 int iter_fd = -1, len = 0, bufleft = TASKBUFSZ; 180 180 struct bpf_link *link; 181 181 char *buf = taskbuf; 182 + int ret = 0; 182 183 183 184 link = bpf_program__attach_iter(prog, NULL); 184 185 if (CHECK(IS_ERR(link), "attach_iter", "attach_iter failed\n")) 185 - return; 186 + return ret; 186 187 187 188 iter_fd = bpf_iter_create(bpf_link__fd(link)); 188 189 if (CHECK(iter_fd < 0, "create_iter", "create_iter failed\n")) ··· 199 198 200 199 if (bss->skip) { 201 200 printf("%s:SKIP:no __builtin_btf_type_id\n", __func__); 201 + ret = 1; 202 202 test__skip(); 203 203 goto free_link; 204 204 } ··· 214 212 if (iter_fd > 0) 215 213 close(iter_fd); 216 214 bpf_link__destroy(link); 215 + return ret; 217 216 } 218 217 219 218 static void test_task_btf(void) 220 219 { 221 220 struct bpf_iter_task_btf__bss *bss; 222 221 struct bpf_iter_task_btf *skel; 222 + int ret; 223 223 224 224 skel = bpf_iter_task_btf__open_and_load(); 225 225 if (CHECK(!skel, "bpf_iter_task_btf__open_and_load", ··· 230 226 231 227 bss = skel->bss; 232 228 233 - do_btf_read(skel); 229 + ret = do_btf_read(skel); 230 + if (ret) 231 + goto cleanup; 234 232 235 233 if (CHECK(bss->tasks == 0, "check if iterated over tasks", 236 234 "no task iteration, did BPF program run?\n"))