summaryrefslogtreecommitdiff
path: root/test/test_build.py
blob: 7c0126a1d2f574a2516935d4df05d81af8d6d11e (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
# file    : test/test_build.py
# project : Salis-VM
# author  : Paul Oliver <contact@pauloliver.dev>

# index:
# [section] imports
# [section] constants
# [section] command lists
# [section] tests null

# ------------------------------------------------------------------------------
# [section] imports
# ------------------------------------------------------------------------------
from test_general import SalisTest

class TestBuild(SalisTest):
    # --------------------------------------------------------------------------
    # [section] constants
    # --------------------------------------------------------------------------
    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} {optimized} -s{seed} -u{ui} -v{arch}"
            for compiler in ["clang", "gcc", "tcc"]
            for optimized in ["", "-o"]
            for seed in [-1, 0, 1234]
            for ui in ["daemon"]
        ]

    def commands_load(self):
        return [
            f"./salis.py load -b -g{compiler} -H{self.tempdir.name} -n{self.SIM_NAME} {optimized} -u{ui}"
            for compiler in ["clang", "gcc", "tcc"]
            for optimized in ["", "-o"]
            for ui in ["daemon"]
        ]

    # --------------------------------------------------------------------------
    # [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"])