From 673da14a9ff50307ebedb7a42af80b37ce4d55f3 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 11 Sep 2026 14:10:56 +0000 Subject: [PATCH] test suite: add autosign_data_dir --- test/clean.py | 3 ++- test/cmdtest.py | 13 +++++++------ test/cmdtest_d/autosign.py | 3 +++ test/cmdtest_d/include/runner.py | 3 ++- test/cmdtest_d/swap.py | 2 +- test/include/common.py | 1 + 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/test/clean.py b/test/clean.py index 7b60de9e..85577c8d 100755 --- a/test/clean.py +++ b/test/clean.py @@ -43,12 +43,13 @@ if os.path.exists(overlay_tree_dir): rmtree(overlay_tree_dir, ignore_errors=True) print(f'Removed {os.path.relpath(overlay_tree_dir)!r}') -from test.include.common import clean, set_globals, trash_dir, trash_dir2 +from test.include.common import clean, set_globals, autosign_data_dir, trash_dir, trash_dir2 set_globals(cfg) extra_dirs = [ Config.test_datadir, + autosign_data_dir, trash_dir, trash_dir2] diff --git a/test/cmdtest.py b/test/cmdtest.py index f394906c..82404515 100755 --- a/test/cmdtest.py +++ b/test/cmdtest.py @@ -25,13 +25,13 @@ def check_segwit_opts(proto): if getattr(cfg, k) and m not in proto.mmtypes: die(1, f'--{k.replace("_", "-")} option incompatible with {proto.cls_name}') -def create_shm_dir(data_dir, trash_dir, trash_dir2): +def create_shm_dir(data_dir, autosign_data_dir, trash_dir, trash_dir2): # Laggy flash media can cause pexpect to fail, so create a temporary directory # under '/dev/shm' and put datadir and tmpdirs here. import shutil from subprocess import run if gc.platform in ('win32', 'darwin'): - for tdir in (data_dir, trash_dir, trash_dir2): + for tdir in (data_dir, autosign_data_dir, trash_dir, trash_dir2): try: os.listdir(tdir) except: @@ -61,7 +61,7 @@ def create_shm_dir(data_dir, trash_dir, trash_dir2): except Exception as e: die(2, f'Unable to create temporary directory in {tdir} ({e.args[0]})') - for tdir in (trash_dir, trash_dir2): + for tdir in (autosign_data_dir, trash_dir, trash_dir2): dest = os.path.join(shm_dir, os.path.basename(tdir)) os.mkdir(dest, 0o755) @@ -91,6 +91,7 @@ from test.include.common import ( cmdtest_py_log_fn, cmdtest_py_error_fn, mk_tmpdir, + autosign_data_dir, trash_dir, trash_dir2, stop_test_daemons) @@ -182,7 +183,7 @@ data_dir = Config.test_datadir # step 1: delete data_dir symlink in ./test; if not po.user_opts.get('skip_deps'): - for fn in (data_dir,): + for fn in (data_dir, autosign_data_dir): try: os.unlink(fn) except: @@ -217,7 +218,7 @@ if cfg.daemon_id and cfg.daemon_id in cfg.blacklisted_daemons.split(): # step 3: move data_dir to /dev/shm and symlink it back to ./test: if not cfg.skipping_deps: - shm_dir = create_shm_dir(data_dir, trash_dir, trash_dir2) + shm_dir = create_shm_dir(data_dir, autosign_data_dir, trash_dir, trash_dir2) check_segwit_opts(cfg._proto) @@ -289,7 +290,7 @@ if __name__ == '__main__': from test.cmdtest_d.include.runner import CmdTestRunner try: - tr = CmdTestRunner(cfg, repo_root, data_dir, trash_dir, trash_dir2) + tr = CmdTestRunner(cfg, repo_root, data_dir, autosign_data_dir, trash_dir, trash_dir2) tr.run_tests(cmd_args) tr.print_warnings() if tr.daemon_started and not cfg.no_daemon_stop: diff --git a/test/cmdtest_d/autosign.py b/test/cmdtest_d/autosign.py index 755c7070..1bde1508 100755 --- a/test/cmdtest_d/autosign.py +++ b/test/cmdtest_d/autosign.py @@ -38,6 +38,7 @@ from ..include.common import ( oqmsg_r, start_test_daemons, stop_test_daemons, + autosign_data_dir, joinpath, imsg, read_from_file, @@ -619,6 +620,8 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase): 'mmgen-autosign', (opts or self.opts) + add_opts + # ensure that changes to online cfg file don’t affect autosign: + + [f'--data-dir={autosign_data_dir}'] + ['--full-summary', 'wait'], direct_exec = True, no_passthru_opts = True, diff --git a/test/cmdtest_d/include/runner.py b/test/cmdtest_d/include/runner.py index 75a117a0..05b0c81a 100755 --- a/test/cmdtest_d/include/runner.py +++ b/test/cmdtest_d/include/runner.py @@ -48,11 +48,12 @@ class CmdTestRunner: if self.logging: self.log_fd.close() - def __init__(self, cfg, repo_root, data_dir, trash_dir, trash_dir2): + def __init__(self, cfg, repo_root, data_dir, autosign_data_dir, trash_dir, trash_dir2): self.cfg = cfg self.proto = cfg._proto self.data_dir = data_dir + self.autosign_data_dir = autosign_data_dir self.trash_dir = trash_dir self.trash_dir2 = trash_dir2 self.cmd_total = 0 diff --git a/test/cmdtest_d/swap.py b/test/cmdtest_d/swap.py index 1d0d3852..1b243c4a 100755 --- a/test/cmdtest_d/swap.py +++ b/test/cmdtest_d/swap.py @@ -266,7 +266,7 @@ class CmdTestSwapMethods: 'exit_after': None, 'log': None} | add_cfg) t = trunner - ret = CmdTestRunner(cfg, t.repo_root, t.data_dir, t.trash_dir, t.trash_dir2) + ret = CmdTestRunner(cfg, t.repo_root, t.data_dir, t.autosign_data_dir, t.trash_dir, t.trash_dir2) ret.init_group(self.cross_group) ret.parent_group = self return ret diff --git a/test/include/common.py b/test/include/common.py index 26c657c9..20ca48a0 100755 --- a/test/include/common.py +++ b/test/include/common.py @@ -60,6 +60,7 @@ def set_globals(cfg): def strip_ansi_escapes(s): return re.sub('\x1b' + r'\[[;0-9]+?m', '', s) +autosign_data_dir = os.path.join('test', 'tmp', 'autosign_data_dir') trash_dir = os.path.join('test', 'tmp', 'trash') trash_dir2 = os.path.join('test', 'tmp', 'trash2')