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

selftests/bpf: Add a dedup selftest with equivalent structure types

Without previous libbpf patch, the following error will occur:

$ ./test_progs -t btf
...
do_test_dedup:FAIL:check btf_dedup failed errno:-22#13/205 btf/dedup: btf_type_tag #5, struct:FAIL

And the previous libbpf patch fixed the issue.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20211115163943.3922547-1-yhs@fb.com

authored by

Yonghong Song and committed by
Daniel Borkmann
47461583 69a055d5

+26
+26
tools/testing/selftests/bpf/prog_tests/btf.c
··· 7352 7352 BTF_STR_SEC("\0tag1"), 7353 7353 }, 7354 7354 }, 7355 + { 7356 + .descr = "dedup: btf_type_tag #5, struct", 7357 + .input = { 7358 + .raw_types = { 7359 + BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ 7360 + BTF_TYPE_TAG_ENC(NAME_NTH(1), 1), /* [2] */ 7361 + BTF_TYPE_ENC(NAME_NTH(2), BTF_INFO_ENC(BTF_KIND_STRUCT, 1, 1), 4), /* [3] */ 7362 + BTF_MEMBER_ENC(NAME_NTH(3), 2, BTF_MEMBER_OFFSET(0, 0)), 7363 + BTF_TYPE_TAG_ENC(NAME_NTH(1), 1), /* [4] */ 7364 + BTF_TYPE_ENC(NAME_NTH(2), BTF_INFO_ENC(BTF_KIND_STRUCT, 1, 1), 4), /* [5] */ 7365 + BTF_MEMBER_ENC(NAME_NTH(3), 4, BTF_MEMBER_OFFSET(0, 0)), 7366 + BTF_END_RAW, 7367 + }, 7368 + BTF_STR_SEC("\0tag1\0t\0m"), 7369 + }, 7370 + .expect = { 7371 + .raw_types = { 7372 + BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ 7373 + BTF_TYPE_TAG_ENC(NAME_NTH(1), 1), /* [2] */ 7374 + BTF_TYPE_ENC(NAME_NTH(2), BTF_INFO_ENC(BTF_KIND_STRUCT, 1, 1), 4), /* [3] */ 7375 + BTF_MEMBER_ENC(NAME_NTH(3), 2, BTF_MEMBER_OFFSET(0, 0)), 7376 + BTF_END_RAW, 7377 + }, 7378 + BTF_STR_SEC("\0tag1\0t\0m"), 7379 + }, 7380 + }, 7355 7381 7356 7382 }; 7357 7383