Skip to content

Commit 6c053ee

Browse files
committed
DEBUG: selftests/bpf: Show lskel attach broken (ringbuf_overwrite)
Attaching BPF kprobe program via lskel fails silently on armhf 32-bit: the program is never called when triggered and results in many strange test failures, especially since testcode often neglects unhappy paths. Before: root@qemu-armhf: # ./test_progs -a ringbuf/ringbuf_overwrite_mode Process ./test_progs created; pid = 125 ringbuf_overwrite_mode_subtest:PASS:skel_open 0 nsec ringbuf_overwrite_mode_subtest:PASS:skel_load 0 nsec ringbuf_overwrite_mode_subtest:PASS:skel_attach 0 nsec ringbuf_overwrite_mode_subtest:PASS:reserve 1 0 nsec ringbuf_overwrite_mode_subtest:PASS:reserve 2 0 nsec ringbuf_overwrite_mode_subtest:FAIL:reserve 3 unexpected reserve 3: actual 0 != expected 1 ringbuf_overwrite_mode_subtest:PASS:reserve 4 0 nsec ringbuf_overwrite_mode_subtest:PASS:reserve 5 0 nsec ringbuf_overwrite_mode_subtest:FAIL:check_ring_size unexpected check_ring_size: actual 0 != expected 4096 ringbuf_overwrite_mode_subtest:FAIL:check_avail_size unexpected check_avail_size: actual 0 != expected 3040 ringbuf_overwrite_mode_subtest:PASS:check_cons_pos 0 nsec ringbuf_overwrite_mode_subtest:FAIL:check_prod_pos unexpected check_prod_pos: actual 0 != expected 5096 ringbuf_overwrite_mode_subtest:FAIL:check_over_pos unexpected check_over_pos: actual 0 != expected 2056 torvalds#358/5 ringbuf/ringbuf_overwrite_mode:FAIL torvalds#358 ringbuf:FAIL After patch switching to use libbpf skel instead of lskel: root@qemu-armhf: # ./test_progs -a ringbuf/ringbuf_overwrite_mode torvalds#358/5 ringbuf/ringbuf_overwrite_mode:OK torvalds#358 ringbuf:OK Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>
1 parent 88d10f8 commit 6c053ee

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,7 @@ LINKED_SKELS := test_static_linked.skel.h linked_funcs.skel.h \
507507

508508
LSKELS := fexit_sleep.c trace_printk.c trace_vprintk.c map_ptr_kern.c \
509509
core_kern.c core_kern_overflow.c test_ringbuf.c \
510-
test_ringbuf_n.c test_ringbuf_map_key.c test_ringbuf_write.c \
511-
test_ringbuf_overwrite.c
510+
test_ringbuf_n.c test_ringbuf_map_key.c test_ringbuf_write.c
512511

513512
LSKELS_SIGNED := fentry_test.c fexit_test.c atomics.c
514513

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "test_ringbuf_n.lskel.h"
1818
#include "test_ringbuf_map_key.lskel.h"
1919
#include "test_ringbuf_write.lskel.h"
20-
#include "test_ringbuf_overwrite.lskel.h"
20+
#include "test_ringbuf_overwrite.skel.h"
2121

2222
#define EDONE 7777
2323

@@ -502,11 +502,11 @@ static void ringbuf_overwrite_mode_subtest(void)
502502
{
503503
unsigned long size, len1, len2, len3, len4, len5;
504504
unsigned long expect_avail_data, expect_prod_pos, expect_over_pos;
505-
struct test_ringbuf_overwrite_lskel *skel;
505+
struct test_ringbuf_overwrite *skel;
506506
int page_size = getpagesize();
507507
int err;
508508

509-
skel = test_ringbuf_overwrite_lskel__open();
509+
skel = test_ringbuf_overwrite__open();
510510
if (!ASSERT_OK_PTR(skel, "skel_open"))
511511
return;
512512

@@ -517,7 +517,7 @@ static void ringbuf_overwrite_mode_subtest(void)
517517
len4 = len3 - 8;
518518
len5 = len3; /* retry with len3 */
519519

520-
skel->maps.ringbuf.max_entries = size;
520+
bpf_map__set_max_entries(skel->maps.ringbuf, size);
521521
skel->rodata->LEN1 = len1;
522522
skel->rodata->LEN2 = len2;
523523
skel->rodata->LEN3 = len3;
@@ -526,11 +526,11 @@ static void ringbuf_overwrite_mode_subtest(void)
526526

527527
skel->bss->pid = getpid();
528528

529-
err = test_ringbuf_overwrite_lskel__load(skel);
529+
err = test_ringbuf_overwrite__load(skel);
530530
if (!ASSERT_OK(err, "skel_load"))
531531
goto cleanup;
532532

533-
err = test_ringbuf_overwrite_lskel__attach(skel);
533+
err = test_ringbuf_overwrite__attach(skel);
534534
if (!ASSERT_OK(err, "skel_attach"))
535535
goto cleanup;
536536

@@ -555,9 +555,9 @@ static void ringbuf_overwrite_mode_subtest(void)
555555
expect_over_pos = len1 + BPF_RINGBUF_HDR_SZ;
556556
ASSERT_EQ(skel->bss->over_pos, expect_over_pos, "check_over_pos");
557557

558-
test_ringbuf_overwrite_lskel__detach(skel);
558+
test_ringbuf_overwrite__detach(skel);
559559
cleanup:
560-
test_ringbuf_overwrite_lskel__destroy(skel);
560+
test_ringbuf_overwrite__destroy(skel);
561561
}
562562

563563
void test_ringbuf(void)

0 commit comments

Comments
 (0)