diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_build.py | 22 | ||||
| -rw-r--r-- | test/test_general.py | 15 | ||||
| -rw-r--r-- | test/test_run.py | 50 | ||||
| -rw-r--r-- | test/ui/push/ui.c | 11 | ||||
| -rw-r--r-- | test/ui/push/vars.py | 3 | ||||
| -rw-r--r-- | test/ui/v1/1rops/ui.c | 1 | ||||
| -rw-r--r-- | test/ui/v1/2rops/ui.c | 1 | ||||
| -rw-r--r-- | test/ui/v1/3rops/ui.c | 1 | ||||
| -rw-r--r-- | test/ui/v1/addrs/ui.c | 1 | ||||
| -rw-r--r-- | test/ui/v1/allos/ui.c | 1 | ||||
| -rw-r--r-- | test/ui/v1/ifnzs/ui.c | 1 | ||||
| -rw-r--r-- | test/ui/v1/ioops/ui.c | 1 | ||||
| -rw-r--r-- | test/ui/v1/jumps/ui.c | 1 | ||||
| -rw-r--r-- | test/ui/v1/mbops/ui.c | 1 | ||||
| -rw-r--r-- | test/ui/v1/noops/ui.c | 2 | ||||
| -rw-r--r-- | test/ui/v1/stack/ui.c | 1 |
16 files changed, 110 insertions, 3 deletions
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; } |
