OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2015 Google Inc. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 Verifies that LTO flags work. | 8 Verifies that LTO flags work. |
9 """ | 9 """ |
10 | 10 |
| 11 from __future__ import print_function |
| 12 |
11 import TestGyp | 13 import TestGyp |
12 | 14 |
13 import os | 15 import os |
14 import re | 16 import re |
15 import subprocess | 17 import subprocess |
16 import sys | 18 import sys |
17 | 19 |
18 if sys.platform == 'darwin': | 20 if sys.platform == 'darwin': |
19 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) | 21 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) |
20 CHDIR = 'lto' | 22 CHDIR = 'lto' |
(...skipping 16 matching lines...) Expand all Loading... |
37 | 39 |
38 def ObjType(p, t_expected): | 40 def ObjType(p, t_expected): |
39 r = re.compile(r'nsyms\s+(\d+)') | 41 r = re.compile(r'nsyms\s+(\d+)') |
40 o = subprocess.check_output(['file', p]) | 42 o = subprocess.check_output(['file', p]) |
41 objtype = 'unknown' | 43 objtype = 'unknown' |
42 if ': Mach-O ' in o: | 44 if ': Mach-O ' in o: |
43 objtype = 'mach-o' | 45 objtype = 'mach-o' |
44 elif ': LLVM bit-code ' in o: | 46 elif ': LLVM bit-code ' in o: |
45 objtype = 'llvm' | 47 objtype = 'llvm' |
46 if objtype != t_expected: | 48 if objtype != t_expected: |
47 print 'Expected %s, got %s' % (t_expected, objtype) | 49 print('Expected %s, got %s' % (t_expected, objtype)) |
48 test.fail_test() | 50 test.fail_test() |
49 | 51 |
50 ObjType(ObjPath('cfile', 'lto'), 'llvm') | 52 ObjType(ObjPath('cfile', 'lto'), 'llvm') |
51 ObjType(ObjPath('ccfile', 'lto'), 'llvm') | 53 ObjType(ObjPath('ccfile', 'lto'), 'llvm') |
52 ObjType(ObjPath('mfile', 'lto'), 'llvm') | 54 ObjType(ObjPath('mfile', 'lto'), 'llvm') |
53 ObjType(ObjPath('mmfile', 'lto'), 'llvm') | 55 ObjType(ObjPath('mmfile', 'lto'), 'llvm') |
54 ObjType(ObjPath('asmfile', 'lto'), 'mach-o') | 56 ObjType(ObjPath('asmfile', 'lto'), 'mach-o') |
55 | 57 |
56 ObjType(ObjPath('cfile', 'lto_static'), 'llvm') | 58 ObjType(ObjPath('cfile', 'lto_static'), 'llvm') |
57 ObjType(ObjPath('ccfile', 'lto_static'), 'llvm') | 59 ObjType(ObjPath('ccfile', 'lto_static'), 'llvm') |
58 ObjType(ObjPath('mfile', 'lto_static'), 'llvm') | 60 ObjType(ObjPath('mfile', 'lto_static'), 'llvm') |
59 ObjType(ObjPath('mmfile', 'lto_static'), 'llvm') | 61 ObjType(ObjPath('mmfile', 'lto_static'), 'llvm') |
60 ObjType(ObjPath('asmfile', 'lto_static'), 'mach-o') | 62 ObjType(ObjPath('asmfile', 'lto_static'), 'mach-o') |
61 | 63 |
62 test.pass_test() | 64 test.pass_test() |
63 | 65 |
64 # TODO: Probably test for -object_path_lto too, else dsymutil won't be | 66 # TODO: Probably test for -object_path_lto too, else dsymutil won't be |
65 # useful maybe? | 67 # useful maybe? |
OLD | NEW |