bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf <bpf@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@fb.com>,
	"daniel@iogearbox.net" <daniel@iogearbox.net>,
	Kernel Team <Kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 10/11] selftests/bpf: add split BTF dedup selftests
Date: Tue, 3 Nov 2020 05:35:14 +0000	[thread overview]
Message-ID: <23399683-99A4-4E91-9C7B-8B0E3A4083DE@fb.com> (raw)
In-Reply-To: <20201029005902.1706310-11-andrii@kernel.org>



> On Oct 28, 2020, at 5:59 PM, Andrii Nakryiko <andrii@kernel.org> wrote:
> 
> Add selftests validating BTF deduplication for split BTF case. Add a helper
> macro that allows to validate entire BTF with raw BTF dump, not just
> type-by-type. This saves tons of code and complexity.
> 
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

Acked-by: Song Liu <songliubraving@fb.com>

with a couple nits:

[...]

> 
> int fprintf_btf_type_raw(FILE *out, const struct btf *btf, __u32 id);
> const char *btf_type_raw_dump(const struct btf *btf, int type_id);
> +int btf_validate_raw(struct btf *btf, int nr_types, const char *exp_types[]);
> 
> +#define VALIDATE_RAW_BTF(btf, raw_types...)				\
> +	btf_validate_raw(btf,						\
> +			 sizeof((const char *[]){raw_types})/sizeof(void *),\
> +			 (const char *[]){raw_types})
> +
> +const char *btf_type_c_dump(const struct btf *btf);
> #endif
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
> new file mode 100644
> index 000000000000..097370a41b60
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
> @@ -0,0 +1,326 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2020 Facebook */
> +#include <test_progs.h>
> +#include <bpf/btf.h>
> +#include "btf_helpers.h"
> +
> +
> +static void test_split_simple() {
> +	const struct btf_type *t;
> +	struct btf *btf1, *btf2 = NULL;
> +	int str_off, err;
> +
> +	btf1 = btf__new_empty();
> +	if (!ASSERT_OK_PTR(btf1, "empty_main_btf"))
> +		return;
> +
> +	btf__set_pointer_size(btf1, 8); /* enforce 64-bit arch */
> +
> +	btf__add_int(btf1, "int", 4, BTF_INT_SIGNED);	/* [1] int */
> +	btf__add_ptr(btf1, 1);				/* [2] ptr to int */
> +	btf__add_struct(btf1, "s1", 4);			/* [3] struct s1 { */
> +	btf__add_field(btf1, "f1", 1, 0, 0);		/*      int f1; */
> +							/* } */
> +

nit: two empty lines. 

> +	VALIDATE_RAW_BTF(
> +		btf1,
> +		"[1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED",
> +		"[2] PTR '(anon)' type_id=1",
> +		"[3] STRUCT 's1' size=4 vlen=1\n"
> +		"\t'f1' type_id=1 bits_offset=0");
> +

[...]

> +
> +cleanup:
> +	btf__free(btf2);
> +	btf__free(btf1);
> +}
> +
> +static void test_split_struct_duped() {
> +	struct btf *btf1, *btf2 = NULL;

nit: No need to initialize btf2, for all 3 tests. 

> +	int err;
> +
[...]


  reply	other threads:[~2020-11-03  5:35 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29  0:58 [PATCH bpf-next 00/11] libbpf: split BTF support Andrii Nakryiko
2020-10-29  0:58 ` [PATCH bpf-next 01/11] libbpf: factor out common operations in BTF writing APIs Andrii Nakryiko
2020-10-30  0:36   ` Song Liu
2020-10-29  0:58 ` [PATCH bpf-next 02/11] selftest/bpf: relax btf_dedup test checks Andrii Nakryiko
2020-10-30 16:43   ` Song Liu
2020-10-30 18:44     ` Andrii Nakryiko
2020-10-30 22:30       ` Song Liu
2020-10-29  0:58 ` [PATCH bpf-next 03/11] libbpf: unify and speed up BTF string deduplication Andrii Nakryiko
2020-10-30 23:32   ` Song Liu
2020-11-03  4:51     ` Andrii Nakryiko
2020-11-03  4:59   ` Alexei Starovoitov
2020-11-03  6:01     ` Andrii Nakryiko
2020-10-29  0:58 ` [PATCH bpf-next 04/11] libbpf: implement basic split BTF support Andrii Nakryiko
2020-11-02 23:23   ` Song Liu
2020-11-03  5:02     ` Andrii Nakryiko
2020-11-03  5:41       ` Song Liu
2020-11-04 23:51         ` Andrii Nakryiko
2020-10-29  0:58 ` [PATCH bpf-next 05/11] selftests/bpf: add split BTF basic test Andrii Nakryiko
2020-11-02 23:36   ` Song Liu
2020-11-03  5:10     ` Andrii Nakryiko
2020-10-29  0:58 ` [PATCH bpf-next 06/11] selftests/bpf: add checking of raw type dump in BTF writer APIs selftests Andrii Nakryiko
2020-11-03  0:08   ` Song Liu
2020-11-03  5:14     ` Andrii Nakryiko
2020-10-29  0:58 ` [PATCH bpf-next 07/11] libbpf: fix BTF data layout checks and allow empty BTF Andrii Nakryiko
2020-11-03  0:51   ` Song Liu
2020-11-03  5:18     ` Andrii Nakryiko
2020-11-03  5:44       ` Song Liu
2020-10-29  0:58 ` [PATCH bpf-next 08/11] libbpf: support BTF dedup of split BTFs Andrii Nakryiko
2020-11-03  2:49   ` Song Liu
2020-11-03  5:25     ` Andrii Nakryiko
2020-11-03  5:59       ` Song Liu
2020-11-03  6:31         ` Andrii Nakryiko
2020-11-03 17:15           ` Song Liu
2020-11-03  5:10   ` Alexei Starovoitov
2020-11-03  6:27     ` Andrii Nakryiko
2020-11-03 17:55       ` Alexei Starovoitov
2020-10-29  0:59 ` [PATCH bpf-next 09/11] libbpf: accomodate DWARF/compiler bug with duplicated identical arrays Andrii Nakryiko
2020-11-03  2:52   ` Song Liu
2020-10-29  0:59 ` [PATCH bpf-next 10/11] selftests/bpf: add split BTF dedup selftests Andrii Nakryiko
2020-11-03  5:35   ` Song Liu [this message]
2020-11-03  6:05     ` Andrii Nakryiko
2020-11-03  6:30       ` Song Liu
2020-10-29  0:59 ` [PATCH bpf-next 11/11] tools/bpftool: add bpftool support for split BTF Andrii Nakryiko
2020-11-03  6:03   ` Song Liu
2020-10-30  0:33 ` [PATCH bpf-next 00/11] libbpf: split BTF support Song Liu
2020-10-30  2:33   ` Andrii Nakryiko
2020-10-30  6:45     ` Song Liu
2020-10-30 12:04     ` Alan Maguire
2020-10-30 18:30       ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23399683-99A4-4E91-9C7B-8B0E3A4083DE@fb.com \
    --to=songliubraving@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).