Skip to content

Commit

Permalink
Merge branch 'selftests/bpf: parallel mode improvement'
Browse files Browse the repository at this point in the history
Yucong Sun says:

====================

Several patches to improve parallel execution mode, updating vmtest.sh
and fixed two previously dropped patches according to feedback.
====================

Signed-off-by: Andrii Nakryiko <[email protected]>
  • Loading branch information
anakryiko committed Oct 27, 2021
2 parents f9d532f + e1ef62a commit 03e6a7a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
9 changes: 7 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/attach_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
/* this is how USDT semaphore is actually defined, except volatile modifier */
volatile unsigned short uprobe_ref_ctr __attribute__((unused)) __attribute((section(".probes")));

/* attach point */
static void method(void) {
return ;
}

void test_attach_probe(void)
{
DECLARE_LIBBPF_OPTS(bpf_uprobe_opts, uprobe_opts);
Expand Down Expand Up @@ -33,7 +38,7 @@ void test_attach_probe(void)
if (CHECK(base_addr < 0, "get_base_addr",
"failed to find base addr: %zd", base_addr))
return;
uprobe_offset = get_uprobe_offset(&get_base_addr, base_addr);
uprobe_offset = get_uprobe_offset(&method, base_addr);

ref_ctr_offset = get_rel_offset((uintptr_t)&uprobe_ref_ctr);
if (!ASSERT_GE(ref_ctr_offset, 0, "ref_ctr_offset"))
Expand Down Expand Up @@ -98,7 +103,7 @@ void test_attach_probe(void)
goto cleanup;

/* trigger & validate uprobe & uretprobe */
get_base_addr();
method();

if (CHECK(skel->bss->uprobe_res != 3, "check_uprobe_res",
"wrong uprobe res: %d\n", skel->bss->uprobe_res))
Expand Down
14 changes: 14 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/tc_redirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ static int netns_setup_namespaces(const char *verb)
return 0;
}

static void netns_setup_namespaces_nofail(const char *verb)
{
const char * const *ns = namespaces;
char cmd[128];

while (*ns) {
snprintf(cmd, sizeof(cmd), "ip netns %s %s > /dev/null 2>&1", verb, *ns);
system(cmd);
ns++;
}
}

struct netns_setup_result {
int ifindex_veth_src_fwd;
int ifindex_veth_dst_fwd;
Expand Down Expand Up @@ -762,6 +774,8 @@ static void test_tc_redirect_peer_l3(struct netns_setup_result *setup_result)

static void *test_tc_redirect_run_tests(void *arg)
{
netns_setup_namespaces_nofail("delete");

RUN_TEST(tc_redirect_peer);
RUN_TEST(tc_redirect_peer_l3);
RUN_TEST(tc_redirect_neigh);
Expand Down
6 changes: 3 additions & 3 deletions tools/testing/selftests/bpf/vmtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@ EOF
-nodefaults \
-display none \
-serial mon:stdio \
-cpu kvm64 \
-cpu host \
-enable-kvm \
-smp 4 \
-m 2G \
-smp 8 \
-m 4G \
-drive file="${rootfs_img}",format=raw,index=1,media=disk,if=virtio,cache=none \
-kernel "${kernel_bzimage}" \
-append "root=/dev/vda rw console=ttyS0,115200"
Expand Down

0 comments on commit 03e6a7a

Please sign in to comment.