From 1961b4b237083f4cfac9ca6b249c1d6cb665d149 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Tue, 14 Jul 2026 17:29:02 +0200 Subject: Initial (refactor) --- test/test_build.py | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 test/test_build.py (limited to 'test/test_build.py') diff --git a/test/test_build.py b/test/test_build.py new file mode 100644 index 0000000..e13669a --- /dev/null +++ b/test/test_build.py @@ -0,0 +1,114 @@ +# file : test/test_build.py +# project : Salis-VM +# author : Paul Oliver + +# index: +# [section] command lists +# [section] tests null +# [section] tests v1 +# [section] tests server & client + +import signal + +from test_general import SalisTest + +class TestBuild(SalisTest): + SIM_NAME = "test-build.sim" + + # -------------------------------------------------------------------------- + # [section] command lists + # -------------------------------------------------------------------------- + def commands_new(self, anc, arch): + return [ + f"./salis.py new -a{anc} -b -f -g{compiler} -H{self.tempdir.name} -n{self.SIM_NAME} {log_trace} {optimized} -s{seed} -u{ui} -v{arch}" + for compiler in ["clang", "gcc", "tcc"] + for log_trace in ["", "-l"] + for optimized in ["", "-o"] + for seed in [-1, 0, 1234] + for ui in ["curses", "daemon"] + ] + + def commands_load(self): + return [ + f"./salis.py load -b -g{compiler} -H{self.tempdir.name} -n{self.SIM_NAME} {log_trace} {optimized} -u{ui}" + for compiler in ["clang", "gcc", "tcc"] + for log_trace in ["", "-l"] + for optimized in ["", "-o"] + for ui in ["curses", "daemon"] + ] + + def cmds_server(self): + return [ + f"./salis.py server -b -g{compiler} -H{self.tempdir.name} -n{self.SIM_NAME} {optimized}" + for compiler in ["clang", "gcc"] + for optimized in ["", "-o"] + ] + + def cmds_client(self): + return [ + f"./salis.py client -b -g{c_compiler} -G{cpp_compiler} {optimized}" + for c_compiler, cpp_compiler in [("clang", "clang++"), ("gcc", "g++")] + for optimized in ["", "-o"] + ] + + # -------------------------------------------------------------------------- + # [section] tests null + # -------------------------------------------------------------------------- + def test_null_new(self): + for command in self.commands_new("0123", "null"): + self.run_subprocess(command) + self.assert_files_exist([f"{self.tempdir.name}/{self.SIM_NAME}/opts.json"]) + + def test_null_load(self): + self.run_subprocess(self.commands_new("0123", "null")[0]) + self.assert_files_exist([f"{self.tempdir.name}/{self.SIM_NAME}/opts.json"]) + + for command in self.commands_load(): + self.run_subprocess(command) + self.assert_files_exist([f"{self.tempdir.name}/{self.SIM_NAME}/opts.json"]) + + # -------------------------------------------------------------------------- + # [section] tests v1 + # -------------------------------------------------------------------------- + def test_v1_new(self): + for command in self.commands_new("55a", "v1"): + self.run_subprocess(command) + self.assert_files_exist([f"{self.tempdir.name}/{self.SIM_NAME}/opts.json"]) + + def test_v1_load(self): + self.run_subprocess(self.commands_new("55a", "v1")[0]) + self.assert_files_exist([f"{self.tempdir.name}/{self.SIM_NAME}/opts.json"]) + + for command in self.commands_load(): + self.run_subprocess(command) + self.assert_files_exist([f"{self.tempdir.name}/{self.SIM_NAME}/opts.json"]) + + # -------------------------------------------------------------------------- + # [section] tests server & client + # -------------------------------------------------------------------------- + def client_test(self): + with self.run_pipe(f"./salis.py server -H{self.tempdir.name}") as server_proc: + for line in server_proc.stdout: + if "Listening..." in line: + break + + for cmd in self.cmds_client(): + self.run_subprocess(cmd) + + server_proc.send_signal(signal.SIGINT) + + def test_server(self): + self.run_subprocess(self.commands_new("0123", "null")[0]) + self.assert_files_exist([f"{self.tempdir.name}/{self.SIM_NAME}/opts.json"]) + + for cmd in self.cmds_server(): + self.run_subprocess(cmd) + self.assert_files_exist([f"{self.tempdir.name}/{self.SIM_NAME}/opts.json"]) + + def test_client_null(self): + self.run_ui_test("0123", "anc", "null", "test/ui", "null") + self.client_test() + + def test_client_v1(self): + self.run_ui_test("55a", "anc", "null", "test/ui", "v1") + self.client_test() -- cgit v1.2.1