[PATCH bpf-next 0/4] selftests/bpf: Update multiple prog_tests to use ASSERT_ macros

Yuran Pereira posted 4 patches 2 years, 2 months ago
There is a newer version of this series
.../selftests/bpf/prog_tests/bind_perm.c      |   6 +-
.../selftests/bpf/prog_tests/bpf_obj_id.c     | 204 +++++++-----------
.../selftests/bpf/prog_tests/bpf_tcp_ca.c     |  48 ++---
.../selftests/bpf/prog_tests/vmlinux.c        |  16 +-
4 files changed, 105 insertions(+), 169 deletions(-)
[PATCH bpf-next 0/4] selftests/bpf: Update multiple prog_tests to use ASSERT_ macros
Posted by Yuran Pereira 2 years, 2 months ago
Multiple files/programs in `tools/testing/selftests/bpf/prog_tests/` still
heavily use the `CHECK` macro, even when better `ASSERT_` alternatives are
available.

As it was already pointed out by Yonghong Song [1] in the bpf selftests the use
of the ASSERT_* series of macros is preferred over the CHECK macro.

This patchset replaces the usage of `CHECK(` macros to the equivalent `ASSERT_`
family of macros in the following prog_tests:
- bind_perm.c
- bpf_obj_id.c
- bpf_tcp_ca.c
- vmlinux.c

[1] https://lore.kernel.org/lkml/0a142924-633c-44e6-9a92-2dc019656bf2@linux.dev

Yuran Pereira (4):
  Replaces the usage of CHECK calls for ASSERTs in bpf_tcp_ca
  Replaces the usage of CHECK calls for ASSERTs in bind_perm
  Replaces the usage of CHECK calls for ASSERTs in bpf_obj_id
  selftests/bpf: Replaces the usage of CHECK calls for ASSERTs in
    vmlinux

 .../selftests/bpf/prog_tests/bind_perm.c      |   6 +-
 .../selftests/bpf/prog_tests/bpf_obj_id.c     | 204 +++++++-----------
 .../selftests/bpf/prog_tests/bpf_tcp_ca.c     |  48 ++---
 .../selftests/bpf/prog_tests/vmlinux.c        |  16 +-
 4 files changed, 105 insertions(+), 169 deletions(-)

-- 
2.25.1
Re: [PATCH bpf-next 0/4] selftests/bpf: Update multiple prog_tests to use ASSERT_ macros
Posted by Andrii Nakryiko 2 years, 2 months ago
On Wed, Nov 15, 2023 at 10:14 PM Yuran Pereira
<yuran.pereira@hotmail.com> wrote:
>
> Multiple files/programs in `tools/testing/selftests/bpf/prog_tests/` still
> heavily use the `CHECK` macro, even when better `ASSERT_` alternatives are
> available.
>
> As it was already pointed out by Yonghong Song [1] in the bpf selftests the use
> of the ASSERT_* series of macros is preferred over the CHECK macro.
>
> This patchset replaces the usage of `CHECK(` macros to the equivalent `ASSERT_`
> family of macros in the following prog_tests:
> - bind_perm.c
> - bpf_obj_id.c
> - bpf_tcp_ca.c
> - vmlinux.c
>
> [1] https://lore.kernel.org/lkml/0a142924-633c-44e6-9a92-2dc019656bf2@linux.dev
>
> Yuran Pereira (4):
>   Replaces the usage of CHECK calls for ASSERTs in bpf_tcp_ca
>   Replaces the usage of CHECK calls for ASSERTs in bind_perm
>   Replaces the usage of CHECK calls for ASSERTs in bpf_obj_id
>   selftests/bpf: Replaces the usage of CHECK calls for ASSERTs in
>     vmlinux
>
>  .../selftests/bpf/prog_tests/bind_perm.c      |   6 +-
>  .../selftests/bpf/prog_tests/bpf_obj_id.c     | 204 +++++++-----------
>  .../selftests/bpf/prog_tests/bpf_tcp_ca.c     |  48 ++---
>  .../selftests/bpf/prog_tests/vmlinux.c        |  16 +-
>  4 files changed, 105 insertions(+), 169 deletions(-)
>
> --
> 2.25.1
>

It seems like you introduced a few failures in selftests, please take
a look at [0] and fix them, thanks!

  [0] https://github.com/kernel-patches/bpf/actions/runs/6885976657/job/18731029901
Re: [PATCH bpf-next 0/4] selftests/bpf: Update multiple prog_tests to use ASSERT_ macros
Posted by Yuran Pereira 2 years, 2 months ago
Hello Andrii,
On Fri, Nov 17, 2023 at 12:18:40PM -0500, Andrii Nakryiko wrote:
> 
> It seems like you introduced a few failures in selftests, please take
> a look at [0] and fix them, thanks!
> 
Thank you for letting me know. I will see what's wrong
and submit a v2 ASAP.

Thanks,
Yuran Pereira