Skip to content

Commit fc32490

Browse files
anakryikoborkmann
authored andcommitted
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: 3a516a0 ("selftests/bpf: add sub-tests support for test_progs") Signed-off-by: Andrii Nakryiko <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 94c2f50 commit fc32490

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tools/testing/selftests/bpf/test_progs.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ static int parse_str_list(const char *s, struct str_set *set)
424424

425425
int parse_num_list(const char *s, struct test_selector *sel)
426426
{
427-
int i, set_len = 0, num, start = 0, end = -1;
427+
int i, set_len = 0, new_len, num, start = 0, end = -1;
428428
bool *set = NULL, *tmp, parsing_end = false;
429429
char *next;
430430

@@ -459,18 +459,19 @@ int parse_num_list(const char *s, struct test_selector *sel)
459459
return -EINVAL;
460460

461461
if (end + 1 > set_len) {
462-
set_len = end + 1;
463-
tmp = realloc(set, set_len);
462+
new_len = end + 1;
463+
tmp = realloc(set, new_len);
464464
if (!tmp) {
465465
free(set);
466466
return -ENOMEM;
467467
}
468+
for (i = set_len; i < start; i++)
469+
tmp[i] = false;
468470
set = tmp;
471+
set_len = new_len;
469472
}
470-
for (i = start; i <= end; i++) {
473+
for (i = start; i <= end; i++)
471474
set[i] = true;
472-
}
473-
474475
}
475476

476477
if (!set)

0 commit comments

Comments
 (0)