mbox series

[bpf-next,v3,0/4] migrate from bpf_prog_test_run{,_xattr}

Message ID 20220202235423.1097270-1-delyank@fb.com (mailing list archive)
Headers show
Series migrate from bpf_prog_test_run{,_xattr} | expand

Message

Delyan Kratunov Feb. 2, 2022, 11:54 p.m. UTC
Fairly straight-forward mechanical transformation from bpf_prog_test_run
and bpf_prog_test_run_xattr to the bpf_prog_test_run_opts goodness.

I did a fair amount of drive-by CHECK/CHECK_ATTR cleanups as well, though
certainly not everything possible. Primarily, I did not want to just change
arguments to CHECK calls, though I had to do a bit more than that
in some cases (overall, -119 CHECK calls and all CHECK_ATTR calls).

v2 -> v3:
Don't introduce CHECK_OPTS, replace CHECK/CHECK_ATTR usages we need to touch
with ASSERT_* calls instead.
Don't be prescriptive about the opts var name and keep old names where that would
minimize unnecessary code churn.
Drop _xattr-specific checks in prog_run_xattr and rename accordingly.

v1 -> v2:
Split selftests/bpf changes into two commits to appease the mailing list.


Delyan Kratunov (4):
  selftests/bpf: migrate from bpf_prog_test_run
  selftests/bpf: migrate from bpf_prog_test_run_xattr
  bpftool: migrate from bpf_prog_test_run_xattr
  libbpf: Deprecate bpf_prog_test_run_xattr and bpf_prog_test_run

 tools/bpf/bpftool/prog.c                      |   5 +-
 tools/lib/bpf/bpf.h                           |   4 +-
 .../selftests/bpf/prog_tests/atomics.c        |  72 +++---
 .../testing/selftests/bpf/prog_tests/bpf_nf.c |  10 +-
 .../selftests/bpf/prog_tests/check_mtu.c      |  38 +--
 .../selftests/bpf/prog_tests/cls_redirect.c   |  10 +-
 .../selftests/bpf/prog_tests/dummy_st_ops.c   |  27 +-
 .../selftests/bpf/prog_tests/fentry_fexit.c   |  24 +-
 .../selftests/bpf/prog_tests/fentry_test.c    |   7 +-
 .../selftests/bpf/prog_tests/fexit_bpf2bpf.c  |  32 ++-
 .../selftests/bpf/prog_tests/fexit_stress.c   |  22 +-
 .../selftests/bpf/prog_tests/fexit_test.c     |   7 +-
 .../selftests/bpf/prog_tests/flow_dissector.c |  31 ++-
 .../prog_tests/flow_dissector_load_bytes.c    |  24 +-
 .../selftests/bpf/prog_tests/for_each.c       |  32 ++-
 .../bpf/prog_tests/get_func_args_test.c       |  12 +-
 .../bpf/prog_tests/get_func_ip_test.c         |  10 +-
 .../selftests/bpf/prog_tests/global_data.c    |  24 +-
 .../bpf/prog_tests/global_func_args.c         |  13 +-
 .../selftests/bpf/prog_tests/kfree_skb.c      |  16 +-
 .../selftests/bpf/prog_tests/kfunc_call.c     |  46 ++--
 .../selftests/bpf/prog_tests/ksyms_module.c   |  23 +-
 .../selftests/bpf/prog_tests/l4lb_all.c       |  35 ++-
 .../selftests/bpf/prog_tests/map_lock.c       |  15 +-
 .../selftests/bpf/prog_tests/map_ptr.c        |  16 +-
 .../selftests/bpf/prog_tests/modify_return.c  |  33 +--
 .../selftests/bpf/prog_tests/pkt_access.c     |  26 +-
 .../selftests/bpf/prog_tests/pkt_md_access.c  |  14 +-
 .../selftests/bpf/prog_tests/prog_run_opts.c  |  77 ++++++
 .../selftests/bpf/prog_tests/prog_run_xattr.c |  83 ------
 .../bpf/prog_tests/queue_stack_map.c          |  46 ++--
 .../bpf/prog_tests/raw_tp_test_run.c          |  64 ++---
 .../bpf/prog_tests/raw_tp_writable_test_run.c |  16 +-
 .../selftests/bpf/prog_tests/signal_pending.c |  23 +-
 .../selftests/bpf/prog_tests/skb_ctx.c        |  81 +++---
 .../selftests/bpf/prog_tests/skb_helpers.c    |  16 +-
 .../selftests/bpf/prog_tests/sockmap_basic.c  |  20 +-
 .../selftests/bpf/prog_tests/spinlock.c       |  14 +-
 .../selftests/bpf/prog_tests/syscall.c        |  10 +-
 .../selftests/bpf/prog_tests/tailcalls.c      | 238 +++++++++---------
 .../selftests/bpf/prog_tests/test_profiler.c  |  14 +-
 .../bpf/prog_tests/test_skb_pkt_end.c         |  15 +-
 .../testing/selftests/bpf/prog_tests/timer.c  |   7 +-
 .../selftests/bpf/prog_tests/timer_mim.c      |   7 +-
 .../selftests/bpf/prog_tests/trace_ext.c      |  28 ++-
 tools/testing/selftests/bpf/prog_tests/xdp.c  |  34 ++-
 .../bpf/prog_tests/xdp_adjust_frags.c         |  32 ++-
 .../bpf/prog_tests/xdp_adjust_tail.c          | 122 +++++----
 .../selftests/bpf/prog_tests/xdp_bpf2bpf.c    |  14 +-
 .../selftests/bpf/prog_tests/xdp_noinline.c   |  44 ++--
 .../selftests/bpf/prog_tests/xdp_perf.c       |  19 +-
 tools/testing/selftests/bpf/test_lru_map.c    |  11 +-
 tools/testing/selftests/bpf/test_verifier.c   |  16 +-
 53 files changed, 872 insertions(+), 807 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/prog_run_opts.c
 delete mode 100644 tools/testing/selftests/bpf/prog_tests/prog_run_xattr.c

