Re: [PATCH bpf-next 3/5] selftests/bpf: add a btf_dump test for type_tags

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

 



On Wed, 2025-01-22 at 02:53 +0000, Ihor Solodrai wrote:
> Factor out common routines handling custom BTF from
> test_btf_dump_incremental. Then use them in the
> test_btf_dump_type_tags.
> 
> test_btf_dump_type_tags verifies that a type tag is dumped correctly
> with respect to its kflag.
> 
> Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxx>
> ---

Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx>

>  .../selftests/bpf/prog_tests/btf_dump.c       | 148 +++++++++++++-----
>  1 file changed, 111 insertions(+), 37 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dump.c b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> index b293b8501fd6..690cf8cef7d2 100644
> --- a/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> @@ -126,26 +126,70 @@ static int test_btf_dump_case(int n, struct btf_dump_test_case *t)
>  	return err;
>  }
>  
> -static char *dump_buf;
> -static size_t dump_buf_sz;
> -static FILE *dump_buf_file;
> +struct btf_dump__custom_btf_test {

Nit: since there would be a v2, I'd give this thing a shorter name,
     e.g. test_ctx.

> +	struct btf *btf;
> +	struct btf_dump *d;
> +	char *dump_buf;
> +	size_t dump_buf_sz;
> +	FILE *dump_buf_file;
> +};

[...]

> +static void test_btf_dump_incremental(void)
> +{
> +	struct btf_dump__custom_btf_test t;

Nit: this should be 'struct btf_dump__custom_btf_test t = {};'
     otherwise btf_dump__custom_btf_test__init() would read
     garbage in the error cases.

> +	struct btf *btf;
> +	int id, err;
> +
> +	if (btf_dump__custom_btf_test__init(&t))
> +		return;
> +
> +	btf = t.btf;
> +
>  	/* First, generate BTF corresponding to the following C code:
>  	 *
>  	 * enum x;

[...]






[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