diff --git a/src/xdevice/_core/driver/drivers_lite.py b/src/xdevice/_core/driver/drivers_lite.py index 9908fa123fc66defc1cd349a5592e1dcf8df968a..cd49d30dc997a10e4f4fa796783b7299990dfcbb 100755 --- a/src/xdevice/_core/driver/drivers_lite.py +++ b/src/xdevice/_core/driver/drivers_lite.py @@ -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 "" diff --git a/src/xdevice/_core/environment/device_lite.py b/src/xdevice/_core/environment/device_lite.py index 0ddc5766dcd4ecb0c1140157190a655cbc3d48f3..1c48f349e96e94678e0cae2973fbc03c923e283a 100755 --- a/src/xdevice/_core/environment/device_lite.py +++ b/src/xdevice/_core/environment/device_lite.py @@ -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)