import os
import sys
import time
+import json
import shutil
import host
return test_result
- def __show_tests_result(self, run_result, check_result):
- Info.head('##### Tests results #####')
-
+ def __make_tests_report(self, run_result, check_result):
+ report_list = []
for test_name in self.__tests_list:
+ report = {
+ 'name': test_name,
+ 'result': 'FAIL',
+ 'error_description': 'Unknown error',
+ }
+
ret = run_result.get(test_name)
if ret is None:
- Info.test_fail('WAS_NOT_STARTED', test_name)
- continue
+ report['error_description'] = 'Test app was not run'
elif ret != 0:
- Info.test_fail('RUN_FAIL_%d' % ret, test_name)
- continue
+ report['error_description'] = 'Test app finished with error: %d' % ret
+ else:
+ result = check_result[test_name]
+ for check_name, ret in result.iteritems():
+ if ret == auxiliary.CheckerAUX.PASS:
+ report['result'] = 'PASS'
+
+ report['error_description'] = \
+ auxiliary.CheckerAUX.description_by_retcode(ret)
+
+ report_list.append(report)
- result = check_result[test_name]
- for check_name, ret in result.iteritems():
- ret_str = auxiliary.CheckerAUX.code_to_string(ret)
- if ret is auxiliary.CheckerAUX.PASS:
- Info.test_pass(ret_str, check_name)
- else:
- Info.test_fail(ret_str, check_name)
+ # show tests result
+ Info.head('##### Tests results #####')
+ for report in report_list:
+ if report['result'] == 'PASS':
+ Info.test_pass(report['result'], report['name'])
+ else:
+ Info.test_fail(report['result'], report['name'])
+
+ return {
+ 'tests_list': report_list
+ }
def run(self):
Info.head('Autotest START')
# check tests
check_test_result = self.__check_all_tests(run_test_result)
- # show tests result
- self.__show_tests_result(run_test_result, check_test_result)
+ # make tests report
+ tests_report = self.__make_tests_report(run_test_result, check_test_result)
+
+ # save tests report
+ with open(self.__host_config.report(), 'w') as file_obj:
+ json.dump(tests_report, file_obj, indent=2)
def main(argv):