Skip to content

Revamp test_progs as a test running framework

Andrii Nakryiko bpf netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest9 patches 1 replyIn review
  2. v29 patches 3 repliesSuperseded
  3. v19 patches 18 repliesSuperseded

Changes in v3 from the cover letter

- fix buffered output rare unitialized value bug (Alexei);
- fix buffered output va_list reuse bug (Alexei);
- fix buffered output truncation due to interleaving zero terminators;

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9selftests/bpf: prevent headers to be compiled as C codetools/testing/selftests/bpf/Makefile+3 -30 replies
2/9selftests/bpf: revamp test_progs to allow more controltools/testing/selftests/bpf/Makefile tools/testing/selftests/bpf/test_progs.c+77 -150 replies
3/9selftests/bpf: add test selectors by number and name to test_progstools/testing/selftests/bpf/test_progs.c+39 -40 replies
4/9libbpf: return previous print callback from libbpf_set_printtools/lib/bpf/libbpf.c tools/lib/bpf/libbpf.h+5 -20 replies
5/9selftest/bpf: centralize libbpf logging management for test_progstools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c tools/testing/selftests/bpf/prog_tests/reference_tracking.c tools/testing/selftests/bpf/test_progs.c+38 -120 replies
6/9selftests/bpf: abstract away test log outputtools/testing/selftests/bpf/prog_tests/bpf_obj_id.c tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c +9 more+183 -730 replies
7/9selftests/bpf: add sub-tests support for test_progstools/testing/selftests/bpf/test_progs.c tools/testing/selftests/bpf/test_progs.h+185 -290 replies
8/9selftests/bpf: convert bpf_verif_scale.c to sub-tests APItools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c+40 -370 replies
9/9selftests/bpf: convert send_signal.c to use subteststools/testing/selftests/bpf/prog_tests/send_signal.c+6 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 bpf-next 0/9] Revamp test_progs as a test running framework

This patch set makes a number of changes to test_progs selftest, which is a collection of many other tests (and sometimes sub-tests as well), to provide better testing experience and allow to start convering many individual test programs under selftests/bpf into a single and convenient test runner.

Patch #1 fixes issue with Makefile, which makes prog_tests/test.h compiled as a C code. This fix allows to change how test.h is generated, providing ability to have more control on what and how tests are run.

Patch #2 changes how test.h is auto-generated, which allows to have test definitions, instead of just running test functions. This gives ability to do more complicated test run policies.

Patch #3 adds -t <test-name> and -n <test-num> selectors to run only subset of tests.

Patch #4 changes libbpf_set_print() to return previously set print callback, allowing to temporarily replace current print callback and then set it back. This is necessary for some tests that want more control over libbpf logging.

Patch #5 sets up and takes over libbpf logging from individual tests to test_prog runner, adding -vv verbosity to capture debug output from libbpf. This is useful when debugging failing tests.

Patch #6 furthers test output management and buffers it by default, emitting log output only if test fails. This give succinct and clean default test output. It's possible to bypass this behavior with -v flag, which will turn off test output buffering.

Patch #7 adds support for sub-tests. It also enhances -t and -n selectors to both support ability to specify sub-test selectors, as well as enhancing number selector to accept sets of test, instead of just individual test number.

Patch #8 converts bpf_verif_scale.c test to use sub-test APIs.

Patch #9 converts send_signal.c tests to use sub-test APIs.

v2->v3:
- fix buffered output rare unitialized value bug (Alexei);
- fix buffered output va_list reuse bug (Alexei);
- fix buffered output truncation due to interleaving zero terminators;

v1->v2:
- drop libbpf_swap_print, instead return previous function from

    libbpf_set_print (Stanislav);

Andrii Nakryiko (9):
selftests/bpf: prevent headers to be compiled as C code selftests/bpf: revamp test_progs to allow more control selftests/bpf: add test selectors by number and name to test_progs
libbpf: return previous print callback from libbpf_set_print selftest/bpf: centralize libbpf logging management for test_progs selftests/bpf: abstract away test log output selftests/bpf: add sub-tests support for test_progs selftests/bpf: convert bpf_verif_scale.c to sub-tests API selftests/bpf: convert send_signal.c to use subtests

 tools/lib/bpf/libbpf.c                        |   5 +-
 tools/lib/bpf/libbpf.h                        |   2 +-
 tools/testing/selftests/bpf/Makefile          |  14 +-
 .../selftests/bpf/prog_tests/bpf_obj_id.c     |   6 +-
 .../bpf/prog_tests/bpf_verif_scale.c          |  90 ++--
 .../bpf/prog_tests/get_stack_raw_tp.c         |   4 +-
 .../selftests/bpf/prog_tests/l4lb_all.c       |   2 +-
 .../selftests/bpf/prog_tests/map_lock.c       |  10 +-
 .../bpf/prog_tests/reference_tracking.c       |  15 +-
 .../selftests/bpf/prog_tests/send_signal.c    |  17 +-
 .../selftests/bpf/prog_tests/spinlock.c       |   2 +-
 .../bpf/prog_tests/stacktrace_build_id.c      |   4 +-
 .../bpf/prog_tests/stacktrace_build_id_nmi.c  |   4 +-
 .../selftests/bpf/prog_tests/xdp_noinline.c   |   3 +-
 tools/testing/selftests/bpf/test_progs.c      | 383 +++++++++++++++++-
 tools/testing/selftests/bpf/test_progs.h      |  45 +-
 16 files changed, 502 insertions(+), 104 deletions(-)
Signature · 1 line
2.17.1