Message ID | 20200123165934.9584-5-lmb@cloudflare.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [bpf,1/4] selftests: bpf: use a temporary file in test_sockmap | expand |
On Thu, Jan 23, 2020 at 04:59:33PM +0000, Lorenz Bauer wrote: > Currently, there is a lot of false positives if a single reuseport test > fails. This is because expected_results and the result map are not cleared. Ah, right. An earlier test failure has ripple effect on the following tests. I notice another embarrassing typo. Can you also make this change in this fix? -static enum result expected_results[NR_RESULTS]; +static __u32 expected_results[NR_RESULTS]; > > Zero both after individual test runs, which fixes the mentioned false > positives. Thanks for the fix! Acked-by: Martin KaFai Lau <kafai@fb.com>
diff --git a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c index 09a536af139a..0bab8b1ca1c3 100644 --- a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c +++ b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c @@ -699,7 +699,19 @@ static void setup_per_test(int type, sa_family_t family, bool inany, static void cleanup_per_test(bool no_inner_map) { - int i, err; + int i, err, zero = 0; + + memset(expected_results, 0, sizeof(expected_results)); + + for (i = 0; i < NR_RESULTS; i++) { + err = bpf_map_update_elem(result_map, &i, &zero, BPF_ANY); + RET_IF(err, "reset elem in result_map", + "i:%u err:%d errno:%d\n", i, err, errno); + } + + err = bpf_map_update_elem(linum_map, &zero, &zero, BPF_ANY); + RET_IF(err, "reset line number in linum_map", "err:%d errno:%d\n", + err, errno); for (i = 0; i < REUSEPORT_ARRAY_SIZE; i++) close(sk_fds[i]);
Currently, there is a lot of false positives if a single reuseport test fails. This is because expected_results and the result map are not cleared. Zero both after individual test runs, which fixes the mentioned false positives. Signed-off-by: Lorenz Bauer <lmb@cloudflare.com> --- .../selftests/bpf/prog_tests/select_reuseport.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)