Skip to content

Commit

Permalink
selftests/bpf: Add selftest for pointer-to-array-of-struct BTF dump
Browse files Browse the repository at this point in the history
Bpftool used to issue forward declarations for a struct used as part of
a pointer to array, which is invalid. Add a test to check that the
struct is fully defined in this case:

	@@ -134,9 +134,9 @@
	 	};
	 };

	-struct struct_in_array {};
	+struct struct_in_array;

	-struct struct_in_array_typed {};
	+struct struct_in_array_typed;

	 typedef struct struct_in_array_typed struct_in_array_t[2];

	@@ -189,3 +189,7 @@
	 	struct struct_with_embedded_stuff _14;
	 };

	+struct struct_in_array {};
	+
	+struct struct_in_array_typed {};
	+
	...
	#13/1 btf_dump: syntax:FAIL

Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210319112554.794552-3-jean-philippe@linaro.org
  • Loading branch information
jpbrucker authored and anakryiko committed Mar 19, 2021
1 parent 901ee1d commit f118aac
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c
Expand Up @@ -174,6 +174,12 @@ struct struct_in_struct {
};
};

struct struct_in_array {};

struct struct_in_array_typed {};

typedef struct struct_in_array_typed struct_in_array_t[2];

struct struct_with_embedded_stuff {
int a;
struct {
Expand Down Expand Up @@ -203,6 +209,8 @@ struct struct_with_embedded_stuff {
} r[5];
struct struct_in_struct s[10];
int t[11];
struct struct_in_array (*u)[2];
struct_in_array_t *v;
};

struct root_struct {
Expand Down

0 comments on commit f118aac

Please sign in to comment.