summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
diff options
context:
space:
mode:
authorStephen Veiss <sveiss@meta.com>2023-04-28 01:53:32 +0300
committerAndrii Nakryiko <andrii@kernel.org>2023-05-02 01:30:02 +0300
commit0a5c0de8b66f9789422f04de7304e374a2ea8df5 (patch)
treea70ff308869b998c772e29142121fc7c9ccb6fcb /tools/testing/selftests/bpf/prog_tests/arg_parsing.c
parentc39028b333f3a3a765c5c0b9726b8e38aedf0ba1 (diff)
downloadlinux-0a5c0de8b66f9789422f04de7304e374a2ea8df5.tar.xz
selftests/bpf: Extract insert_test from parse_test_list
Split the logic to insert new tests into test filter sets out from parse_test_list. Fix the subtest insertion logic to reuse an existing top-level test filter, which prevents the creation of duplicate top-level test filters each with a single subtest. Signed-off-by: Stephen Veiss <sveiss@meta.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20230427225333.3506052-2-sveiss@meta.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/arg_parsing.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/arg_parsing.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/arg_parsing.c b/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
index b17bfa0e0aac..3754cd5f8c0a 100644
--- a/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
+++ b/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
@@ -96,6 +96,19 @@ static void test_parse_test_list(void)
goto error;
ASSERT_OK(strcmp("*bpf_cookie*", set.tests[0].name), "test name");
ASSERT_OK(strcmp("*trace*", set.tests[0].subtests[0]), "subtest name");
+ free_test_filter_set(&set);
+
+ ASSERT_OK(parse_test_list("t/subtest1,t/subtest2", &set, true),
+ "parsing");
+ if (!ASSERT_EQ(set.cnt, 1, "count of test filters"))
+ goto error;
+ if (!ASSERT_OK_PTR(set.tests, "test filters initialized"))
+ goto error;
+ if (!ASSERT_EQ(set.tests[0].subtest_cnt, 2, "subtest filters count"))
+ goto error;
+ ASSERT_OK(strcmp("t", set.tests[0].name), "test name");
+ ASSERT_OK(strcmp("subtest1", set.tests[0].subtests[0]), "subtest name");
+ ASSERT_OK(strcmp("subtest2", set.tests[0].subtests[1]), "subtest name");
error:
free_test_filter_set(&set);
}