summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/btf_data.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2020-07-11 23:53:29 +0200
committerAlexei Starovoitov <ast@kernel.org>2020-07-13 10:42:03 -0700
commitcc15a20d5f3abc3cbd7911b70156b7b9e2bc7d41 (patch)
tree72725e347309aa4c0ad196b34978f359c54d2ab6 /tools/testing/selftests/bpf/progs/btf_data.c
parente5a0516ec9681daf5c1f0d05144d21430b6ca6d7 (diff)
selftests/bpf: Add test for resolve_btfids
Adding resolve_btfids test under test_progs suite. It's possible to use btf_ids.h header and its logic in user space application, so we can add easy test for it. The test defines BTF_ID_LIST and checks it gets properly resolved. For this reason the test_progs binary (and other binaries that use TRUNNER* macros) is processed with resolve_btfids tool, which resolves BTF IDs in .BTF_ids section. The BTF data are taken from btf_data.o object rceated from progs/btf_data.c. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Tested-by: Andrii Nakryiko <andriin@fb.com> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/20200711215329.41165-10-jolsa@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/progs/btf_data.c')
-rw-r--r--tools/testing/selftests/bpf/progs/btf_data.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/btf_data.c b/tools/testing/selftests/bpf/progs/btf_data.c
new file mode 100644
index 000000000000..baa525275bde
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/btf_data.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+
+struct S {
+ int a;
+ int b;
+ int c;
+};
+
+union U {
+ int a;
+ int b;
+ int c;
+};
+
+struct S1 {
+ int a;
+ int b;
+ int c;
+};
+
+union U1 {
+ int a;
+ int b;
+ int c;
+};
+
+typedef int T;
+typedef int S;
+typedef int U;
+typedef int T1;
+typedef int S1;
+typedef int U1;
+
+struct root_struct {
+ S m_1;
+ T m_2;
+ U m_3;
+ S1 m_4;
+ T1 m_5;
+ U1 m_6;
+ struct S m_7;
+ struct S1 m_8;
+ union U m_9;
+ union U1 m_10;
+};
+
+int func(struct root_struct *root)
+{
+ return 0;
+}