summaryrefslogtreecommitdiff
path: root/test/test_build.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_build.py')
-rw-r--r--test/test_build.py114
1 files changed, 114 insertions, 0 deletions
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 <contact@pauloliver.dev>
+
+# 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()