!14 修复因没及时删除xml测试报告导致测试套重跑并发生crash的问题

Merge pull request !14 from liukunmo/master
This commit is contained in:
openharmony_ci 2021-04-27 19:43:34 +08:00 committed by Gitee
commit a4f7aee37b
2 changed files with 27 additions and 12 deletions

View File

@ -58,6 +58,8 @@ from _core.report.suite_reporter import SuiteReporter
__all__ = ["CppTestDriver", "CTestDriver", "init_remote_server"]
LOG = platform_logger("DriversLite")
FAILED_RUN_TEST_ATTEMPTS = 2
CPP_TEST_MOUNT_STOP_SIGN = "not mount properly, Test Stop"
CPP_TEST_NFS_SIGN = "execve: I/O error"
def get_nfs_server(request):
@ -266,11 +268,12 @@ class CppTestDriver(IDriver):
command=collect_test_command,
case_type=DeviceTestType.cpp_test_lite,
timeout=15, receiver=None)
if "not mount properly, Test Stop" in result:
if CPP_TEST_MOUNT_STOP_SIGN in result:
tests = []
return tests
tests = self.read_nfs_xml(request, self.config.device_xml_path)
self.delete_device_xml(request, self.config.device_xml_path)
time.sleep(1)
return tests
else:
@ -375,8 +378,13 @@ class CppTestDriver(IDriver):
if self.config.xml_output:
self.run("{} --gtest_output=xml:{}".format(
command, self.config.device_report_path))
time.sleep(5)
test_run = self.read_nfs_xml(request, self.config.device_xml_path)
time.sleep(20)
test_rerun = True
if self.check_xml_exist(self.execute_bin + ".xml"):
test_rerun = False
test_run = self.read_nfs_xml(request, self.config.device_xml_path,
test_rerun)
if len(test_run) < len(expected_tests):
expected_tests = TestDescription.remove_test(expected_tests,
test_run)
@ -483,7 +491,7 @@ class CppTestDriver(IDriver):
time.sleep(5)
return False
def read_nfs_xml(self, request, report_path):
def read_nfs_xml(self, request, report_path, is_true=False):
remote_nfs = get_nfs_server(request)
if not remote_nfs:
err_msg = "The name of remote device {} does not match". \
@ -491,9 +499,10 @@ class CppTestDriver(IDriver):
LOG.error(err_msg, error_no="00403")
raise TypeError(err_msg)
tests = []
file_path = os.path.join(report_path,
self.execute_bin + ".xml")
if not self.check_xml_exist(self.execute_bin + ".xml"):
execute_bin_xml = (self.execute_bin + "_1.xml") if is_true else (
self.execute_bin + ".xml")
file_path = os.path.join(report_path, execute_bin_xml)
if not self.check_xml_exist(execute_bin_xml):
return tests
from xml.etree import ElementTree
@ -575,7 +584,11 @@ class CppTestDriver(IDriver):
client.close()
else:
for report_xml in glob.glob(os.path.join(report_path, '*.xml')):
os.remove(report_xml)
try:
os.remove(report_xml)
except Exception as exception:
LOG.error(
"remove {} Failed.{}".format(report_xml, exception))
def __result__(self):
return self.result if os.path.exists(self.result) else ""

View File

@ -354,9 +354,11 @@ class DeviceLite(IDevice):
timeout=timeout,
receiver=receiver)
if not receiver:
LOG.debug("execute result:%s", filter_result)
if not status:
LOG.debug("error_message:%s", error_message)
LOG.debug("%s execute result:%s" % (
convert_serial(self.__get_serial__()), filter_result))
if not status:
LOG.debug("%s error_message:%s" % (
convert_serial(self.__get_serial__()), error_message))
return filter_result, status, error_message
def recover_device(self):
@ -368,7 +370,7 @@ class DeviceLite(IDevice):
execute_command_with_timeout(command="reset", timeout=30)
if not filter_result:
if check_mode(ModeType.decc):
LOG.debug("set device %s recover state to false" %
LOG.debug("Set device %s recover state to false" %
self.device_sn)
self.device_allocation_state = DeviceAllocationState.unusable
self.set_recover_state(False)