selftests/bpf: Test_progs option for getting number of tests
authorJesper Dangaard Brouer <brouer@redhat.com>
Wed, 1 Jul 2020 21:44:12 +0000 (23:44 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 1 Jul 2020 22:22:13 +0000 (15:22 -0700)
commit643e7233aa948901dce81d4573c91ed99fdd272e
tree588690946a045ae94d3d9f12f4f516015cc4dca1
parent6c92bd5cd4650c39dd929565ee172984c680fead
selftests/bpf: Test_progs option for getting number of tests

It can be practial to get the number of tests that test_progs contain.
This could for example be used to create a shell for-loop construct that
runs the individual tests.

Like:
 for N in $(seq 1 $(./test_progs -c)); do
   ./test_progs -n $N 2>&1 > result_test_${N}.log &
 done ; wait

V2: Add the ability to return the count for the selected tests. This is
useful for getting a count e.g. after excluding some tests with option -b.
The current beakers test script like to report the max test count upfront.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/159363985244.930467.12617117873058936829.stgit@firesoul
tools/testing/selftests/bpf/test_progs.c
tools/testing/selftests/bpf/test_progs.h