Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3f74056

Browse files
committedOct 31, 2024··
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 failed 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 3f74056

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-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

+22-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,22 @@ def _parse_nested_tests(full_run):
110110

111111
r['result'] = result
112112

113-
tests.append(r)
113+
if prev_results is not None:
114+
found = False
115+
for entry in prev_results:
116+
if entry['test'] == r['test']:
117+
entry['retry'] = result
118+
found = True
119+
break
120+
if not found:
121+
# the first run didn't validate this test: mark 1st attempt as fail
122+
r['result'] = 'fail'
123+
r['retry'] = result
124+
prev_results.append(r)
125+
else:
126+
tests.append(r)
114127

128+
# return an empty list when there are prev results: no replacement needed
115129
return tests
116130

117131
def _vm_thread(config, results_path, thr_id, hard_stop, in_queue, out_queue):
@@ -195,8 +209,13 @@ def _vm_thread(config, results_path, thr_id, hard_stop, in_queue, out_queue):
195209
outcome['crashes'] = crashes
196210

197211
if config.getboolean('ksft', 'nested_tests', fallback=False):
212+
if is_retry:
213+
prev_results = outcome['results'] if 'results' in outcome else []
214+
else:
215+
prev_results = None
216+
198217
# this will only parse nested tests inside the TAP comments
199-
nested_tests = _parse_nested_tests(vm.log_out)
218+
nested_tests = _parse_nested_tests(vm.log_out, prev_results)
200219
if nested_tests:
201220
outcome['results'] = nested_tests
202221

0 commit comments

Comments
 (0)
Please sign in to comment.