OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
2 | |
3 import os | |
4 import shutil | |
5 import subprocess | |
6 import sys | |
7 import unittest | |
8 | |
9 ROOT_BUILD_DIR = 'out/test' | |
10 | |
11 FILES = { | |
12 'BUILD.gn' : ''' | |
13 import("snapshot_toolchain.gni") | |
14 | |
15 if (current_toolchain == default_toolchain || (current_os == "android")) { | |
16 group("v8") { | |
17 print("v8", current_toolchain) | |
18 deps = [ ":v8_snapshot($v8_snapshot_toolchain)" ] | |
19 if (target_os == "android" && target_cpu == "arm64" && | |
20 current_cpu == "arm64") { | |
21 deps += [ ":v8(//build/toolchain/android:arm)" ] | |
22 } | |
23 } | |
24 } | |
25 if (current_toolchain == v8_snapshot_toolchain) { | |
26 group("v8_snapshot") { | |
27 print("v8_snapshot", current_toolchain, v8_target_cpu) | |
28 } | |
29 } | |
30 ''', | |
31 | |
32 'build/toolchain/win/setup_toolchain.py': ''' | |
Michael Achenbach
2016/07/25 08:24:05
Is there no way to use the original files as they
| |
33 print 'vc_bin_dir = ""' | |
34 print 'include_flags = ""' | |
35 ''', | |
36 | |
37 'build/vs_toolchain.py': ''' | |
38 print 'vs_path = ""' | |
39 print 'sdk_path = ""' | |
40 print 'vs_version = "2015"' | |
41 print 'wdk_dir = ""' | |
42 print 'runtime_dirs = ""' | |
43 ''' | |
44 } | |
45 | |
46 | |
47 class SnapshotToolchainTest(unittest.TestCase): | |
48 maxDiff = 1024 | |
49 | |
50 @classmethod | |
51 def setUpClass(cls): | |
52 for path, contents in FILES.items(): | |
53 os.rename(path, path + '.bak') | |
54 with open(path, "w") as fp: | |
55 fp.write(contents) | |
56 | |
57 @classmethod | |
58 def tearDownClass(cls): | |
59 for path in FILES: | |
60 os.rename(path + '.bak', path) | |
61 | |
62 def setUp(self): | |
63 shutil.rmtree(ROOT_BUILD_DIR, ignore_errors=True) | |
64 os.makedirs(ROOT_BUILD_DIR) | |
65 | |
66 def tearDown(self): | |
67 shutil.rmtree(ROOT_BUILD_DIR) | |
68 | |
69 def run_one_test(self, args, expected_out): | |
70 with open('%s/args.gn' % ROOT_BUILD_DIR, 'w') as fp: | |
71 fp.write(args + "\n") | |
72 | |
73 if sys.platform == "win32": | |
74 gn = "buildtools/win/gn.exe" | |
75 elif sys.platform == "darwin": | |
76 gn = "buildtools/mac/gn" | |
77 else: | |
78 gn = "buildtools/linux64/gn" | |
79 | |
80 p = subprocess.Popen([gn, 'gen', ROOT_BUILD_DIR], | |
81 stdout=subprocess.PIPE) | |
82 got, _ = p.communicate() | |
83 exp_lines = expected_out.strip().splitlines() | |
84 got_lines = got.splitlines()[:-1] | |
85 | |
86 self.assertEqual(p.returncode, 0) | |
87 self.assertEqual(set(got_lines), set(exp_lines)) | |
Michael Achenbach
2016/07/25 08:24:05
Just a thought: The approach is maybe a bit sensit
| |
88 | |
89 def test_android_arm(self): | |
90 self.run_one_test(''' | |
91 host_os = "linux" | |
92 target_os = "android" | |
93 use_sysroot = false | |
94 ''', ''' | |
95 v8 //build/toolchain/android:arm | |
96 v8_snapshot //build/toolchain/linux:clang_x86_v8_arm arm | |
97 ''') | |
98 | |
99 def test_android_arm64_fat_binary(self): | |
100 self.run_one_test(''' | |
101 host_os = "linux" | |
102 target_os = "android" | |
103 target_cpu = "arm64" | |
104 use_sysroot = false | |
105 ''', ''' | |
106 v8 //build/toolchain/android:arm64 | |
107 v8 //build/toolchain/android:arm | |
108 v8_snapshot //build/toolchain/linux:clang_x64_v8_arm64 arm64 | |
109 v8_snapshot //build/toolchain/linux:clang_x86_v8_arm arm | |
110 ''') | |
111 | |
112 def test_android_mips64el(self): | |
113 self.run_one_test(''' | |
114 host_os = "linux" | |
115 target_os = "android" | |
116 target_cpu = "mips64el" | |
117 use_sysroot = false | |
118 ''', ''' | |
119 v8 //build/toolchain/android:mips64el | |
120 v8_snapshot //build/toolchain/linux:clang_x64_v8_mips64el mips64el | |
121 ''') | |
122 | |
123 def test_android_x64(self): | |
124 self.run_one_test(''' | |
125 host_os = "linux" | |
126 target_os = "android" | |
127 target_cpu = "x64" | |
128 use_sysroot = false | |
129 ''', ''' | |
130 v8 //build/toolchain/android:x64 | |
131 v8_snapshot //build/toolchain/linux:clang_x64 x64 | |
132 ''') | |
133 | |
134 def test_android_x86(self): | |
135 self.run_one_test(''' | |
136 host_os = "linux" | |
137 target_os = "android" | |
138 target_cpu = "x86" | |
139 use_sysroot = false | |
140 ''', ''' | |
141 v8 //build/toolchain/android:x86 | |
142 v8_snapshot //build/toolchain/linux:clang_x86 x86 | |
143 ''') | |
144 | |
145 def test_linux_x64(self): | |
146 self.run_one_test(''' | |
147 host_os = "linux" | |
148 use_sysroot = false | |
149 | |
150 ''', ''' | |
151 v8 //build/toolchain/linux:clang_x64 | |
152 v8_snapshot //build/toolchain/linux:clang_x64 x64 | |
153 ''') | |
154 | |
155 def test_linux_x86(self): | |
156 self.run_one_test(''' | |
157 host_os = "linux" | |
158 target_cpu = "x86" | |
159 use_sysroot = false | |
160 ''', ''' | |
161 v8 //build/toolchain/linux:clang_x86 | |
162 v8_snapshot //build/toolchain/linux:clang_x86 x86 | |
163 ''') | |
164 | |
165 def test_linux_gcc_arm64(self): | |
166 self.run_one_test(''' | |
167 host_os = "linux" | |
168 v8_target_cpu = "arm64" | |
169 is_clang = false | |
170 use_sysroot = false | |
171 ''', ''' | |
172 v8 //build/toolchain/linux:x64 | |
173 v8_snapshot //build/toolchain/linux:x64 arm64 | |
174 ''') | |
175 | |
176 def test_linux_x86_v8_arm(self): | |
177 self.run_one_test(''' | |
178 host_os = "linux" | |
179 target_cpu = "x86" | |
180 v8_target_cpu = "arm" | |
181 use_sysroot = false | |
182 ''', ''' | |
183 v8 //build/toolchain/linux:clang_x86 | |
184 v8_snapshot //build/toolchain/linux:clang_x86 arm | |
185 ''') | |
186 | |
187 def test_mac(self): | |
188 self.run_one_test(''' | |
189 host_os = "mac" | |
190 ''', ''' | |
191 v8 //build/toolchain/mac:clang_x64 | |
192 v8_snapshot //build/toolchain/mac:clang_x64 x64 | |
193 ''') | |
194 | |
195 def test_win_x64(self): | |
196 self.run_one_test(''' | |
197 host_os = "win" | |
198 ''', ''' | |
199 v8 //build/toolchain/win:x64 | |
200 v8_snapshot //build/toolchain/win:x64 x64 | |
201 ''') | |
202 | |
203 def test_win_x86(self): | |
204 self.run_one_test(''' | |
205 host_os = "win" | |
206 target_cpu = "x86" | |
207 ''', ''' | |
208 v8 //build/toolchain/win:x86 | |
209 v8_snapshot //build/toolchain/win:x86 x86 | |
210 ''') | |
211 | |
212 | |
213 if __name__ == '__main__': | |
214 unittest.main() | |
OLD | NEW |