Skip to content

Commit

Permalink
selftests/bpf: Add non-standardly sized enum tests for btf_dump
Browse files Browse the repository at this point in the history
Add few custom enum definitions testing mode(byte) and mode(word)
attributes.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20221212211505.558851-4-andrii@kernel.org
  • Loading branch information
Andrii Nakryiko authored and Daniel Borkmann committed Dec 14, 2022
1 parent 21a9a1b commit 9d23497
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,39 @@ typedef enum {
H = 2,
} e3_t;

/* ----- START-EXPECTED-OUTPUT ----- */
/*
*enum e_byte {
* EBYTE_1 = 0,
* EBYTE_2 = 1,
*} __attribute__((mode(byte)));
*
*/
/* ----- END-EXPECTED-OUTPUT ----- */
enum e_byte {
EBYTE_1,
EBYTE_2,
} __attribute__((mode(byte)));

/* ----- START-EXPECTED-OUTPUT ----- */
/*
*enum e_word {
* EWORD_1 = 0LL,
* EWORD_2 = 1LL,
*} __attribute__((mode(word)));
*
*/
/* ----- END-EXPECTED-OUTPUT ----- */
enum e_word {
EWORD_1,
EWORD_2,
} __attribute__((mode(word))); /* force to use 8-byte backing for this enum */

/* ----- START-EXPECTED-OUTPUT ----- */
enum e_big {
EBIG_1 = 1000000000000ULL,
};

typedef int int_t;

typedef volatile const int * volatile const crazy_ptr_t;
Expand Down Expand Up @@ -224,6 +257,9 @@ struct root_struct {
enum e2 _2;
e2_t _2_1;
e3_t _2_2;
enum e_byte _100;
enum e_word _101;
enum e_big _102;
struct struct_w_typedefs _3;
anon_struct_t _7;
struct struct_fwd *_8;
Expand Down

0 comments on commit 9d23497

Please sign in to comment.