--
2.30.2

Comments

Andrii Nakryiko Feb. 3, 2022, 7:11 a.m. UTC | #1
On Wed, Feb 2, 2022 at 3:56 PM Delyan Kratunov <delyank@fb.com> wrote:
>
> Fairly straight-forward mechanical transformation from bpf_prog_test_run
> and bpf_prog_test_run_xattr to the bpf_prog_test_run_opts goodness.
>
> I did a fair amount of drive-by CHECK/CHECK_ATTR cleanups as well, though
> certainly not everything possible. Primarily, I did not want to just change
> arguments to CHECK calls, though I had to do a bit more than that
> in some cases (overall, -119 CHECK calls and all CHECK_ATTR calls).
>
> v2 -> v3:
> Don't introduce CHECK_OPTS, replace CHECK/CHECK_ATTR usages we need to touch
> with ASSERT_* calls instead.
> Don't be prescriptive about the opts var name and keep old names where that would
> minimize unnecessary code churn.
> Drop _xattr-specific checks in prog_run_xattr and rename accordingly.
>
> v1 -> v2:
> Split selftests/bpf changes into two commits to appease the mailing list.
>
>
> Delyan Kratunov (4):
>   selftests/bpf: migrate from bpf_prog_test_run
>   selftests/bpf: migrate from bpf_prog_test_run_xattr
>   bpftool: migrate from bpf_prog_test_run_xattr
>   libbpf: Deprecate bpf_prog_test_run_xattr and bpf_prog_test_run
>
>  tools/bpf/bpftool/prog.c                      |   5 +-
>  tools/lib/bpf/bpf.h                           |   4 +-
>  .../selftests/bpf/prog_tests/atomics.c        |  72 +++---
>  .../testing/selftests/bpf/prog_tests/bpf_nf.c |  10 +-
>  .../selftests/bpf/prog_tests/check_mtu.c      |  38 +--
>  .../selftests/bpf/prog_tests/cls_redirect.c   |  10 +-
>  .../selftests/bpf/prog_tests/dummy_st_ops.c   |  27 +-
>  .../selftests/bpf/prog_tests/fentry_fexit.c   |  24 +-
>  .../selftests/bpf/prog_tests/fentry_test.c    |   7 +-
>  .../selftests/bpf/prog_tests/fexit_bpf2bpf.c  |  32 ++-
>  .../selftests/bpf/prog_tests/fexit_stress.c   |  22 +-
>  .../selftests/bpf/prog_tests/fexit_test.c     |   7 +-
>  .../selftests/bpf/prog_tests/flow_dissector.c |  31 ++-
>  .../prog_tests/flow_dissector_load_bytes.c    |  24 +-
>  .../selftests/bpf/prog_tests/for_each.c       |  32 ++-
>  .../bpf/prog_tests/get_func_args_test.c       |  12 +-
>  .../bpf/prog_tests/get_func_ip_test.c         |  10 +-
>  .../selftests/bpf/prog_tests/global_data.c    |  24 +-
>  .../bpf/prog_tests/global_func_args.c         |  13 +-
>  .../selftests/bpf/prog_tests/kfree_skb.c      |  16 +-
>  .../selftests/bpf/prog_tests/kfunc_call.c     |  46 ++--
>  .../selftests/bpf/prog_tests/ksyms_module.c   |  23 +-
>  .../selftests/bpf/prog_tests/l4lb_all.c       |  35 ++-
>  .../selftests/bpf/prog_tests/map_lock.c       |  15 +-
>  .../selftests/bpf/prog_tests/map_ptr.c        |  16 +-
>  .../selftests/bpf/prog_tests/modify_return.c  |  33 +--
>  .../selftests/bpf/prog_tests/pkt_access.c     |  26 +-
>  .../selftests/bpf/prog_tests/pkt_md_access.c  |  14 +-
>  .../selftests/bpf/prog_tests/prog_run_opts.c  |  77 ++++++
>  .../selftests/bpf/prog_tests/prog_run_xattr.c |  83 ------
>  .../bpf/prog_tests/queue_stack_map.c          |  46 ++--
>  .../bpf/prog_tests/raw_tp_test_run.c          |  64 ++---
>  .../bpf/prog_tests/raw_tp_writable_test_run.c |  16 +-
>  .../selftests/bpf/prog_tests/signal_pending.c |  23 +-
>  .../selftests/bpf/prog_tests/skb_ctx.c        |  81 +++---
>  .../selftests/bpf/prog_tests/skb_helpers.c    |  16 +-
>  .../selftests/bpf/prog_tests/sockmap_basic.c  |  20 +-
>  .../selftests/bpf/prog_tests/spinlock.c       |  14 +-
>  .../selftests/bpf/prog_tests/syscall.c        |  10 +-
>  .../selftests/bpf/prog_tests/tailcalls.c      | 238 +++++++++---------
>  .../selftests/bpf/prog_tests/test_profiler.c  |  14 +-
>  .../bpf/prog_tests/test_skb_pkt_end.c         |  15 +-
>  .../testing/selftests/bpf/prog_tests/timer.c  |   7 +-
>  .../selftests/bpf/prog_tests/timer_mim.c      |   7 +-
>  .../selftests/bpf/prog_tests/trace_ext.c      |  28 ++-
>  tools/testing/selftests/bpf/prog_tests/xdp.c  |  34 ++-
>  .../bpf/prog_tests/xdp_adjust_frags.c         |  32 ++-
>  .../bpf/prog_tests/xdp_adjust_tail.c          | 122 +++++----
>  .../selftests/bpf/prog_tests/xdp_bpf2bpf.c    |  14 +-
>  .../selftests/bpf/prog_tests/xdp_noinline.c   |  44 ++--
>  .../selftests/bpf/prog_tests/xdp_perf.c       |  19 +-
>  tools/testing/selftests/bpf/test_lru_map.c    |  11 +-
>  tools/testing/selftests/bpf/test_verifier.c   |  16 +-
>  53 files changed, 872 insertions(+), 807 deletions(-)

