All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hengqi Chen <hengqi.chen@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>, Yonghong Song <yhs@fb.com>,
	john fastabend <john.fastabend@gmail.com>
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Test BPF map creation using BTF-defined key/value
Date: Fri, 1 Oct 2021 00:05:34 +0800	[thread overview]
Message-ID: <52bd9e85-4b5f-d260-8ef0-b5685654ae62@gmail.com> (raw)
In-Reply-To: <CAEf4BzZnKxVRtkaGUbzCmi0SDsR4_KM=uqdgP+Q6seAygkst7g@mail.gmail.com>



On 9/9/21 12:29 PM, Andrii Nakryiko wrote:
> On Sun, Sep 5, 2021 at 3:09 AM Hengqi Chen <hengqi.chen@gmail.com> wrote:
>>
>> Test BPF map creation using BTF-defined key/value. The test defines
>> some specialized maps by specifying BTF types for key/value and
>> checks those maps are correctly initialized and loaded.
>>
>> Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
>> ---
>>  .../selftests/bpf/prog_tests/map_create.c     |  87 ++++++++++++++
>>  .../selftests/bpf/progs/test_map_create.c     | 110 ++++++++++++++++++
>>  2 files changed, 197 insertions(+)
>>  create mode 100644 tools/testing/selftests/bpf/prog_tests/map_create.c
>>  create mode 100644 tools/testing/selftests/bpf/progs/test_map_create.c
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/map_create.c b/tools/testing/selftests/bpf/prog_tests/map_create.c
>> new file mode 100644
>> index 000000000000..6ca32d0dffd2
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/prog_tests/map_create.c
>> @@ -0,0 +1,87 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/* Copyright (c) 2021 Hengqi Chen */
>> +
>> +#include <test_progs.h>
>> +#include "test_map_create.skel.h"
>> +
>> +void test_map_create(void)
>> +{
>> +       struct test_map_create *skel;
>> +       int err, fd;
>> +
>> +       skel = test_map_create__open();
>> +       if (!ASSERT_OK_PTR(skel, "test_map_create__open failed"))
>> +               return;
>> +
>> +       err = test_map_create__load(skel);
> 
> If load() succeeds, all the maps will definitely be created, so all
> the below tests are meaningless.
> 
> I think it's better to just change all the existing map definitions
> used throughout selftests to use key/value types, instead of
> key_size/value_size. That will automatically test this feature without
> adding an extra test. Unfortunately to really test that the logic is
> working, we'd need to check that libbpf doesn't emit the warning about
> retrying map creation w/o BTF, but I think one-time manual check
> (please use ./test_progs -v to see libbpf warnings during tests)
> should be sufficient for this.
> 

Hello, Andrii

I updated these existing tests as you suggested, 
but I was unable to run the whole bpf selftests locally.

Running ./test_progs -v made my system hang up,
didn't find the root cause yet.

Instead I just run the modified test with the following commands:

sudo ./test_progs -v --name=kfree_skb,perf_event_stackmap,btf_map_in_map,pe_preserve_elems,stacktrace_map,stacktrace_build_id,xdp_bpf2bpf,select_reuseport,tcpbpf_user

>> +       if (!ASSERT_OK(err, "test_map_create__load failed"))
>> +               goto cleanup;
>> +
>> +       fd = bpf_map__fd(skel->maps.map1);
>> +       if (!ASSERT_GT(fd, 0, "bpf_map__fd failed"))
>> +               goto cleanup;
>> +       close(fd);
>> +
>> +       fd = bpf_map__fd(skel->maps.map2);
>> +       if (!ASSERT_GT(fd, 0, "bpf_map__fd failed"))
>> +               goto cleanup;
>> +       close(fd);
> 
> [...]
> 

  reply	other threads:[~2021-09-30 16:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-05 10:09 [PATCH bpf-next 1/2] libbpf: Support uniform BTF-defined key/value specification across all BPF maps Hengqi Chen
2021-09-05 10:09 ` [PATCH bpf-next 2/2] selftests/bpf: Test BPF map creation using BTF-defined key/value Hengqi Chen
2021-09-09  4:29   ` Andrii Nakryiko
2021-09-30 16:05     ` Hengqi Chen [this message]
2021-09-30 18:39       ` Andrii Nakryiko
2021-10-02 16:17         ` Hengqi Chen
2021-09-09  4:26 ` [PATCH bpf-next 1/2] libbpf: Support uniform BTF-defined key/value specification across all BPF maps Andrii Nakryiko
2021-09-30 15:58   ` Hengqi Chen

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=52bd9e85-4b5f-d260-8ef0-b5685654ae62@gmail.com \
    --to=hengqi.chen@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=yhs@fb.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.