aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests/testllvmsubprojects.py
blob: c39e7ae81ed3ef43d29ae0437f64928305d2618e (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
import os
import unittest

from modules.llvm import LLVMSubproject


class TestLLVMSubproject(unittest.TestCase):
    """Test that we have the right info on LLVM subprojects."""

    def test_build_paths(self):
        subprojects = LLVMSubproject.get_all_subprojects()

        self.assertEqual(subprojects["clang"].cmake_path,
                         os.path.join("tools", "clang"))
        self.assertEqual(subprojects["compiler-rt"].cmake_path,
                         os.path.join("projects", "compiler-rt"))
        self.assertEqual(subprojects["libcxx"].cmake_path,
                         os.path.join("projects", "libcxx"))
        self.assertEqual(subprojects["libcxxabi"].cmake_path,
                         os.path.join("projects", "libcxxabi"))
        self.assertEqual(subprojects["libunwind"].cmake_path,
                         os.path.join("projects", "libunwind"))
        self.assertEqual(subprojects["lld"].cmake_path,
                         os.path.join("tools", "lld"))
        self.assertEqual(subprojects["lldb"].cmake_path,
                         os.path.join("tools", "lldb"))
        self.assertEqual(subprojects["test-suite"].cmake_path,
                         os.path.join("projects", "test-suite"))

    def test_cmake_vars(self):
        subprojects = LLVMSubproject.get_all_subprojects()

        self.assertEqual(
            subprojects["clang"].cmake_var,
            "LLVM_TOOL_CLANG_BUILD")
        self.assertEqual(subprojects["compiler-rt"].cmake_var,
                         "LLVM_TOOL_COMPILER_RT_BUILD")
        self.assertEqual(
            subprojects["libcxx"].cmake_var,
            "LLVM_TOOL_LIBCXX_BUILD")
        self.assertEqual(subprojects["libcxxabi"].cmake_var,
                         "LLVM_TOOL_LIBCXXABI_BUILD")
        self.assertEqual(
            subprojects["libunwind"].cmake_var,
            "LLVM_TOOL_LIBUNWIND_BUILD")
        self.assertEqual(subprojects["lld"].cmake_var, "LLVM_TOOL_LLD_BUILD")
        self.assertEqual(subprojects["lldb"].cmake_var, "LLVM_TOOL_LLDB_BUILD")
        self.assertEqual(subprojects["test-suite"].cmake_var, None)

    def test_get_cmake_path(self):
        subproject = LLVMSubproject(
            os.path.join(
                "path",
                "to",
                "subproj"),
            None)
        cmake_path = subproject.get_cmake_path(os.path.join("llvm", "sources"))

        self.assertEqual(
            str(cmake_path),
            os.path.join("llvm", "sources", "path", "to", "subproj"))

if __name__ == "__main__":
    unittest.main()