diff mbox series

[bpf-next,2/2] selftests/bpf: add a dedup selftest with equivalent structure types

Message ID 20211115163943.3922547-1-yhs@fb.com (mailing list archive)
State Accepted
Commit 4746158305e98c91c479539d53ef9bf8c520dd66
Delegated to: BPF
Headers show
Series bpf: fix a couple of missed btf_type_tag handling in libbpf | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 7 maintainers not CCed: kafai@fb.com songliubraving@fb.com john.fastabend@gmail.com shuah@kernel.org netdev@vger.kernel.org linux-kselftest@vger.kernel.org kpsingh@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 105 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next fail VM_Test

Commit Message

Yonghong Song Nov. 15, 2021, 4:39 p.m. UTC
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 previfous libbpf patch fixed the issue.

Signed-off-by: Yonghong Song <yhs@fb.com>
---
 tools/testing/selftests/bpf/prog_tests/btf.c | 26 ++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Daniel Borkmann Nov. 16, 2021, 12:27 p.m. UTC | #1
On 11/15/21 5:39 PM, Yonghong Song wrote:
> 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 previfous libbpf patch fixed the issue.

Fixed up the typo above while applying and also formatted the 1/2 a bit better.
checkpatch usually has a lot of noise in its output, but it would catch things
like typos when quickly running before submission, fwiw. Anyway, thanks!
Yonghong Song Nov. 16, 2021, 4:19 p.m. UTC | #2
On 11/16/21 4:27 AM, Daniel Borkmann wrote:
> On 11/15/21 5:39 PM, Yonghong Song wrote:
>> 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 previfous libbpf patch fixed the issue.
> 
> Fixed up the typo above while applying and also formatted the 1/2 a bit 
> better.
> checkpatch usually has a lot of noise in its output, but it would catch 
> things
> like typos when quickly running before submission, fwiw. Anyway, thanks!

Thanks for the fixup! I need to remember to run checkpatch even for
small patches!
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c
index 4aa6343dc4c8..f9326a13badb 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf.c
@@ -7352,6 +7352,32 @@  static struct btf_dedup_test dedup_tests[] = {
 		BTF_STR_SEC("\0tag1"),
 	},
 },
+{
+	.descr = "dedup: btf_type_tag #5, struct",
+	.input = {
+		.raw_types = {
+			BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),				/* [1] */
+			BTF_TYPE_TAG_ENC(NAME_NTH(1), 1),					/* [2] */
+			BTF_TYPE_ENC(NAME_NTH(2), BTF_INFO_ENC(BTF_KIND_STRUCT, 1, 1), 4),	/* [3] */
+			BTF_MEMBER_ENC(NAME_NTH(3), 2, BTF_MEMBER_OFFSET(0, 0)),
+			BTF_TYPE_TAG_ENC(NAME_NTH(1), 1),					/* [4] */
+			BTF_TYPE_ENC(NAME_NTH(2), BTF_INFO_ENC(BTF_KIND_STRUCT, 1, 1), 4),	/* [5] */
+			BTF_MEMBER_ENC(NAME_NTH(3), 4, BTF_MEMBER_OFFSET(0, 0)),
+			BTF_END_RAW,
+		},
+		BTF_STR_SEC("\0tag1\0t\0m"),
+	},
+	.expect = {
+		.raw_types = {
+			BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),				/* [1] */
+			BTF_TYPE_TAG_ENC(NAME_NTH(1), 1),					/* [2] */
+			BTF_TYPE_ENC(NAME_NTH(2), BTF_INFO_ENC(BTF_KIND_STRUCT, 1, 1), 4),	/* [3] */
+			BTF_MEMBER_ENC(NAME_NTH(3), 2, BTF_MEMBER_OFFSET(0, 0)),
+			BTF_END_RAW,
+		},
+		BTF_STR_SEC("\0tag1\0t\0m"),
+	},
+},
 
 };