def _recover_core(self): core_path = cores.recover_core_dump_file(self.command[0], self._cwd, self.process.pid) if core_path: # Core dump file recovering may be disabled (for distbuild for example) - produce only bt store_cores = runtime._get_ya_config().collect_cores if store_cores: new_core_path = path.get_unique_file_path(runtime.output_path(), "{}.{}.core".format(os.path.basename(self.command[0]), self._process.pid)) # Copy core dump file, because it may be overwritten yatest_logger.debug("Coping core dump file from '%s' to the '%s'", core_path, new_core_path) shutil.copyfile(core_path, new_core_path) core_path = new_core_path bt_filename = None pbt_filename = None if os.path.exists(runtime.gdb_path()): self._backtrace = cores.get_gdb_full_backtrace(self.command[0], core_path, runtime.gdb_path()) bt_filename = path.get_unique_file_path(runtime.output_path(), "{}.{}.backtrace".format(os.path.basename(self.command[0]), self._process.pid)) with open(bt_filename, "w") as afile: afile.write(self._backtrace) # generate pretty html version of backtrace aka Tri Korochki pbt_filename = bt_filename + ".html" cores.backtrace_to_html(bt_filename, pbt_filename) if store_cores: runtime._register_core(os.path.basename(self.command[0]), self.command[0], core_path, bt_filename, pbt_filename) else: runtime._register_core(os.path.basename(self.command[0]), None, None, bt_filename, pbt_filename)
def _canonical_execute(excutor, kwargs, file_name, save_locally, diff_tool, diff_file_name): res = excutor(**kwargs) command = kwargs["command"] file_name = file_name or process.get_command_name(command) if file_name.endswith(".exe"): file_name = os.path.splitext(file_name)[ 0] # don't want to bring windows stuff in file names out_file_path = path.get_unique_file_path(runtime.output_path(), "{}.out.txt".format(file_name)) err_file_path = path.get_unique_file_path(runtime.output_path(), "{}.err.txt".format(file_name)) try: os.makedirs(os.path.dirname(out_file_path)) except OSError: pass with open(out_file_path, "w") as out_file: yatest_logger.debug("Will store file in %s", out_file_path) out_file.write(res.std_out) if res.std_err: with open(err_file_path, "w") as err_file: err_file.write(res.std_err) return canonical_file(out_file_path, local=save_locally, diff_tool=diff_tool, diff_file_name=diff_file_name)
def _canonical_execute(excutor, kwargs, file_name, save_locally, diff_tool, diff_file_name): res = excutor(**kwargs) command = kwargs["command"] file_name = file_name or process.get_command_name(command) if file_name.endswith(".exe"): file_name = os.path.splitext(file_name)[0] # don't want to bring windows stuff in file names out_file_path = path.get_unique_file_path(runtime.output_path(), "{}.out.txt".format(file_name)) err_file_path = path.get_unique_file_path(runtime.output_path(), "{}.err.txt".format(file_name)) try: os.makedirs(os.path.dirname(out_file_path)) except OSError: pass with open(out_file_path, "w") as out_file: yatest_logger.debug("Will store file in %s", out_file_path) out_file.write(res.std_out) if res.std_err: with open(err_file_path, "w") as err_file: err_file.write(res.std_err) return canonical_file(out_file_path, local=save_locally, diff_tool=diff_tool, diff_file_name=diff_file_name)