[PATCH bpf-next 0/3] selftests/bpf: unblock bpf-gcc test coverage

Vineet Gupta <[email protected]>
Newsgroups org.kernel.vger.bpf
Message-ID <[email protected]>
When doing some unrelated testing, stumbled upon this. A lot of tests
are skipped run under BPF_GCC due to clang only gate. On top, the test
harness declares them passing/OK.

Patch 1 renames a few placeholders a consistent dummy_test name [NFC].

A sample test with BPF_GCC used to say:

| #587/1 verifier_bswap/cpuv4 is not supported by compiler or jit, use a dummy test:OK
| #587	 verifier_bswap:OK

Patch 2 adds a __skip("reason") annotation so a compile-time gated file
reports SKIP rather than OK, making these gaps visible in test_progs
output.

Now the output changes to

| #587/1 verifier_bswap/cpuv4 is not supported by compiler or jit, use a dummy test:SKIP
| #587	 verifier_bswap:SKIP

Patch 3 augments the clang only gate with a per-feature gate supported
by both the compilers. FWIW the clang half has to stay: clang only
defines __BPF_FEATURE_MOVSX and friends at -mcpu=v4 but assembles the
inline asm at -mcpu=v3 too, so dropping it would remove these tests from
the default test_progs flavour where they run today.

And finally the output now is

| 587/1	 verifier_bswap/BSWAP, 16:OK
| #587/2 verifier_bswap/BSWAP, 16 @unpriv:SKIP
| #587/3 verifier_bswap/BSWAP, 32:OK
| #587/4 verifier_bswap/BSWAP, 32 @unpriv:SKIP
| #587/5 verifier_bswap/BSWAP, 64:OK
| #587/6 verifier_bswap/BSWAP, 64 @unpriv:SKIP
| #587/7 verifier_bswap/bswap16_range:OK
| #587/8 verifier_bswap/bswap32_range:OK
| #587/9 verifier_bswap/bswap64_range:OK
| #587/10 verifier_bswap/be16_range:OK
| #587/11 verifier_bswap/be32_range:OK
| #587/12 verifier_bswap/be64_range:OK
| #587/13 verifier_bswap/le16_range:OK
| #587/14 verifier_bswap/le32_range:OK
| #587/15 verifier_bswap/le64_range:OK
| #587/16 verifier_bswap/BSWAP, reset reg id:OK
| #587	 verifier_bswap:OK (SKIP: 3/16)

Programs per object recovered under BPF_GCC, 124 in total:

  verifier_sdiv                  1 -> 80
  verifier_movsx                 1 -> 17
  verifier_ldsx                  1 -> 14
  verifier_bswap                 1 -> 13
  compute_live_registers        17 -> 19
  verifier_gotol                 1 -> 2
  verifier_iterating_callbacks  34 -> 35

Two things stay clang-only on purpose: the arena tests using
addr_space_cast, and verifier_load_acquire/verifier_store_release. gas
implements neither.

The increased coverage bore fruits right away as I stumbled into a gas
bug: PR gas/3455. Fix is posted however workaround is needed for the
time being.

Built for x86_64 with both clang and bpf-gcc; the per-object counts above
were read back from the generated objects.

Vineet Gupta (3):
  selftests/bpf: name the remaining placeholder programs dummy_test
    [NFC]
  selftests/bpf: report placeholder tests as SKIP, not OK
  selftests/bpf: Enable some of the blocked cpuv4 instruction tests for
    bpf-gcc

 .../testing/selftests/bpf/progs/arena_kfunc.c |  3 ++-
 tools/testing/selftests/bpf/progs/bpf_misc.h  | 10 ++++++++--
 .../bpf/progs/compute_live_registers.c        |  7 +++++++
 .../selftests/bpf/progs/stack_arg_fail.c      |  3 ++-
 .../selftests/bpf/progs/stack_arg_precision.c |  1 +
 .../selftests/bpf/progs/verifier_bswap.c      |  3 ++-
 .../selftests/bpf/progs/verifier_gotol.c      |  1 +
 .../selftests/bpf/progs/verifier_ldsx.c       | 19 ++++++++++++-------
 .../bpf/progs/verifier_load_acquire.c         |  1 +
 .../selftests/bpf/progs/verifier_movsx.c      |  3 ++-
 .../bpf/progs/verifier_private_stack.c        |  1 +
 .../selftests/bpf/progs/verifier_sdiv.c       |  3 ++-
 .../selftests/bpf/progs/verifier_stack_arg.c  |  1 +
 .../bpf/progs/verifier_stack_arg_order.c      |  1 +
 .../bpf/progs/verifier_store_release.c        |  1 +
 tools/testing/selftests/bpf/test_loader.c     |  9 +++++++++
 16 files changed, 53 insertions(+), 14 deletions(-)

-- 
2.53.0-Meta
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.