diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-03-04 14:18:12 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-03-04 14:18:12 +0300 |
commit | 334dcbe6ee68b8a12e4914f6f1ac6f0332a2752a (patch) | |
tree | f7680cb5b5ce23fb271e5d4db72d2e5efa23cd05 /library/python/testing | |
parent | dde32cec87a38e03e73ba702f1e424a234eb68cd (diff) | |
download | ydb-334dcbe6ee68b8a12e4914f6f1ac6f0332a2752a.tar.gz |
intermediate changes
ref:2a778101b5c1b72fe97b6485437fc7bbd1713dce
Diffstat (limited to 'library/python/testing')
-rw-r--r-- | library/python/testing/yatest_common/yatest/common/process.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/library/python/testing/yatest_common/yatest/common/process.py b/library/python/testing/yatest_common/yatest/common/process.py index a8bcc21f518..bed0db1e1dc 100644 --- a/library/python/testing/yatest_common/yatest/common/process.py +++ b/library/python/testing/yatest_common/yatest/common/process.py @@ -5,6 +5,7 @@ import re import time import signal import shutil +import inspect import logging import tempfile import subprocess @@ -91,7 +92,11 @@ class InvalidCommandError(Exception): class _Execution(object): - def __init__(self, command, process, out_file, err_file, process_progress_listener=None, cwd=None, collect_cores=True, check_sanitizer=True, started=0, user_stdout=False, user_stderr=False): + def __init__(self, command, process, out_file, err_file, + process_progress_listener=None, cwd=None, collect_cores=True, + check_sanitizer=True, started=0, user_stdout=False, user_stderr=False, + core_pattern=None): + self._command = command self._process = process self._out_file = out_file @@ -110,6 +115,8 @@ class _Execution(object): self._user_stdout = bool(user_stdout) self._user_stderr = bool(user_stderr) self._exit_code = None + self._core_pattern = core_pattern + if process_progress_listener: process_progress_listener.open(command, process, out_file, err_file) @@ -146,6 +153,10 @@ class _Execution(object): return self._command @property + def core_pattern(self): + return self._core_pattern + + @property def returncode(self): return self.exit_code @@ -253,7 +264,11 @@ class _Execution(object): self._out_file = None def _recover_core(self): - core_path = cores.recover_core_dump_file(self.command[0], self._cwd, self.process.pid) + core_path = cores.recover_core_dump_file( + self.command[0], + self._cwd, + self.process.pid, + self.core_pattern) 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 @@ -422,6 +437,7 @@ def execute( process_progress_listener=None, close_fds=False, collect_cores=True, check_sanitizer=True, preexec_fn=None, on_timeout=None, executor=_Execution, + core_pattern=None, ): """ Executes a command @@ -527,7 +543,16 @@ def execute( ) yatest_logger.debug("Command pid: %s", process.pid) - res = executor(command, process, out_file, err_file, process_progress_listener, cwd, collect_cores, check_sanitizer, started, user_stdout=user_stdout, user_stderr=user_stderr) + kwargs = { + 'user_stdout': user_stdout, + 'user_stderr': user_stderr, + } + + if 'core_pattern' in inspect.getargspec(executor.__init__).args: + kwargs.update([('core_pattern', core_pattern)]) + + res = executor(command, process, out_file, err_file, process_progress_listener, + cwd, collect_cores, check_sanitizer, started, **kwargs) if wait: res.wait(check_exit_code, timeout, on_timeout) return res |