[RFC bpf-next 12/13] selftests/bpf: extend base reference tests cover BTF reconciliation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ensure reconciled BTF looks as expected; in this case identical to
original split BTF.  More tests needed here for positive/negative
cases..

Signed-off-by: Alan Maguire <alan.maguire@xxxxxxxxxx>
---
 .../bpf/prog_tests/btf_split_base_ref.c       | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/btf_split_base_ref.c b/tools/testing/selftests/bpf/prog_tests/btf_split_base_ref.c
index d611167fa4b2..3f4382651fc8 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf_split_base_ref.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf_split_base_ref.c
@@ -158,6 +158,41 @@ static void test_split_base_ref(void)
 		"[16] CONST '(anon)' type_id=8",
 		"[17] PTR '(anon)' type_id=9");
 
+	if (!ASSERT_EQ(btf__reconcile(btf3, btf1), 0, "reconcile_split"))
+		goto cleanup;
+	VALIDATE_RAW_BTF(
+		btf3,
+		"[1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED",
+		"[2] PTR '(anon)' type_id=1",
+		"[3] STRUCT 's1' size=8 vlen=1\n"
+		"\t'f1' type_id=2 bits_offset=0",
+		"[4] STRUCT '(anon)' size=12 vlen=2\n"
+		"\t'f1' type_id=1 bits_offset=0\n"
+		"\t'f2' type_id=3 bits_offset=32",
+		"[5] INT 'unsigned int' size=4 bits_offset=0 nr_bits=32 encoding=(none)",
+		"[6] UNION 'u1' size=12 vlen=2\n"
+		"\t'f1' type_id=1 bits_offset=0\n"
+		"\t'f2' type_id=2 bits_offset=0",
+		"[7] UNION '(anon)' size=4 vlen=1\n"
+		"\t'f1' type_id=1 bits_offset=0",
+		"[8] ENUM 'e1' encoding=UNSIGNED size=4 vlen=1\n"
+		"\t'v1' val=1",
+		"[9] ENUM '(anon)' encoding=UNSIGNED size=4 vlen=1\n"
+		"\t'av1' val=2",
+		"[10] ENUM64 'e641' encoding=SIGNED size=8 vlen=1\n"
+		"\t'v1' val=1024",
+		"[11] ENUM64 '(anon)' encoding=SIGNED size=8 vlen=1\n"
+		"\t'v1' val=1025",
+		"[12] STRUCT 'unneeded' size=4 vlen=1\n"
+		"\t'f1' type_id=1 bits_offset=0",
+		"[13] PTR '(anon)' type_id=3",
+		"[14] PTR '(anon)' type_id=4",
+		"[15] CONST '(anon)' type_id=6",
+		"[16] RESTRICT '(anon)' type_id=7",
+		"[17] VOLATILE '(anon)' type_id=8",
+		"[18] TYPEDEF 'et' type_id=9",
+		"[19] CONST '(anon)' type_id=10",
+		"[20] PTR '(anon)' type_id=11");
 cleanup:
 	btf__free(btf4);
 	btf__free(btf3);
-- 
2.39.3





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux