mbox series

[bpf-next,00/11] bpf/selftests: convert some tests to ASSERT_* macros

Message ID 1664169131-32405-1-git-send-email-wangyufen@huawei.com (mailing list archive)
Headers show
Series bpf/selftests: convert some tests to ASSERT_* macros | expand

Message

wangyufen Sept. 26, 2022, 5:12 a.m. UTC
Convert some tests to use the preferred ASSERT_* macros instead of the
deprecated CHECK().

Wang Yufen (11):
  bpf/selftests: convert sockmap_basic test to ASSERT_* macros
  bpf/selftests: convert sockmap_ktls test to ASSERT_* macros
  bpf/selftests: convert sockopt test to ASSERT_* macros
  bpf/selftests: convert sockopt_inherit test to ASSERT_* macros
  bpf/selftests: convert sockopt_multi test to ASSERT_* macros
  bpf/selftests: convert sockopt_sk test to ASSERT_* macros
  bpf/selftests: convert tcp_estats test to ASSERT_* macros
  bpf/selftests: convert tcp_hdr_options test to ASSERT_* macros
  bpf/selftests: convert tcp_rtt test to ASSERT_* macros
  bpf/selftests: convert tcpbpf_user test to ASSERT_* macros
  bpf/selftests: convert udp_limit test to ASSERT_* macros

 .../selftests/bpf/prog_tests/sockmap_basic.c       | 87 ++++++++--------------
 .../selftests/bpf/prog_tests/sockmap_ktls.c        | 39 +++-------
 tools/testing/selftests/bpf/prog_tests/sockopt.c   |  4 +-
 .../selftests/bpf/prog_tests/sockopt_inherit.c     | 30 ++++----
 .../selftests/bpf/prog_tests/sockopt_multi.c       | 10 +--
 .../testing/selftests/bpf/prog_tests/sockopt_sk.c  |  2 +-
 .../testing/selftests/bpf/prog_tests/tcp_estats.c  |  4 +-
 .../selftests/bpf/prog_tests/tcp_hdr_options.c     | 80 +++++++-------------
 tools/testing/selftests/bpf/prog_tests/tcp_rtt.c   | 13 ++--
 .../testing/selftests/bpf/prog_tests/tcpbpf_user.c | 32 +++-----
 tools/testing/selftests/bpf/prog_tests/udp_limit.c | 18 ++---
 11 files changed, 117 insertions(+), 202 deletions(-)

Comments

Andrii Nakryiko Sept. 29, 2022, 12:37 a.m. UTC | #1
On Sun, Sep 25, 2022 at 9:51 PM Wang Yufen <wangyufen@huawei.com> wrote:
>
> Convert some tests to use the preferred ASSERT_* macros instead of the
> deprecated CHECK().
>
> Wang Yufen (11):
>   bpf/selftests: convert sockmap_basic test to ASSERT_* macros
>   bpf/selftests: convert sockmap_ktls test to ASSERT_* macros
>   bpf/selftests: convert sockopt test to ASSERT_* macros
>   bpf/selftests: convert sockopt_inherit test to ASSERT_* macros
>   bpf/selftests: convert sockopt_multi test to ASSERT_* macros
>   bpf/selftests: convert sockopt_sk test to ASSERT_* macros
>   bpf/selftests: convert tcp_estats test to ASSERT_* macros
>   bpf/selftests: convert tcp_hdr_options test to ASSERT_* macros
>   bpf/selftests: convert tcp_rtt test to ASSERT_* macros
>   bpf/selftests: convert tcpbpf_user test to ASSERT_* macros
>   bpf/selftests: convert udp_limit test to ASSERT_* macros
>
>  .../selftests/bpf/prog_tests/sockmap_basic.c       | 87 ++++++++--------------
>  .../selftests/bpf/prog_tests/sockmap_ktls.c        | 39 +++-------
>  tools/testing/selftests/bpf/prog_tests/sockopt.c   |  4 +-
>  .../selftests/bpf/prog_tests/sockopt_inherit.c     | 30 ++++----
>  .../selftests/bpf/prog_tests/sockopt_multi.c       | 10 +--
>  .../testing/selftests/bpf/prog_tests/sockopt_sk.c  |  2 +-
>  .../testing/selftests/bpf/prog_tests/tcp_estats.c  |  4 +-
>  .../selftests/bpf/prog_tests/tcp_hdr_options.c     | 80 +++++++-------------
>  tools/testing/selftests/bpf/prog_tests/tcp_rtt.c   | 13 ++--
>  .../testing/selftests/bpf/prog_tests/tcpbpf_user.c | 32 +++-----
>  tools/testing/selftests/bpf/prog_tests/udp_limit.c | 18 ++---
>  11 files changed, 117 insertions(+), 202 deletions(-)
>
> --
> 1.8.3.1
>

Thanks for the clean up! I've changed one ASSERT_OK(err && errno !=
ENOENT) to ASSERT_EQ(errno, ENOENT) in patch #1, that expresses the
intent more directly. Please also keep in mind that patch prefix
should (conventionally) be "selftests/bpf: ". I've fixed that for all
patches while applying.

We are down to:

$ rg -w CHECK | wc -l
1186
09/28 17:36:39.381
andriin@devbig019:~/linux/tools/testing/selftests/bpf (master)
$ rg -w CHECK_FAIL | wc -l
463

Some ways to go still, but slowly decreasing. Thank you for your contribution!
patchwork-bot+netdevbpf@kernel.org Sept. 29, 2022, 12:40 a.m. UTC | #2
Hello:

