diff --git a/run-vmtest/normalize_bpf_test_names.py b/run-vmtest/normalize_bpf_test_names.py index b8a88286..d32aec51 100755 --- a/run-vmtest/normalize_bpf_test_names.py +++ b/run-vmtest/normalize_bpf_test_names.py @@ -45,7 +45,10 @@ def next_test(lines: list[str]): prev = lines[0] def is_subtest(line: str) -> bool: - return ('/' in line) and ('/' not in prev) and line.startswith(prev) + # Compare against "prev/" rather than "prev": without the separator + # "a_test" also swallows "a_test_two/subtest", which is a subtest of a + # different test that happens to share a prefix. + return ('/' not in prev) and line.startswith(prev + '/') yield lines[0] for line in lines[1:]: diff --git a/run-vmtest/tests/normalize_bpf_test_names/expected-output.txt b/run-vmtest/tests/normalize_bpf_test_names/expected-output.txt index e0029e2b..1533edd4 100644 --- a/run-vmtest/tests/normalize_bpf_test_names/expected-output.txt +++ b/run-vmtest/tests/normalize_bpf_test_names/expected-output.txt @@ -10,3 +10,5 @@ test4_blah test5 test6 test7/subtest123 +test8 +test8_peek/subtest1 diff --git a/run-vmtest/tests/normalize_bpf_test_names/input.txt b/run-vmtest/tests/normalize_bpf_test_names/input.txt index 5b9a48d0..14fb97e7 100644 --- a/run-vmtest/tests/normalize_bpf_test_names/input.txt +++ b/run-vmtest/tests/normalize_bpf_test_names/input.txt @@ -18,3 +18,5 @@ test5 # should consume test5/s ## some blank lines, should be removed +test8 +test8_peek/subtest1 # must be kept: test8_peek is a different test, not a subtest of test8