Chromium Code Reviews| Index: v8_snapshot_test.py |
| diff --git a/v8_snapshot_test.py b/v8_snapshot_test.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0375533b30f9de4c92ea4ec0fd48cf8070f2a1da |
| --- /dev/null |
| +++ b/v8_snapshot_test.py |
| @@ -0,0 +1,214 @@ |
| +#!/usr/bin/python |
| + |
| +import os |
| +import shutil |
| +import subprocess |
| +import sys |
| +import unittest |
| + |
| +ROOT_BUILD_DIR = 'out/test' |
| + |
| +FILES = { |
| + 'BUILD.gn' : ''' |
| +import("snapshot_toolchain.gni") |
| + |
| +if (current_toolchain == default_toolchain || (current_os == "android")) { |
| + group("v8") { |
| + print("v8", current_toolchain) |
| + deps = [ ":v8_snapshot($v8_snapshot_toolchain)" ] |
| + if (target_os == "android" && target_cpu == "arm64" && |
| + current_cpu == "arm64") { |
| + deps += [ ":v8(//build/toolchain/android:arm)" ] |
| + } |
| + } |
| +} |
| +if (current_toolchain == v8_snapshot_toolchain) { |
| + group("v8_snapshot") { |
| + print("v8_snapshot", current_toolchain, v8_target_cpu) |
| + } |
| +} |
| +''', |
| + |
| + '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
|
| +print 'vc_bin_dir = ""' |
| +print 'include_flags = ""' |
| +''', |
| + |
| + 'build/vs_toolchain.py': ''' |
| +print 'vs_path = ""' |
| +print 'sdk_path = ""' |
| +print 'vs_version = "2015"' |
| +print 'wdk_dir = ""' |
| +print 'runtime_dirs = ""' |
| +''' |
| +} |
| + |
| + |
| +class SnapshotToolchainTest(unittest.TestCase): |
| + maxDiff = 1024 |
| + |
| + @classmethod |
| + def setUpClass(cls): |
| + for path, contents in FILES.items(): |
| + os.rename(path, path + '.bak') |
| + with open(path, "w") as fp: |
| + fp.write(contents) |
| + |
| + @classmethod |
| + def tearDownClass(cls): |
| + for path in FILES: |
| + os.rename(path + '.bak', path) |
| + |
| + def setUp(self): |
| + shutil.rmtree(ROOT_BUILD_DIR, ignore_errors=True) |
| + os.makedirs(ROOT_BUILD_DIR) |
| + |
| + def tearDown(self): |
| + shutil.rmtree(ROOT_BUILD_DIR) |
| + |
| + def run_one_test(self, args, expected_out): |
| + with open('%s/args.gn' % ROOT_BUILD_DIR, 'w') as fp: |
| + fp.write(args + "\n") |
| + |
| + if sys.platform == "win32": |
| + gn = "buildtools/win/gn.exe" |
| + elif sys.platform == "darwin": |
| + gn = "buildtools/mac/gn" |
| + else: |
| + gn = "buildtools/linux64/gn" |
| + |
| + p = subprocess.Popen([gn, 'gen', ROOT_BUILD_DIR], |
| + stdout=subprocess.PIPE) |
| + got, _ = p.communicate() |
| + exp_lines = expected_out.strip().splitlines() |
| + got_lines = got.splitlines()[:-1] |
| + |
| + self.assertEqual(p.returncode, 0) |
| + 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
|
| + |
| + def test_android_arm(self): |
| + self.run_one_test(''' |
| +host_os = "linux" |
| +target_os = "android" |
| +use_sysroot = false |
| +''', ''' |
| +v8 //build/toolchain/android:arm |
| +v8_snapshot //build/toolchain/linux:clang_x86_v8_arm arm |
| +''') |
| + |
| + def test_android_arm64_fat_binary(self): |
| + self.run_one_test(''' |
| +host_os = "linux" |
| +target_os = "android" |
| +target_cpu = "arm64" |
| +use_sysroot = false |
| +''', ''' |
| +v8 //build/toolchain/android:arm64 |
| +v8 //build/toolchain/android:arm |
| +v8_snapshot //build/toolchain/linux:clang_x64_v8_arm64 arm64 |
| +v8_snapshot //build/toolchain/linux:clang_x86_v8_arm arm |
| +''') |
| + |
| + def test_android_mips64el(self): |
| + self.run_one_test(''' |
| +host_os = "linux" |
| +target_os = "android" |
| +target_cpu = "mips64el" |
| +use_sysroot = false |
| +''', ''' |
| +v8 //build/toolchain/android:mips64el |
| +v8_snapshot //build/toolchain/linux:clang_x64_v8_mips64el mips64el |
| +''') |
| + |
| + def test_android_x64(self): |
| + self.run_one_test(''' |
| +host_os = "linux" |
| +target_os = "android" |
| +target_cpu = "x64" |
| +use_sysroot = false |
| +''', ''' |
| +v8 //build/toolchain/android:x64 |
| +v8_snapshot //build/toolchain/linux:clang_x64 x64 |
| +''') |
| + |
| + def test_android_x86(self): |
| + self.run_one_test(''' |
| +host_os = "linux" |
| +target_os = "android" |
| +target_cpu = "x86" |
| +use_sysroot = false |
| +''', ''' |
| +v8 //build/toolchain/android:x86 |
| +v8_snapshot //build/toolchain/linux:clang_x86 x86 |
| +''') |
| + |
| + def test_linux_x64(self): |
| + self.run_one_test(''' |
| +host_os = "linux" |
| +use_sysroot = false |
| + |
| +''', ''' |
| +v8 //build/toolchain/linux:clang_x64 |
| +v8_snapshot //build/toolchain/linux:clang_x64 x64 |
| +''') |
| + |
| + def test_linux_x86(self): |
| + self.run_one_test(''' |
| +host_os = "linux" |
| +target_cpu = "x86" |
| +use_sysroot = false |
| +''', ''' |
| +v8 //build/toolchain/linux:clang_x86 |
| +v8_snapshot //build/toolchain/linux:clang_x86 x86 |
| +''') |
| + |
| + def test_linux_gcc_arm64(self): |
| + self.run_one_test(''' |
| +host_os = "linux" |
| +v8_target_cpu = "arm64" |
| +is_clang = false |
| +use_sysroot = false |
| +''', ''' |
| +v8 //build/toolchain/linux:x64 |
| +v8_snapshot //build/toolchain/linux:x64 arm64 |
| +''') |
| + |
| + def test_linux_x86_v8_arm(self): |
| + self.run_one_test(''' |
| +host_os = "linux" |
| +target_cpu = "x86" |
| +v8_target_cpu = "arm" |
| +use_sysroot = false |
| +''', ''' |
| +v8 //build/toolchain/linux:clang_x86 |
| +v8_snapshot //build/toolchain/linux:clang_x86 arm |
| +''') |
| + |
| + def test_mac(self): |
| + self.run_one_test(''' |
| +host_os = "mac" |
| +''', ''' |
| +v8 //build/toolchain/mac:clang_x64 |
| +v8_snapshot //build/toolchain/mac:clang_x64 x64 |
| +''') |
| + |
| + def test_win_x64(self): |
| + self.run_one_test(''' |
| +host_os = "win" |
| +''', ''' |
| +v8 //build/toolchain/win:x64 |
| +v8_snapshot //build/toolchain/win:x64 x64 |
| +''') |
| + |
| + def test_win_x86(self): |
| + self.run_one_test(''' |
| +host_os = "win" |
| +target_cpu = "x86" |
| +''', ''' |
| +v8 //build/toolchain/win:x86 |
| +v8_snapshot //build/toolchain/win:x86 x86 |
| +''') |
| + |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |