/* check that user is able to pass in a null callback_ctx */
link = bpf_program__attach(skel->progs.prog_null_ctx); if (!ASSERT_OK_PTR(link, "link")) return;
/* check that passing in non-zero flags returns -EINVAL */
link = bpf_program__attach(skel->progs.prog_invalid_flags); if (!ASSERT_OK_PTR(link, "link")) return;
staticvoid check_stack(struct bpf_loop *skel)
{ struct bpf_link *link = bpf_program__attach(skel->progs.stack_check); constint max_key = 12; int key; int map_fd;
if (!ASSERT_OK_PTR(link, "link")) return;
map_fd = bpf_map__fd(skel->maps.map1);
if (!ASSERT_GE(map_fd, 0, "bpf_map__fd")) goto out;
for (key = 1; key <= max_key; ++key) { int val = key; int err = bpf_map_update_elem(map_fd, &key, &val, BPF_NOEXIST);
if (!ASSERT_OK(err, "bpf_map_update_elem")) goto out;
}
usleep(1);
for (key = 1; key <= max_key; ++key) { int val; int err = bpf_map_lookup_elem(map_fd, &key, &val);
if (!ASSERT_OK(err, "bpf_map_lookup_elem")) goto out; if (!ASSERT_EQ(val, key + 1, "bad value in the map")) goto out;
}
out:
bpf_link__destroy(link);
}
void test_bpf_loop(void)
{ struct bpf_loop *skel;
skel = bpf_loop__open_and_load(); if (!ASSERT_OK_PTR(skel, "bpf_loop__open_and_load")) return;
skel->bss->pid = getpid();
if (test__start_subtest("check_nr_loops"))
check_nr_loops(skel); if (test__start_subtest("check_callback_fn_stop"))
check_callback_fn_stop(skel); if (test__start_subtest("check_null_callback_ctx"))
check_null_callback_ctx(skel); if (test__start_subtest("check_invalid_flags"))
check_invalid_flags(skel); if (test__start_subtest("check_nested_calls"))
check_nested_calls(skel); if (test__start_subtest("check_non_constant_callback"))
check_non_constant_callback(skel); if (test__start_subtest("check_stack"))
check_stack(skel);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.