mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 21:44:06 +08:00
selftests/bpf: test_progs: remove asserts from subtests
Otherwise they can bring the whole process down. Cc: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
d38835b75f
commit
62d69f24fe
@ -48,15 +48,17 @@ void test_bpf_obj_id(void)
|
||||
/* test_obj_id.o is a dumb prog. It should never fail
|
||||
* to load.
|
||||
*/
|
||||
CHECK_FAIL(err);
|
||||
assert(!err);
|
||||
if (CHECK_FAIL(err))
|
||||
continue;
|
||||
|
||||
/* Insert a magic value to the map */
|
||||
map_fds[i] = bpf_find_map(__func__, objs[i], "test_map_id");
|
||||
assert(map_fds[i] >= 0);
|
||||
if (CHECK_FAIL(map_fds[i] < 0))
|
||||
goto done;
|
||||
err = bpf_map_update_elem(map_fds[i], &array_key,
|
||||
&array_magic_value, 0);
|
||||
assert(!err);
|
||||
if (CHECK_FAIL(err))
|
||||
goto done;
|
||||
|
||||
/* Check getting map info */
|
||||
info_len = sizeof(struct bpf_map_info) * 2;
|
||||
@ -95,9 +97,11 @@ void test_bpf_obj_id(void)
|
||||
prog_infos[i].map_ids = ptr_to_u64(map_ids + i);
|
||||
prog_infos[i].nr_map_ids = 2;
|
||||
err = clock_gettime(CLOCK_REALTIME, &real_time_ts);
|
||||
assert(!err);
|
||||
if (CHECK_FAIL(err))
|
||||
goto done;
|
||||
err = clock_gettime(CLOCK_BOOTTIME, &boot_time_ts);
|
||||
assert(!err);
|
||||
if (CHECK_FAIL(err))
|
||||
goto done;
|
||||
err = bpf_obj_get_info_by_fd(prog_fds[i], &prog_infos[i],
|
||||
&info_len);
|
||||
load_time = (real_time_ts.tv_sec - boot_time_ts.tv_sec)
|
||||
@ -223,7 +227,8 @@ void test_bpf_obj_id(void)
|
||||
nr_id_found++;
|
||||
|
||||
err = bpf_map_lookup_elem(map_fd, &array_key, &array_value);
|
||||
assert(!err);
|
||||
if (CHECK_FAIL(err))
|
||||
goto done;
|
||||
|
||||
err = bpf_obj_get_info_by_fd(map_fd, &map_info, &info_len);
|
||||
CHECK(err || info_len != sizeof(struct bpf_map_info) ||
|
||||
|
@ -54,17 +54,22 @@ void test_map_lock(void)
|
||||
bpf_map_update_elem(map_fd[0], &key, vars, BPF_F_LOCK);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
assert(pthread_create(&thread_id[i], NULL,
|
||||
&spin_lock_thread, &prog_fd) == 0);
|
||||
if (CHECK_FAIL(pthread_create(&thread_id[i], NULL,
|
||||
&spin_lock_thread, &prog_fd)))
|
||||
goto close_prog;
|
||||
for (i = 4; i < 6; i++)
|
||||
assert(pthread_create(&thread_id[i], NULL,
|
||||
¶llel_map_access, &map_fd[i - 4]) == 0);
|
||||
if (CHECK_FAIL(pthread_create(&thread_id[i], NULL,
|
||||
¶llel_map_access,
|
||||
&map_fd[i - 4])))
|
||||
goto close_prog;
|
||||
for (i = 0; i < 4; i++)
|
||||
assert(pthread_join(thread_id[i], &ret) == 0 &&
|
||||
ret == (void *)&prog_fd);
|
||||
if (CHECK_FAIL(pthread_join(thread_id[i], &ret) ||
|
||||
ret != (void *)&prog_fd))
|
||||
goto close_prog;
|
||||
for (i = 4; i < 6; i++)
|
||||
assert(pthread_join(thread_id[i], &ret) == 0 &&
|
||||
ret == (void *)&map_fd[i - 4]);
|
||||
if (CHECK_FAIL(pthread_join(thread_id[i], &ret) ||
|
||||
ret != (void *)&map_fd[i - 4]))
|
||||
goto close_prog;
|
||||
close_prog:
|
||||
bpf_object__close(obj);
|
||||
}
|
||||
|
@ -16,12 +16,14 @@ void test_spinlock(void)
|
||||
goto close_prog;
|
||||
}
|
||||
for (i = 0; i < 4; i++)
|
||||
assert(pthread_create(&thread_id[i], NULL,
|
||||
&spin_lock_thread, &prog_fd) == 0);
|
||||
for (i = 0; i < 4; i++)
|
||||
assert(pthread_join(thread_id[i], &ret) == 0 &&
|
||||
ret == (void *)&prog_fd);
|
||||
if (CHECK_FAIL(pthread_create(&thread_id[i], NULL,
|
||||
&spin_lock_thread, &prog_fd)))
|
||||
goto close_prog;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
if (CHECK_FAIL(pthread_join(thread_id[i], &ret) ||
|
||||
ret != (void *)&prog_fd))
|
||||
goto close_prog;
|
||||
close_prog:
|
||||
bpf_object__close(obj);
|
||||
}
|
||||
|
@ -51,9 +51,10 @@ retry:
|
||||
"err %d errno %d\n", err, errno))
|
||||
goto disable_pmu;
|
||||
|
||||
assert(system("dd if=/dev/urandom of=/dev/zero count=4 2> /dev/null")
|
||||
== 0);
|
||||
assert(system("./urandom_read") == 0);
|
||||
if (CHECK_FAIL(system("dd if=/dev/urandom of=/dev/zero count=4 2> /dev/null")))
|
||||
goto disable_pmu;
|
||||
if (CHECK_FAIL(system("./urandom_read")))
|
||||
goto disable_pmu;
|
||||
/* disable stack trace collection */
|
||||
key = 0;
|
||||
val = 1;
|
||||
|
@ -82,9 +82,10 @@ retry:
|
||||
"err %d errno %d\n", err, errno))
|
||||
goto disable_pmu;
|
||||
|
||||
assert(system("dd if=/dev/urandom of=/dev/zero count=4 2> /dev/null")
|
||||
== 0);
|
||||
assert(system("taskset 0x1 ./urandom_read 100000") == 0);
|
||||
if (CHECK_FAIL(system("dd if=/dev/urandom of=/dev/zero count=4 2> /dev/null")))
|
||||
goto disable_pmu;
|
||||
if (CHECK_FAIL(system("taskset 0x1 ./urandom_read 100000")))
|
||||
goto disable_pmu;
|
||||
/* disable stack trace collection */
|
||||
key = 0;
|
||||
val = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user