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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
"""Command line interface tests for llvm.py run-test-suite.
Note that although this uses the unittest framework, it does *not* contain unit
tests.
"""
from llvmtestcase import LLVMTestCase, require_command_arg, debug
from re import escape
class Testllvmruntestsuite(LLVMTestCase):
@classmethod
def llvm_run_test_suite(cls, *args, **kwargs):
return cls.command_with_defaults("run-test-suite", *args, **kwargs)
@require_command_arg("--sandbox")
def test_sandbox_is_compulsory(self):
"""Test that we get an error if we don't pass the path to the sandbox."""
self.run_with_output(self.llvm_run_test_suite("--test-suite=somewhere",
"--use-lit=somewhere"
"--cc=somewhere"))
@require_command_arg("--test-suite")
def test_test_suite_repo_is_compulsory(self):
"""
Test that we get an error if we don't pass the path to the test-suite
repo.
"""
self.run_with_output(self.llvm_run_test_suite("--sandbox=somewhere",
"--use-lit=somewhere"
"--cc=somewhere"))
@require_command_arg("--use-lit")
def test_llvm_lit_is_compulsory(self):
"""Test that we get an error if we don't pass the path to llvm-lit."""
self.run_with_output(self.llvm_run_test_suite("--sandbox=somewhere",
"--test-suite=somewhere"
"--cc=somewhere"))
@require_command_arg("--cc")
def test_cc_is_compulsory(self):
"""
Test that we get an error if we don't pass the path to the C compiler.
"""
self.run_with_output(self.llvm_run_test_suite("--sandbox=somewhere",
"--test-suite=somewhere",
"--use-lit=somewhere"))
def test_basic_command(self):
"""
Test that we can run a test-suite command with only the required args.
"""
sandbox = "path/to/sandbox"
testsuite = "path/to/testuite"
lit = "path/to/lit"
cc = "path/to/clang"
output = self.run_with_output(
self.llvm_run_test_suite(
"--dry-run",
"--sandbox", sandbox,
"--test-suite", testsuite,
"--use-lit", lit,
"--cc", cc))
expectedCommand = escape(
"{0}/bin/python {0}/bin/lnt runtest test-suite "
"--sandbox={0} --test-suite={1} --use-lit={2} --cc={3}\n".format(
sandbox, testsuite, lit, cc))
# We don't care about the directory where this is running.
self.assertRegex(
output, "(.*)\$ {}".format(expectedCommand))
def test_custom_flags(self):
"""Test that we can run a test-suite command with custom flags."""
sandbox = "path/to/sandbox"
testsuite = "path/to/testuite"
lit = "path/to/lit"
cc = "path/to/clang"
output = self.run_with_output(
self.llvm_run_test_suite(
"--dry-run",
"--sandbox", sandbox,
"--test-suite", testsuite,
"--use-lit", lit,
"--cc", cc,
"--lnt-flag=--cppflags='-mcpu=cortex-a15 -marm'",
"--lnt-flag=--threads=4"))
expectedCommand = escape(
"{0}/bin/python {0}/bin/lnt runtest test-suite "
"--sandbox={0} --test-suite={1} --use-lit={2} --cc={3} "
"--cppflags='-mcpu=cortex-a15 -marm' --threads=4\n".format(
sandbox, testsuite, lit, cc))
# We don't care about the directory where this is running.
self.assertRegex(
output, "(.*)\$ {}".format(expectedCommand))
def test_cxx(self):
"""Test that we can specify --cxx if we want to."""
sandbox = "path/to/sandbox"
testsuite = "path/to/testuite"
lit = "path/to/lit"
cc = "path/to/clang"
cxx = "path/to/clang++"
output = self.run_with_output(
self.llvm_run_test_suite(
"--dry-run",
"--sandbox", sandbox,
"--test-suite", testsuite,
"--use-lit", lit,
"--cc", cc,
"--cxx", cxx,
"--lnt-flag=--cppflags='-mcpu=cortex-a15 -marm'",
"--lnt-flag=--threads=4"))
expectedCommand = escape(
"{0}/bin/python {0}/bin/lnt runtest test-suite "
"--sandbox={0} --test-suite={1} --use-lit={2} --cc={3} --cxx={4} "
"--cppflags='-mcpu=cortex-a15 -marm' --threads=4\n".format(
sandbox, testsuite, lit, cc, cxx))
# We don't care about the directory where this is running.
self.assertRegex(
output, "(.*)\$ {}".format(expectedCommand))
|