This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Mon, 26 Sep 2022 13:12:00 +0800 you wrote:
> Convert some tests to use the preferred ASSERT_* macros instead of the
> deprecated CHECK().
> 
> Wang Yufen (11):
>   bpf/selftests: convert sockmap_basic test to ASSERT_* macros
>   bpf/selftests: convert sockmap_ktls test to ASSERT_* macros
>   bpf/selftests: convert sockopt test to ASSERT_* macros
>   bpf/selftests: convert sockopt_inherit test to ASSERT_* macros
>   bpf/selftests: convert sockopt_multi test to ASSERT_* macros
>   bpf/selftests: convert sockopt_sk test to ASSERT_* macros
>   bpf/selftests: convert tcp_estats test to ASSERT_* macros
>   bpf/selftests: convert tcp_hdr_options test to ASSERT_* macros
>   bpf/selftests: convert tcp_rtt test to ASSERT_* macros
>   bpf/selftests: convert tcpbpf_user test to ASSERT_* macros
>   bpf/selftests: convert udp_limit test to ASSERT_* macros
> 
> [...]

Here is the summary with links:
  - [bpf-next,01/11] bpf/selftests: convert sockmap_basic test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/38e35e1d0cee
  - [bpf-next,02/11] bpf/selftests: convert sockmap_ktls test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/d155fcb3fff1
  - [bpf-next,03/11] bpf/selftests: convert sockopt test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/099763e7da0b
  - [bpf-next,04/11] bpf/selftests: convert sockopt_inherit test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/675bc8abe16d
  - [bpf-next,05/11] bpf/selftests: convert sockopt_multi test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/a605a6bbccce
  - [bpf-next,06/11] bpf/selftests: convert sockopt_sk test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/f19708dfa0bf
  - [bpf-next,07/11] bpf/selftests: convert tcp_estats test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/a0a17296713a
  - [bpf-next,08/11] bpf/selftests: convert tcp_hdr_options test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/3082f8cd4ba3
  - [bpf-next,09/11] bpf/selftests: convert tcp_rtt test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/8dda32ac58b6
  - [bpf-next,10/11] bpf/selftests: convert tcpbpf_user test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/9d0b05bdfbea
  - [bpf-next,11/11] bpf/selftests: convert udp_limit test to ASSERT_* macros
    https://git.kernel.org/bpf/bpf-next/c/1fddca3d36d1

You are awesome, thank you!
wangyufen Sept. 29, 2022, 3:37 a.m. UTC | #3
在 2022/9/29 8:37, Andrii Nakryiko 写道:
> On Sun, Sep 25, 2022 at 9:51 PM Wang Yufen <wangyufen@huawei.com> wrote:
>> Convert some tests to use the preferred ASSERT_* macros instead of the
>> deprecated CHECK().
>>
>> Wang Yufen (11):
>>    bpf/selftests: convert sockmap_basic test to ASSERT_* macros
>>    bpf/selftests: convert sockmap_ktls test to ASSERT_* macros
>>    bpf/selftests: convert sockopt test to ASSERT_* macros
>>    bpf/selftests: convert sockopt_inherit test to ASSERT_* macros
>>    bpf/selftests: convert sockopt_multi test to ASSERT_* macros
>>    bpf/selftests: convert sockopt_sk test to ASSERT_* macros
>>    bpf/selftests: convert tcp_estats test to ASSERT_* macros
>>    bpf/selftests: convert tcp_hdr_options test to ASSERT_* macros
>>    bpf/selftests: convert tcp_rtt test to ASSERT_* macros
>>    bpf/selftests: convert tcpbpf_user test to ASSERT_* macros
>>    bpf/selftests: convert udp_limit test to ASSERT_* macros
>>
>>   .../selftests/bpf/prog_tests/sockmap_basic.c       | 87 ++++++++--------------
>>   .../selftests/bpf/prog_tests/sockmap_ktls.c        | 39 +++-------
>>   tools/testing/selftests/bpf/prog_tests/sockopt.c   |  4 +-
>>   .../selftests/bpf/prog_tests/sockopt_inherit.c     | 30 ++++----
>>   .../selftests/bpf/prog_tests/sockopt_multi.c       | 10 +--
>>   .../testing/selftests/bpf/prog_tests/sockopt_sk.c  |  2 +-
>>   .../testing/selftests/bpf/prog_tests/tcp_estats.c  |  4 +-
>>   .../selftests/bpf/prog_tests/tcp_hdr_options.c     | 80 +++++++-------------
>>   tools/testing/selftests/bpf/prog_tests/tcp_rtt.c   | 13 ++--
>>   .../testing/selftests/bpf/prog_tests/tcpbpf_user.c | 32 +++-----
>>   tools/testing/selftests/bpf/prog_tests/udp_limit.c | 18 ++---
>>   11 files changed, 117 insertions(+), 202 deletions(-)
>>
>> --
>> 1.8.3.1
>>
> Thanks for the clean up! I've changed one ASSERT_OK(err && errno !=
> ENOENT) to ASSERT_EQ(errno, ENOENT) in patch #1, that expresses the
> intent more directly. Please also keep in mind that patch prefix
> should (conventionally) be "selftests/bpf: ". I've fixed that for all
> patches while applying.

I got it.Thanks for the fixes.

>
> We are down to:
>
> $ rg -w CHECK | wc -l
> 1186
> 09/28 17:36:39.381
> andriin@devbig019:~/linux/tools/testing/selftests/bpf (master)
> $ rg -w CHECK_FAIL | wc -l
> 463
>
> Some ways to go still, but slowly decreasing. Thank you for your contribution!