summaryrefslogtreecommitdiff
path: root/test/test_general.py
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2026-07-14 17:29:02 +0200
committerPaul Oliver <contact@pauloliver.dev>2026-08-30 16:24:48 +0200
commit1961b4b237083f4cfac9ca6b249c1d6cb665d149 (patch)
treefd9fc8260360e2ac30be9747ca558bcfc824a4c4 /test/test_general.py
Initial (refactor)HEADmaster
Diffstat (limited to 'test/test_general.py')
-rw-r--r--test/test_general.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/test_general.py b/test/test_general.py
new file mode 100644
index 0000000..2286b4f
--- /dev/null
+++ b/test/test_general.py
@@ -0,0 +1,58 @@
+# file : test/test_general.py
+# project : Salis-VM
+# author : Paul Oliver <contact@pauloliver.dev>
+
+# index:
+# [section] setup/teardown
+# [section] file lists
+# [section] assertions
+# [section] subprocess
+
+import os
+import subprocess
+import unittest
+
+from tempfile import TemporaryDirectory
+
+class SalisTest(unittest.TestCase):
+ # --------------------------------------------------------------------------
+ # [section] setup/teardown
+ # --------------------------------------------------------------------------
+ def setUp(self):
+ self.tempdir = TemporaryDirectory(prefix="salis_test_")
+
+ def tearDown(self):
+ self.tempdir.cleanup()
+
+ # --------------------------------------------------------------------------
+ # [section] file lists
+ # --------------------------------------------------------------------------
+ def files_on_new(self, name):
+ return [
+ f"{self.tempdir.name}/{name}/evas/evas-{0:016x}",
+ f"{self.tempdir.name}/{name}/opts.json",
+ f"{self.tempdir.name}/{name}/{name}",
+ f"{self.tempdir.name}/{name}/{name}-{0:016x}",
+ f"{self.tempdir.name}/{name}/{name}.sqlite3",
+ ]
+
+ # --------------------------------------------------------------------------
+ # [section] assertions
+ # --------------------------------------------------------------------------
+ def assert_files_exist(self, files):
+ for file in files:
+ assert os.path.isfile(file), f"{file} does not exist"
+
+ # --------------------------------------------------------------------------
+ # [section] subprocess
+ # --------------------------------------------------------------------------
+ def run_subprocess(self, command):
+ subprocess.run(command.split(), check=True, stdout=subprocess.DEVNULL)
+
+ def run_pipe(self, command):
+ return subprocess.Popen(command.split(), stdout=subprocess.PIPE, text=True)
+
+ def run_ui_test(self, anc, anc_path, ui, ui_path, vm_arch, clones=1, cores=1, mvec_pow=20, name="def.sim", seed=0, data_push_pow=28, sync_pow=20, auto_save_pow=36, **kwargs):
+ command = f"./salis.py new -a{anc} -A{anc_path} -C{clones} -c{cores} -d{data_push_pow} -f -H{self.tempdir.name} -m{mvec_pow} -n{name} -s{seed} -u{ui} -U{ui_path} -v{vm_arch} -y{sync_pow} -z{auto_save_pow}"
+ self.run_subprocess(command)
+ self.assert_files_exist(self.files_on_new(name))