aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/py/lib
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-07-18 01:33:39 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-07-18 02:10:52 +0200
commit7ddd364a83b7a8f3ab6720f805df6b62aee6ea88 (patch)
treeb8cda93951e7e544b341e9bd96a3426e0ebfc138 /test/py/lib
parentjson_rpc: removed unused routines (diff)
downloadcimple-7ddd364a83b7a8f3ab6720f805df6b62aee6ea88.tar.gz
cimple-7ddd364a83b7a8f3ab6720f805df6b62aee6ea88.zip
process: preserve the exit code more
If the process is killed by a signal, preserve the exit code as it would be reported by $?.
Diffstat (limited to 'test/py/lib')
-rw-r--r--test/py/lib/test_repo.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/test/py/lib/test_repo.py b/test/py/lib/test_repo.py
index aca6dfa..e3e875b 100644
--- a/test/py/lib/test_repo.py
+++ b/test/py/lib/test_repo.py
@@ -40,7 +40,7 @@ class TestRepo(Repo):
# Prevent Pytest from discovering test cases in this class:
__test__ = False
- def __init__(self, path, ci_script='ci.sh'):
+ def __init__(self, path, ci_script='ci'):
super().__init__(path)
self.runs_dir = os.path.join(self.path, 'runs')
@@ -78,9 +78,12 @@ class TestRepo(Repo):
runs_dir = shlex.quote(self.runs_dir)
return CI_SCRIPT.format(runs_dir=runs_dir)
- def count_run_files(self):
+ def _count_run_files(self):
return len([name for name in os.listdir(self.runs_dir) if os.path.isfile(os.path.join(self.runs_dir, name))])
+ def run_files_are_present(self, expected):
+ assert expected == self._count_run_files()
+
class TestRepoOutput(TestRepo, abc.ABC):
__test__ = False
@@ -223,24 +226,22 @@ class TestRepoSegfault(TestRepo):
def __init__(self, repo_path, prog_path):
self.prog_path = prog_path
- self.prog_name = os.path.basename(prog_path)
super().__init__(repo_path)
- shutil.copy(prog_path, self.path)
- self.run('git', 'add', '--', self.prog_name)
- self.run('git', 'commit', '-q', '-m', 'add test program')
-
@staticmethod
def codename():
return 'segfault'
- def format_ci_script(self):
- script = super().format_ci_script()
- added = r'exec {prog}'.format(prog=shlex.quote(f'./{self.prog_name}'))
- return f'{script}\n{added}\n'
+ def write_ci_script(self):
+ shutil.copy(self.prog_path, self.ci_script_path)
def run_exit_code_matches(self, ec):
- return ec < 0
+ # If WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV, then the $?
+ # would be 139.
+ return ec == 139
def run_output_matches(self, output):
return "Started the test program.\n" == output.decode()
+
+ def run_files_are_present(self, *args):
+ return True