Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 # Copyright (c) 2015 Google Inc. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 """ | |
| 8 Verifies that LTO flags work. | |
| 9 """ | |
| 10 | |
| 11 import TestGyp | |
| 12 | |
| 13 import os | |
| 14 import re | |
| 15 import subprocess | |
| 16 import sys | |
| 17 | |
| 18 if sys.platform == 'darwin': | |
| 19 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) | |
| 20 #if test.format == 'xcode-ninja': | |
|
scottmg
2015/04/01 23:50:21
delete?
| |
| 21 # test.skip_test() | |
| 22 CHDIR = 'lto' | |
| 23 test.run_gyp('test.gyp', chdir=CHDIR) | |
| 24 | |
| 25 test.build('test.gyp', test.ALL, chdir=CHDIR) | |
| 26 | |
| 27 def ObjPath(srcpath, target): | |
| 28 # TODO: Remove this into TestGyp if it's needed elsewhere. | |
| 29 if test.format == 'xcode': | |
| 30 return os.path.join(CHDIR, 'build', 'test.build', 'Default', | |
| 31 target + '.build', 'Objects-normal', 'x86_64', | |
| 32 srcpath + '.o') | |
| 33 elif 'ninja' in test.format: # ninja, xcode-ninja | |
| 34 return os.path.join(CHDIR, 'out', 'Default', 'obj', | |
| 35 target + '.' + srcpath + '.o') | |
| 36 elif test.format == 'make': | |
| 37 return os.path.join(CHDIR, 'out', 'Default', 'obj.target', | |
| 38 target, srcpath + '.o') | |
| 39 | |
| 40 def ObjType(p, t_expected): | |
| 41 r = re.compile(r'nsyms\s+(\d+)') | |
| 42 o = subprocess.check_output(['file', p]) | |
| 43 objtype = 'unknown' | |
| 44 if ': Mach-O ' in o: | |
| 45 objtype = 'mach-o' | |
| 46 elif ': LLVM bit-code ' in o: | |
| 47 objtype = 'llvm' | |
| 48 if objtype != t_expected: | |
| 49 print 'Expected %s, got %s' % (t_expected, objtype) | |
| 50 test.fail_test() | |
| 51 | |
| 52 ObjType(ObjPath('cfile', 'lto'), 'llvm') | |
| 53 ObjType(ObjPath('ccfile', 'lto'), 'llvm') | |
| 54 ObjType(ObjPath('mfile', 'lto'), 'llvm') | |
| 55 ObjType(ObjPath('mmfile', 'lto'), 'llvm') | |
| 56 ObjType(ObjPath('asmfile', 'lto'), 'mach-o') | |
| 57 | |
| 58 ObjType(ObjPath('cfile', 'lto_static'), 'llvm') | |
| 59 ObjType(ObjPath('ccfile', 'lto_static'), 'llvm') | |
| 60 ObjType(ObjPath('mfile', 'lto_static'), 'llvm') | |
| 61 ObjType(ObjPath('mmfile', 'lto_static'), 'llvm') | |
| 62 ObjType(ObjPath('asmfile', 'lto_static'), 'mach-o') | |
| 63 | |
| 64 test.pass_test() | |
| 65 | |
| 66 # TODO: Probably test for -object_path_lto too, else dsymutil won't be | |
| 67 # useful maybe? | |
| OLD | NEW |