Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf, test_offload.py: Skip base maps without names

The test fails:

# ./test_offload.py
[...]
Test bpftool bound info reporting (own ns)...
FAIL: 3 BPF maps loaded, expected 2
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 1177, in <module>
check_dev_info(False, "")
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 645, in check_dev_info
maps = bpftool_map_list(expected=2, ns=ns)
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 190, in bpftool_map_list
fail(True, "%d BPF maps loaded, expected %d" %
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 86, in fail
tb = "".join(traceback.extract_stack().format())

Some base maps do not have names and they cannot be added due to compatibility
with older kernels, see [0]. So, just skip the unnamed maps.

[0] https://lore.kernel.org/bpf/CAEf4BzY66WPKQbDe74AKZ6nFtZjq5e+G3Ji2egcVytB9R6_sGQ@mail.gmail.com/

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20220329081100.9705-1-ykaliuta@redhat.com

authored by

Yauheni Kaliuta and committed by
Daniel Borkmann
891663ac 8eb943fc

+1 -1
+1 -1
tools/testing/selftests/bpf/test_offload.py
··· 184 184 def bpftool_map_list(expected=None, ns=""): 185 185 _, maps = bpftool("map show", JSON=True, ns=ns, fail=True) 186 186 # Remove the base maps 187 - maps = [m for m in maps if m not in base_maps and m.get('name') not in base_map_names] 187 + maps = [m for m in maps if m not in base_maps and m.get('name') and m.get('name') not in base_map_names] 188 188 if expected is not None: 189 189 if len(maps) != expected: 190 190 fail(True, "%d BPF maps loaded, expected %d" %