Skip to content

Commit

Permalink
selftests/bpf: Fix test_progs's parsing of test numbers
Browse files Browse the repository at this point in the history
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: 3a516a0 ("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
  • Loading branch information
anakryiko authored and borkmann committed Mar 17, 2020
1 parent 94c2f50 commit fc32490
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tools/testing/selftests/bpf/test_progs.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static int parse_str_list(const char *s, struct str_set *set)

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;

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fc32490

Please sign in to comment.