Skip to content

Commit 7c26084

Browse files
committed
contest: subcases: handle retry cases
In case of failure, some tests are restarted. That's great, but when parsing the subcases (nested tests), the previous results were overridden. Also, when displaying the results, the 'retry' field from the main test was re-used in each subcases: quite confusing for the reader. Now, in case of retry, the previous 'results' list will be modified to add a new 'retry' entry for each test that has been re-validated. If the previous test with the same name cannot be found, that could be because there was major issue before and some subcases have not been executed (or the names are not fixed). In this case, a new entry with a skipped first attempt will be added to the list. When querying the subcases results, the new 'retry' entry will be used, or none if it is not there. Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
1 parent f08356b commit 7c26084

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

contest/backend/query.py

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ def result_as_l2(raw):
6363
del data["results"]
6464
if "time" in data:
6565
del data["time"]
66+
# in case of retry, the subtest might not have been re-executed
67+
if "retry" in data:
68+
del data["retry"]
6669
data |= case
6770
data["test"] = l1["test"] + '.' + case["test"]
6871
flat.append(data)

contest/remote/vmksft-p.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_prog_list(vm, targets):
6969
return [(e.split(":")[0].strip(), e.split(":")[1].strip()) for e in targets]
7070

7171

72-
def _parse_nested_tests(full_run):
72+
def _parse_nested_tests(full_run, prev_results):
7373
tests = []
7474
nested_tests = False
7575

@@ -110,8 +110,20 @@ def _parse_nested_tests(full_run):
110110

111111
r['result'] = result
112112

113-
tests.append(r)
113+
if prev_results is not None:
114+
for entry in prev_results:
115+
if entry['test'] == r['test']:
116+
entry['retry'] = result
117+
break
118+
else:
119+
# the first run didn't validate this test: add it to the list
120+
r['result'] = 'skip'
121+
r['retry'] = result
122+
prev_results.append(r)
123+
else:
124+
tests.append(r)
114125

126+
# return an empty list when there are prev results: no replacement needed
115127
return tests
116128

117129
def _vm_thread(config, results_path, thr_id, hard_stop, in_queue, out_queue):
@@ -195,8 +207,13 @@ def _vm_thread(config, results_path, thr_id, hard_stop, in_queue, out_queue):
195207
outcome['crashes'] = crashes
196208

197209
if config.getboolean('ksft', 'nested_tests', fallback=False):
210+
if is_retry:
211+
prev_results = outcome['results'] if 'results' in outcome else []
212+
else:
213+
prev_results = None
214+
198215
# this will only parse nested tests inside the TAP comments
199-
nested_tests = _parse_nested_tests(vm.log_out)
216+
nested_tests = _parse_nested_tests(vm.log_out, prev_results)
200217
if nested_tests:
201218
outcome['results'] = nested_tests
202219

0 commit comments

Comments
 (0)