Skip to content

Commit a51de88

Browse files
matttbekuba-moo
authored andcommitted
contest: vmksft: support parsing nested tests
Some selftests are executing a lot of different subtests. On the other hand, the kselftests infrastructure only supports TAP 13 format, which doesn't support subtests. If one subtest fails, the whole selftest is marked as failed. It starts to be really annoying when one subtest starts to be unstable and marked as "ignored": all the other subtests are then ignored as well. It is then important to parse subtests to be able to track each subtest individually, and not loose info about the others when one is unstable. A workaround to support subtests with TAP 13 is to embed the subtests result in the comments. This is what is done with MPTCP selftests. That's not specific to MPTCP, because TC and others written in C and using kselftest_harness.h are also doing that. Because it will increase the number of tests, there is a new option, disabled by default, to enable this feature or not per target: [ksft] nested_tests = on When nested TAP results are detected, new tests are being created on top of the main/parent one. At the end of the comments, the parsing continue on the main/parent test. Note that the 'output' of these subtests will not be duplicated in the main test and the subtests ones: what is specific to the subtests will only be in the 'output' of the subtests, not the main one. Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
1 parent 12fc2e1 commit a51de88

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

contest/remote/vmksft.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
boot_timeout=45
4343
[ksft]
4444
targets=net
45+
nested_tests=off / on
4546
4647
4748
Expected:
@@ -51,14 +52,28 @@
5152
"""
5253

5354

54-
def ktap_split(full_run):
55+
def ktap_split(full_run, parse_nested_tests):
5556
tests = []
5657
test = None
5758
test_id = 0
59+
test_main = None
5860

5961
result_re = re.compile(r"(not )?ok (\d+)( -)? ([^#]*[^ ])( # )?([^ ].*)?$")
6062

6163
for line in full_run.split('\n'):
64+
if parse_nested_tests:
65+
# nested tests support: we parse the comments from 'TAP version'
66+
if test_main:
67+
if line.startswith("# "):
68+
line = line[2:]
69+
else:
70+
# back to the main test
71+
test = test_main
72+
test_main = None
73+
elif line.startswith("# TAP version "):
74+
test_main = test
75+
test = None
76+
6277
if test is None:
6378
test = {
6479
"tid": test_id,
@@ -168,7 +183,9 @@ def test(binfo, rinfo, cbarg):
168183
full_run = vm.log_out
169184
vm.dump_log(results_path + '/full', result=retcode, info={"vm_state": vm.fail_state})
170185

171-
tests = ktap_split(full_run)
186+
parse_nested_tests = config.getboolean('ksft', 'nested_tests',
187+
fallback=False)
188+
tests = ktap_split(full_run, parse_nested_tests)
172189
if tests:
173190
pfx = ktap_extract_pfx(tests)
174191
grp_name = namify(pfx)

0 commit comments

Comments
 (0)