Massive work, thanks a lot! Applied to bpf-next.

>  create mode 100644 tools/testing/selftests/bpf/prog_tests/prog_run_opts.c
>  delete mode 100644 tools/testing/selftests/bpf/prog_tests/prog_run_xattr.c
>
> --
> 2.30.2
patchwork-bot+netdevbpf@kernel.org Feb. 3, 2022, 7:20 a.m. UTC | #2
Hello:

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

On Wed, 2 Feb 2022 15:54:19 -0800 you wrote:
> Fairly straight-forward mechanical transformation from bpf_prog_test_run
> and bpf_prog_test_run_xattr to the bpf_prog_test_run_opts goodness.
> 
> I did a fair amount of drive-by CHECK/CHECK_ATTR cleanups as well, though
> certainly not everything possible. Primarily, I did not want to just change
> arguments to CHECK calls, though I had to do a bit more than that
> in some cases (overall, -119 CHECK calls and all CHECK_ATTR calls).
> 
> [...]

Here is the summary with links:
  - [bpf-next,v3,1/4] selftests/bpf: migrate from bpf_prog_test_run
    https://git.kernel.org/bpf/bpf-next/c/04fcb5f9a104
  - [bpf-next,v3,2/4] selftests/bpf: migrate from bpf_prog_test_run_xattr
    https://git.kernel.org/bpf/bpf-next/c/393161837845
  - [bpf-next,v3,3/4] bpftool: migrate from bpf_prog_test_run_xattr
    https://git.kernel.org/bpf/bpf-next/c/9cce53138dd9
  - [bpf-next,v3,4/4] libbpf: Deprecate bpf_prog_test_run_xattr and bpf_prog_test_run
    https://git.kernel.org/bpf/bpf-next/c/3e1ab843d2d4

You are awesome, thank you!