CH_test_tool: Store logs of failed subtests

This commit is contained in:
Purna Pavan Chandra Aekkaladevi 2022-12-19 12:55:52 +05:30 коммит произвёл LiliDeng
Родитель 103ddf453f
Коммит a8c1976846
1 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -73,7 +73,7 @@ class CloudHypervisorTests(Tool):
# Report subtest results and collect logs before doing any
# assertions.
results = self._extract_test_results(result.stdout)
results = self._extract_test_results(result.stdout, log_path)
failures = [r.name for r in results if r.status == TestStatus.FAILED]
for r in results:
@ -190,7 +190,9 @@ class CloudHypervisorTests(Tool):
return self._check_exists()
def _extract_test_results(self, output: str) -> List[CloudHypervisorTestResult]:
def _extract_test_results(
self, output: str, log_path: Path
) -> List[CloudHypervisorTestResult]:
results: List[CloudHypervisorTestResult] = []
# Cargo will output test status for each test separately in JSON format. Parse
@ -224,6 +226,15 @@ class CloudHypervisorTests(Tool):
)
)
# store stdout of failed subtests
if status == TestStatus.FAILED:
# test case names have ':'s in them (e.g. "integration::test_vfio").
# ':'s are not allowed in file names in Windows.
testcase = result["name"].replace(":", "-")
testcase_log_file = log_path / f"{testcase}.log"
with open(testcase_log_file, "w") as f:
f.write(result["stdout"])
return results
def _send_subtest_msg(