aboutsummaryrefslogtreecommitdiff
path: root/test/test_build.py
blob: a57c09d51f704692a33e42565cc12d8683ac1c41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import signal

from test_general import SalisTest

class TestBuild(SalisTest):
    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}"
            for compiler in ["clang", "gcc"]
            for optimized in ["", "-o"]
            for seed in [-1, 0, 1234]
            for ui in ["curses", "daemon"]
        )

    def cmds_new_null(self):
        return self.cmds_new("0123", "null")

    def cmds_new_v1(self):
        return self.cmds_new("55a", "v1")

    def cmds_load(self):
        return (
            f"./salis.py load -b -g{compiler} -H{self.tempdir.name} {optimized} -u{ui}"
            for compiler in ["clang", "gcc"]
            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} {optimized}"
            for compiler in ["clang", "gcc"]
            for optimized in ["", "-o"]
        )

    def cmds_client(self):
        return (
            f"./salis.py client -b -g{c_compiler} {optimized} -x{cxx_compiler}"
            for c_compiler in ["clang", "gcc"]
            for cxx_compiler in ["clang", "gcc"]
            for optimized in ["", "-o"]
        )

    def test_null_new(self):
        for cmd in self.cmds_new_null():
            SalisTest.run_subprocess(cmd)

    def test_v1_new(self):
        for cmd in self.cmds_new_v1():
            SalisTest.run_subprocess(cmd)

    def test_null_load(self):
        SalisTest.run_subprocess(next(self.cmds_new_null()))

        for cmd in self.cmds_load():
            SalisTest.run_subprocess(cmd)

    def test_v1_load(self):
        SalisTest.run_subprocess(next(self.cmds_new_v1()))

        for cmd in self.cmds_load():
            SalisTest.run_subprocess(cmd)

    def test_server(self):
        SalisTest.run_subprocess(next(self.cmds_new_null()))

        for cmd in self.cmds_server():
            SalisTest.run_subprocess(cmd)

    @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):
        with SalisTest.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():
                SalisTest.run_subprocess(cmd)

            server_proc.send_signal(signal.SIGINT)