diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index 1a859723f0c52f09d32d5f2c28a54e5a1e7594cd..a51ef7e613d648e0a874ffaf3a6ff6b23ec8a7f8 100755 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -467,17 +467,16 @@ class CppTestDriver(IDriver): "No test device is found. ") return - serial = request.config.device.__get_serial__() - device_log_file = get_device_log_file( - request.config.report_path, - serial) + self.config.device.set_device_report_path(request.config.report_path) + self.config.device.device_log_collector.start_hilog_task() + self._init_gtest() + self._run_gtest(suite_file) - with open(device_log_file, "a", encoding="UTF-8") as file_pipe: - self.config.device.start_catch_device_log(hilog_file_pipe=file_pipe) - self._init_gtest() - self._run_gtest(suite_file) finally: - self.config.device.stop_catch_device_log() + serial = "{}_{}".format(str(request.config.device.__get_serial__()), time.time_ns()) + log_tar_file_name = "{}_{}".format(request.get_module_name(), str(serial).replace( + ":", "_")) + self.config.device.device_log_collector.stop_hilog_task(log_tar_file_name) def _init_gtest(self): self.config.device.connector_command("target mount") @@ -631,6 +630,8 @@ class JSUnitTestDriver(IDriver): self.start_time = None self.ability_name = "" self.package_name = "" + self.hilog = None + self.hilog_proc = None def __check_environment__(self, device_options): pass @@ -672,23 +673,27 @@ class JSUnitTestDriver(IDriver): "/data/data/%s/files/" % self.package_name self.config.device.connector_command("shell hilog -r") - hilog = get_device_log_file( + self.hilog = get_device_log_file( request.config.report_path, request.config.device.__get_serial__() + "_" + request. get_module_name(), "device_hilog") - hilog_open = os.open(hilog, os.O_WRONLY | os.O_CREAT | os.O_APPEND, + hilog_open = os.open(self.hilog, os.O_WRONLY | os.O_CREAT | os.O_APPEND, 0o755) with os.fdopen(hilog_open, "a") as hilog_file_pipe: - self.config.device.start_catch_device_log(hilog_file_pipe=hilog_file_pipe) + self.config.device.device_log_collector.add_log_address(None, self.hilog) + _, self.hilog_proc = self.config.device.device_log_collector. \ + start_catch_device_log(hilog_file_pipe=hilog_file_pipe) self._init_jsunit_test() - self._run_jsunit(suite_file, hilog) + self._run_jsunit(suite_file, self.hilog) hilog_file_pipe.flush() - self.generate_console_output(hilog, request) + self.generate_console_output(self.hilog, request) + finally: - self.config.device.stop_catch_device_log() + self.config.device.device_log_collector.remove_log_address(None, self.hilog) + self.config.device.device_log_collector.stop_catch_device_log(self.hilog_proc) def _init_jsunit_test(self): self.config.device.connector_command("target mount")