Re: [PATCH bpf-next 3/6] selftests/bpf: add non-standardly sized enum tests for btf_dump

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

 



On Thu, 2022-12-08 at 10:57 -0800, Andrii Nakryiko wrote:
> Add few custom enum definitions testing mode(byte) and mode(word)
> attributes.
> 
> Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> ---
>  .../bpf/progs/btf_dump_test_case_syntax.c     | 36 +++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c b/tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c
> index 4ee4748133fe..26fffb02ed10 100644
> --- a/tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c
> +++ b/tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c
> @@ -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;
>  

Something is off with this test, when executed on my little-endian
machine the output looks as follows:

# ./test_progs -n 23/1
--- -	2022-12-09 17:22:03.412602033 +0000
+++ /tmp/btf_dump_test_case_syntax.output.Z28uhX	2022-12-09 17:22:03.403945082 +0000
@@ -23,13 +23,13 @@
 } __attribute__((mode(byte)));
 
 enum e_word {
-	EWORD_1 = 0LL,
-	EWORD_2 = 1LL,
+	EWORD_1 = 0,
+	EWORD_2 = 1,
 } __attribute__((mode(word)));
 
 enum e_big {
-	EBIG_1 = 1000000000000ULL,
-};
+	EBIG_1 = 3567587328,
+} __attribute__((mode(word)));

But this is not related to your changes, here is a raw dump:

$ bpftool btf dump file ./btf_dump_test_case_syntax.bpf.o 

[10] ENUM 'e_big' encoding=UNSIGNED size=8 vlen=1
        'EBIG_1' val=3567587328

>  typedef volatile const int * volatile const crazy_ptr_t;
> @@ -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;





[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