Commit 1b1c6a2
committed
selftests/bpf: Fix map_ptr test cases for CPUMAP, HASHMAP
The map_ptr test fails on a 4 vCPU QEMU/armhf system with error E2BIG:
root@qemu-armhf:/usr/libexec/kselftests-bpf# ./test_progs -a map_ptr
test_map_ptr:PASS:skel_open 0 nsec
test_map_ptr:FAIL:skel_load unexpected error: -7 (errno 7)
torvalds#192 map_ptr:FAIL
This results from trying to create a CPUMAP map with 'max_entries' set to
8, since the kernel limits this to the number of logical CPUs (i.e. 4).
Fix by determining the number of CPUs and setting 'max_entries' from
userspace, similar to the RINGBUF map setup.
The last fix reveals another bug where the HASHMAP subtest hard-codes
the expected htab element size assuming a 64-bit host, which fails on
32-bit armhf because 'struct htab_elem' depends on host word size. As
above, fix this by determining the correct element size and writing the
expected value from userspace. Since the 'struct htab_elem' declaration
is not in uapi, create a local version that captures the same type/size
and alignment variation with system word size. While not ideal, this is
still better than hard-coding a single value.
Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>1 parent 140735e commit 1b1c6a2
File tree
2 files changed
+28
-3
lines changed- tools/testing/selftests/bpf
- prog_tests
- progs
2 files changed
+28
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
15 | 30 | | |
16 | 31 | | |
17 | 32 | | |
| |||
25 | 40 | | |
26 | 41 | | |
27 | 42 | | |
| 43 | + | |
28 | 44 | | |
29 | 45 | | |
30 | 46 | | |
31 | 47 | | |
32 | 48 | | |
33 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
34 | 56 | | |
35 | 57 | | |
36 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
114 | 117 | | |
115 | 118 | | |
116 | 119 | | |
117 | | - | |
| 120 | + | |
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
| |||
463 | 466 | | |
464 | 467 | | |
465 | 468 | | |
466 | | - | |
| 469 | + | |
467 | 470 | | |
468 | 471 | | |
469 | 472 | | |
| |||
0 commit comments