bpf: Selftests, break down test_sockmap into subtests
authorJohn Fastabend <john.fastabend@gmail.com>
Wed, 13 May 2020 19:14:44 +0000 (12:14 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Sat, 16 May 2020 00:56:49 +0000 (02:56 +0200)
commit328aa08a081bb94f9aba506363186de6ec3382ec
tree62c6d74e082a7fe0d0d4ddeddba37e81199afc81
parent18d4e900a4500c54af56b9ad39f4d3b378eb0661
bpf: Selftests, break down test_sockmap into subtests

At the moment test_sockmap runs all 800+ tests ungrouped which is not
ideal because it makes it hard to see what is failing but also more
importantly its hard to confirm all cases are tested. Additionally,
after inspecting we noticed the runtime is bloated because we run
many duplicate tests. Worse some of these tests are known error cases
that wait for the recvmsg handler to timeout which creats long delays.
Also we noted some tests were not clearing their options and as a
result the following tests would run with extra and incorrect options.

Fix this by reorganizing test code so its clear what tests are running
and when. Then it becomes easy to remove duplication and run tests with
only the set of send/recv patterns that are relavent.

To accomplish this break test_sockmap into subtests and remove
unnecessary duplication. The output is more readable now and
the runtime reduced.

Now default output prints subtests like this,

 $ ./test_sockmap
 # 1/ 6  sockmap:txmsg test passthrough:OK
 ...
 #22/ 1 sockhash:txmsg test push/pop data:OK
 Pass: 22 Fail: 0

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/158939728384.15176.13601520183665880762.stgit@john-Precision-5820-Tower
tools/testing/selftests/bpf/test_sockmap.c