aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2026-07-07 05:57:49 +0200
committerPaul Oliver <contact@pauloliver.dev>2026-07-07 05:57:49 +0200
commit55928b51596de4cd1b7a2783529ecda3ff3087ce (patch)
treed00172e0e7dc1d5bb593c55e5d51acb1634a4855
parentb54b9ceb2952ba84b58e75aba014558b17d08e77 (diff)
Adds run tests and file checks
-rw-r--r--core/salis.c4
-rw-r--r--core/server.c2
-rwxr-xr-xsalis.py10
-rw-r--r--test/test_build.py22
-rw-r--r--test/test_general.py15
-rw-r--r--test/test_run.py50
-rw-r--r--test/ui/push/ui.c11
-rw-r--r--test/ui/push/vars.py3
-rw-r--r--test/ui/v1/1rops/ui.c1
-rw-r--r--test/ui/v1/2rops/ui.c1
-rw-r--r--test/ui/v1/3rops/ui.c1
-rw-r--r--test/ui/v1/addrs/ui.c1
-rw-r--r--test/ui/v1/allos/ui.c1
-rw-r--r--test/ui/v1/ifnzs/ui.c1
-rw-r--r--test/ui/v1/ioops/ui.c1
-rw-r--r--test/ui/v1/jumps/ui.c1
-rw-r--r--test/ui/v1/mbops/ui.c1
-rw-r--r--test/ui/v1/noops/ui.c2
-rw-r--r--test/ui/v1/stack/ui.c1
19 files changed, 118 insertions, 11 deletions
diff --git a/core/salis.c b/core/salis.c
index 11c6efb..b7c904b 100644
--- a/core/salis.c
+++ b/core/salis.c
@@ -708,7 +708,7 @@ void salis_auto_save(void) {
#endif
g_asav_pbuf,
AUTOSAVE_NAME_LEN,
- "%s-%#018lx",
+ "%s-%016lx",
SIM_PATH,
g_steps
);
@@ -804,7 +804,7 @@ void salis_push_data_line(void) {
int rem = snprintf(
g_eva_pbuf,
EVA_SAVE_NAME_LEN,
- "%s/evas-%#018lx",
+ "%s/evas-%016lx",
SIM_EDIR,
g_steps
);
diff --git a/core/server.c b/core/server.c
index 6848cf6..aceaee4 100644
--- a/core/server.c
+++ b/core/server.c
@@ -166,7 +166,7 @@ void sql_callback_add_data(sqlite3_stmt *sql_stmt, void *data) {
int rem = snprintf(
g_eva_pbuf,
EVA_SAVE_NAME_LEN,
- "%s/evas-%#018lx",
+ "%s/evas-%016lx",
SIM_EDIR,
col_value
);
diff --git a/salis.py b/salis.py
index dabc2a3..de4f75d 100755
--- a/salis.py
+++ b/salis.py
@@ -419,8 +419,8 @@ if args.command == "new":
pop_sim_path_vars()
pop_general()
- ns.b.defines.add(f"-DAUTOSAVE_NAME_LEN={len(ns.sim_path) + 20}")
- ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_edir) + 25}")
+ ns.b.defines.add(f"-DAUTOSAVE_NAME_LEN={len(ns.sim_path) + 18}")
+ ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_edir) + 23}")
ns.b.defines.add(f"-DTHREAD_GAP={args.thread_gap}")
# Populate for load
@@ -431,8 +431,8 @@ if args.command == "load":
pop_sim_path_vars()
pop_general()
- ns.b.defines.add(f"-DAUTOSAVE_NAME_LEN={len(ns.sim_path) + 20}")
- ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_edir) + 25}")
+ ns.b.defines.add(f"-DAUTOSAVE_NAME_LEN={len(ns.sim_path) + 18}")
+ ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_edir) + 23}")
ns.b.defines.add(f"-DTHREAD_GAP={args.thread_gap}")
# Populate for server
@@ -443,7 +443,7 @@ if args.command == "server":
pop_net_vars()
pop_general()
- ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_edir) + 25}")
+ ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_edir) + 23}")
# Populate for client
if args.command == "client":
diff --git a/test/test_build.py b/test/test_build.py
index a57c09d..ec23390 100644
--- a/test/test_build.py
+++ b/test/test_build.py
@@ -1,11 +1,14 @@
+import os
import signal
from test_general import SalisTest
class TestBuild(SalisTest):
+ NAME = "test-build.sim"
+
def cmds_new(self, anc, arch):
return (
- f"./salis.py new -a{anc} -b -f -g{compiler} -H{self.tempdir.name} {optimized} -s{seed} -u{ui} -v{arch}"
+ f"./salis.py new -a{anc} -b -f -g{compiler} -H{self.tempdir.name} -n{TestBuild.NAME} {optimized} -s{seed} -u{ui} -v{arch}"
for compiler in ["clang", "gcc"]
for optimized in ["", "-o"]
for seed in [-1, 0, 1234]
@@ -20,7 +23,7 @@ class TestBuild(SalisTest):
def cmds_load(self):
return (
- f"./salis.py load -b -g{compiler} -H{self.tempdir.name} {optimized} -u{ui}"
+ f"./salis.py load -b -g{compiler} -H{self.tempdir.name} -n{TestBuild.NAME} {optimized} -u{ui}"
for compiler in ["clang", "gcc"]
for optimized in ["", "-o"]
for ui in ["curses", "daemon"]
@@ -28,7 +31,7 @@ class TestBuild(SalisTest):
def cmds_server(self):
return (
- f"./salis.py server -b -g{compiler} -H{self.tempdir.name} {optimized}"
+ f"./salis.py server -b -g{compiler} -H{self.tempdir.name} -n{TestBuild.NAME} {optimized}"
for compiler in ["clang", "gcc"]
for optimized in ["", "-o"]
)
@@ -41,31 +44,44 @@ class TestBuild(SalisTest):
for optimized in ["", "-o"]
)
+ def file_list(self):
+ return [
+ os.path.join(self.tempdir.name, TestBuild.NAME, "opts.json"),
+ ]
+
def test_null_new(self):
for cmd in self.cmds_new_null():
SalisTest.run_subprocess(cmd)
+ self.assert_file_list_exists(self.file_list())
def test_v1_new(self):
for cmd in self.cmds_new_v1():
SalisTest.run_subprocess(cmd)
+ self.assert_file_list_exists(self.file_list())
def test_null_load(self):
SalisTest.run_subprocess(next(self.cmds_new_null()))
+ self.assert_file_list_exists(self.file_list())
for cmd in self.cmds_load():
SalisTest.run_subprocess(cmd)
+ self.assert_file_list_exists(self.file_list())
def test_v1_load(self):
SalisTest.run_subprocess(next(self.cmds_new_v1()))
+ self.assert_file_list_exists(self.file_list())
for cmd in self.cmds_load():
SalisTest.run_subprocess(cmd)
+ self.assert_file_list_exists(self.file_list())
def test_server(self):
SalisTest.run_subprocess(next(self.cmds_new_null()))
+ self.assert_file_list_exists(self.file_list())
for cmd in self.cmds_server():
SalisTest.run_subprocess(cmd)
+ self.assert_file_list_exists(self.file_list())
@SalisTest.run_ui_test(anc="0123", anc_path="anc", name="def.sim", ui="null", ui_path="test/ui", vm_arch="null")
def test_client(self):
diff --git a/test/test_general.py b/test/test_general.py
index eb3185d..43f3635 100644
--- a/test/test_general.py
+++ b/test/test_general.py
@@ -1,3 +1,4 @@
+import os
import subprocess
import unittest
@@ -10,6 +11,19 @@ class SalisTest(unittest.TestCase):
def tearDown(self):
self.tempdir.cleanup()
+ def file_list_new(self, name):
+ return [
+ os.path.join(self.tempdir.name, name, name),
+ os.path.join(self.tempdir.name, name, f"{name}.sqlite3"),
+ os.path.join(self.tempdir.name, name, f"{name}-{0:016x}"),
+ os.path.join(self.tempdir.name, name, "opts.json"),
+ os.path.join(self.tempdir.name, name, "evas", f"evas-{0:016x}"),
+ ]
+
+ def assert_file_list_exists(self, files):
+ for file in files:
+ assert os.path.isfile(file), f"{file} does not exist"
+
@staticmethod
def run_subprocess(cmd):
subprocess.run(cmd.split(), check=True, stdout=subprocess.DEVNULL)
@@ -24,6 +38,7 @@ class SalisTest(unittest.TestCase):
def test_wrapper(self):
cmd = f"./salis.py new -a{anc} -A{anc_path} -C{clones} -c{cores} -H{self.tempdir.name} -n{name} -u{ui} -U{ui_path} -v{vm_arch}"
subprocess.run(cmd.split(), check=True, stdout=subprocess.DEVNULL)
+ self.assert_file_list_exists(self.file_list_new(name))
test_case(self)
return test_wrapper
diff --git a/test/test_run.py b/test/test_run.py
new file mode 100644
index 0000000..17bdca8
--- /dev/null
+++ b/test/test_run.py
@@ -0,0 +1,50 @@
+import os
+
+from test_general import SalisTest
+
+class TestRun(SalisTest):
+ NAME = "test-run.sim"
+ PUSH_POW = 8
+
+ def cmds(self, anc, arch):
+ return (
+ (
+ f"./salis.py new -a{anc} -d{TestRun.PUSH_POW} -f -g{compiler} -H{self.tempdir.name} -n{TestRun.NAME} {optimized} -s{seed} -upush -Utest/ui/ -v{arch} -y{TestRun.PUSH_POW}",
+ f"./salis.py load -g{compiler} -H{self.tempdir.name} -n{TestRun.NAME} {optimized} -upush -Utest/ui/",
+ )
+ for compiler in ["clang", "gcc"]
+ for optimized in ["", "-o"]
+ for seed in [-1, 0, 1234]
+ )
+
+ def cmds_null(self):
+ return self.cmds("0123", "null")
+
+ def cmds_v1(self):
+ return self.cmds("55a", "v1")
+
+ def file_list_0(self):
+ return [
+ *self.file_list_new(TestRun.NAME),
+ os.path.join(self.tempdir.name, TestRun.NAME, "evas", f"evas-{2 ** TestRun.PUSH_POW:016x}"),
+ ]
+
+ def file_list_1(self):
+ return [
+ *self.file_list_0(),
+ os.path.join(self.tempdir.name, TestRun.NAME, "evas", f"evas-{2 * (2 ** TestRun.PUSH_POW):016x}"),
+ ]
+
+ def test_null(self):
+ for cmd in self.cmds_null():
+ SalisTest.run_subprocess(cmd[0])
+ self.assert_file_list_exists(self.file_list_0())
+ SalisTest.run_subprocess(cmd[1])
+ self.assert_file_list_exists(self.file_list_1())
+
+ def test_v1(self):
+ for cmd in self.cmds_v1():
+ SalisTest.run_subprocess(cmd[0])
+ self.assert_file_list_exists(self.file_list_0())
+ SalisTest.run_subprocess(cmd[1])
+ self.assert_file_list_exists(self.file_list_1())
diff --git a/test/ui/push/ui.c b/test/ui/push/ui.c
new file mode 100644
index 0000000..e345658
--- /dev/null
+++ b/test/ui/push/ui.c
@@ -0,0 +1,11 @@
+int main(void) {
+#if defined(COMMAND_NEW)
+ salis_init();
+#elif defined(COMMAND_LOAD)
+ salis_load();
+#endif
+ salis_step(DATA_PUSH_INTERVAL);
+ salis_save(SIM_PATH);
+ salis_free();
+ return 0;
+}
diff --git a/test/ui/push/vars.py b/test/ui/push/vars.py
new file mode 100644
index 0000000..9c2a9f3
--- /dev/null
+++ b/test/ui/push/vars.py
@@ -0,0 +1,3 @@
+flags = set()
+defines = set()
+links = set()
diff --git a/test/ui/v1/1rops/ui.c b/test/ui/v1/1rops/ui.c
index 9c96470..8831fbd 100644
--- a/test/ui/v1/1rops/ui.c
+++ b/test/ui/v1/1rops/ui.c
@@ -59,6 +59,7 @@ int main(void) {
}
}
+ salis_save(SIM_PATH);
salis_free();
return 0;
}
diff --git a/test/ui/v1/2rops/ui.c b/test/ui/v1/2rops/ui.c
index 5fcf65f..32829c4 100644
--- a/test/ui/v1/2rops/ui.c
+++ b/test/ui/v1/2rops/ui.c
@@ -41,6 +41,7 @@ int main(void) {
}
}
+ salis_save(SIM_PATH);
salis_free();
return 0;
}
diff --git a/test/ui/v1/3rops/ui.c b/test/ui/v1/3rops/ui.c
index e4e2d83..1f20ccc 100644
--- a/test/ui/v1/3rops/ui.c
+++ b/test/ui/v1/3rops/ui.c
@@ -55,6 +55,7 @@ int main(void) {
}
}
+ salis_save(SIM_PATH);
salis_free();
return 0;
}
diff --git a/test/ui/v1/addrs/ui.c b/test/ui/v1/addrs/ui.c
index 8949c3f..69bc2ee 100644
--- a/test/ui/v1/addrs/ui.c
+++ b/test/ui/v1/addrs/ui.c
@@ -42,6 +42,7 @@ int main(void) {
salis_step(1);
}
+ salis_save(SIM_PATH);
salis_free();
return 0;
}
diff --git a/test/ui/v1/allos/ui.c b/test/ui/v1/allos/ui.c
index 1a02c30..b6150f9 100644
--- a/test/ui/v1/allos/ui.c
+++ b/test/ui/v1/allos/ui.c
@@ -85,6 +85,7 @@ int main(void) {
assert(g_cores->pnum == 7);
assert(g_cores->pvec[0].sp > MVEC_SIZE);
+ salis_save(SIM_PATH);
salis_free();
return 0;
}
diff --git a/test/ui/v1/ifnzs/ui.c b/test/ui/v1/ifnzs/ui.c
index 57e9533..bf4b201 100644
--- a/test/ui/v1/ifnzs/ui.c
+++ b/test/ui/v1/ifnzs/ui.c
@@ -41,6 +41,7 @@ int main(void) {
assert(g_cores->pvec->r2x == 2);
assert(g_cores->pvec->r3x == 2);
+ salis_save(SIM_PATH);
salis_free();
return 0;
}
diff --git a/test/ui/v1/ioops/ui.c b/test/ui/v1/ioops/ui.c
index 489cb38..0f41a4b 100644
--- a/test/ui/v1/ioops/ui.c
+++ b/test/ui/v1/ioops/ui.c
@@ -50,6 +50,7 @@ int main(void) {
}
}
+ salis_save(SIM_PATH);
salis_free();
return 0;
}
diff --git a/test/ui/v1/jumps/ui.c b/test/ui/v1/jumps/ui.c
index 61514f5..14f9c08 100644
--- a/test/ui/v1/jumps/ui.c
+++ b/test/ui/v1/jumps/ui.c
@@ -16,6 +16,7 @@ int main(void) {
assert(g_cores->pvec->ip < ANC_SIZE);
}
+ salis_save(SIM_PATH);
salis_free();
return 0;
}
diff --git a/test/ui/v1/mbops/ui.c b/test/ui/v1/mbops/ui.c
index 8a92d6f..337a85e 100644
--- a/test/ui/v1/mbops/ui.c
+++ b/test/ui/v1/mbops/ui.c
@@ -31,6 +31,7 @@ int main(void) {
}
}
+ salis_save(SIM_PATH);
salis_free();
return 0;
}
diff --git a/test/ui/v1/noops/ui.c b/test/ui/v1/noops/ui.c
index 230e98d..42d0361 100644
--- a/test/ui/v1/noops/ui.c
+++ b/test/ui/v1/noops/ui.c
@@ -109,6 +109,8 @@ int main(void) {
}
check_final();
+
+ salis_save(SIM_PATH);
salis_free();
return 0;
}
diff --git a/test/ui/v1/stack/ui.c b/test/ui/v1/stack/ui.c
index 1ad047e..1446f34 100644
--- a/test/ui/v1/stack/ui.c
+++ b/test/ui/v1/stack/ui.c
@@ -70,6 +70,7 @@ int main(void) {
}
}
+ salis_save(SIM_PATH);
salis_free();
return 0;
}