aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/btf_dump_test_case_ordering.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2019-05-24 11:59:04 -0700
committerAlexei Starovoitov <ast@kernel.org>2019-05-24 14:05:58 -0700
commit2d2a3ad872f884d618f11e1a2028cff862503dcd (patch)
treeac6c8d467949cdb304024b3aff5bd113e3bff3c6 /tools/testing/selftests/bpf/progs/btf_dump_test_case_ordering.c
parentlibbpf: add btf_dump API for BTF-to-C conversion (diff)
downloadlinux-dev-2d2a3ad872f884d618f11e1a2028cff862503dcd.tar.xz
linux-dev-2d2a3ad872f884d618f11e1a2028cff862503dcd.zip
selftests/bpf: add btf_dump BTF-to-C conversion tests
Add new test_btf_dump set of tests, validating BTF-to-C conversion correctness. Tests rely on clang to generate BTF from provided C test cases. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/btf_dump_test_case_ordering.c')
-rw-r--r--tools/testing/selftests/bpf/progs/btf_dump_test_case_ordering.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/btf_dump_test_case_ordering.c b/tools/testing/selftests/bpf/progs/btf_dump_test_case_ordering.c
new file mode 100644
index 000000000000..7c95702ee4cb
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/btf_dump_test_case_ordering.c
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+
+/*
+ * BTF-to-C dumper test for topological sorting of dependent structs.
+ *
+ * Copyright (c) 2019 Facebook
+ */
+/* ----- START-EXPECTED-OUTPUT ----- */
+struct s1 {};
+
+struct s3;
+
+struct s4;
+
+struct s2 {
+ struct s2 *s2;
+ struct s3 *s3;
+ struct s4 *s4;
+};
+
+struct s3 {
+ struct s1 s1;
+ struct s2 s2;
+};
+
+struct s4 {
+ struct s1 s1;
+ struct s3 s3;
+};
+
+struct list_head {
+ struct list_head *next;
+ struct list_head *prev;
+};
+
+struct hlist_node {
+ struct hlist_node *next;
+ struct hlist_node **pprev;
+};
+
+struct hlist_head {
+ struct hlist_node *first;
+};
+
+struct callback_head {
+ struct callback_head *next;
+ void (*func)(struct callback_head *);
+};
+
+struct root_struct {
+ struct s4 s4;
+ struct list_head l;
+ struct hlist_node n;
+ struct hlist_head h;
+ struct callback_head cb;
+};
+
+/*------ END-EXPECTED-OUTPUT ------ */
+
+int f(struct root_struct *root)
+{
+ return 0;
+}