aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/bpf
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2020-03-13 18:39:31 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2020-03-17 19:30:46 +0100
commitfc32490bff855a539d253c8a52c5a1ba51d1325a (patch)
tree5776c7a29cbec9405fbde8d5cba00412fce235e4 /tools/testing/selftests/bpf
parentselftests/bpf: Fix race in tcp_rtt test (diff)
downloadwireguard-linux-fc32490bff855a539d253c8a52c5a1ba51d1325a.tar.xz
wireguard-linux-fc32490bff855a539d253c8a52c5a1ba51d1325a.zip
selftests/bpf: Fix test_progs's parsing of test numbers
When specifying disjoint set of tests, test_progs doesn't set skipped test's array elements to false. This leads to spurious execution of tests that should have been skipped. Fix it by explicitly initializing them to false. Fixes: 3a516a0a3a7b ("selftests/bpf: add sub-tests support for test_progs") Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/20200314013932.4035712-2-andriin@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf')
-rw-r--r--tools/testing/selftests/bpf/test_progs.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index dc12fd0de1c2..c8cb407482c6 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -424,7 +424,7 @@ err:
int parse_num_list(const char *s, struct test_selector *sel)
{
- int i, set_len = 0, num, start = 0, end = -1;
+ int i, set_len = 0, new_len, num, start = 0, end = -1;
bool *set = NULL, *tmp, parsing_end = false;
char *next;
@@ -459,18 +459,19 @@ int parse_num_list(const char *s, struct test_selector *sel)
return -EINVAL;
if (end + 1 > set_len) {
- set_len = end + 1;
- tmp = realloc(set, set_len);
+ new_len = end + 1;
+ tmp = realloc(set, new_len);
if (!tmp) {
free(set);
return -ENOMEM;
}
+ for (i = set_len; i < start; i++)
+ tmp[i] = false;
set = tmp;
+ set_len = new_len;
}
- for (i = start; i <= end; i++) {
+ for (i = start; i <= end; i++)
set[i] = true;
- }
-
}
if (!set)