Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: test/mac/gyptest-strip.py

Issue 1454433002: Python 3 compatibility Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Rebase with master (4ec6c4e3a94bd04a6da2858163d40b2429b8aad1) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012 Google Inc. All rights reserved. 3 # Copyright (c) 2012 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 stripping works. 8 Verifies that stripping works.
9 """ 9 """
10 10
11 from __future__ import print_function
12
11 import TestGyp 13 import TestGyp
12 import TestMac 14 import TestMac
13 15
14 import re 16 import re
15 import subprocess 17 import subprocess
16 import sys 18 import sys
17 import time 19 import time
18 20
19 if sys.platform == 'darwin': 21 if sys.platform == 'darwin':
20 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) 22 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
21 23
22 test.run_gyp('test.gyp', chdir='strip') 24 test.run_gyp('test.gyp', chdir='strip')
23 25
24 test.build('test.gyp', test.ALL, chdir='strip') 26 test.build('test.gyp', test.ALL, chdir='strip')
25 27
26 # Lightweight check if stripping was done. 28 # Lightweight check if stripping was done.
27 def OutPath(s): 29 def OutPath(s):
28 return test.built_file_path(s, type=test.SHARED_LIB, chdir='strip') 30 return test.built_file_path(s, type=test.SHARED_LIB, chdir='strip')
29 31
30 def CheckNsyms(p, n_expected): 32 def CheckNsyms(p, n_expected):
31 r = re.compile(r'nsyms\s+(\d+)') 33 r = re.compile(r'nsyms\s+(\d+)')
32 o = subprocess.check_output(['otool', '-l', p]) 34 o = subprocess.check_output(['otool', '-l', p])
33 m = r.search(o) 35 m = r.search(o)
34 n = int(m.group(1)) 36 n = int(m.group(1))
35 if n != n_expected: 37 if n != n_expected:
36 print 'Stripping: Expected %d symbols, got %d' % (n_expected, n) 38 print('Stripping: Expected %d symbols, got %d' % (n_expected, n))
37 test.fail_test() 39 test.fail_test()
38 40
39 # Starting with Xcode 5.0, clang adds an additional symbols to the compiled 41 # Starting with Xcode 5.0, clang adds an additional symbols to the compiled
40 # file when using a relative path to the input file. So when using ninja 42 # file when using a relative path to the input file. So when using ninja
41 # with Xcode 5.0 or higher, take this additional symbol into consideration 43 # with Xcode 5.0 or higher, take this additional symbol into consideration
42 # for unstripped builds (it is stripped by all strip commands). 44 # for unstripped builds (it is stripped by all strip commands).
43 expected_extra_symbol_count = 0 45 expected_extra_symbol_count = 0
44 if test.format in ['ninja', 'xcode-ninja'] \ 46 if test.format in ['ninja', 'xcode-ninja'] \
45 and TestMac.Xcode.Version() >= '0500': 47 and TestMac.Xcode.Version() >= '0500':
46 expected_extra_symbol_count = 1 48 expected_extra_symbol_count = 1
47 49
48 # The actual numbers here are not interesting, they just need to be the same 50 # The actual numbers here are not interesting, they just need to be the same
49 # in both the xcode and the make build. 51 # in both the xcode and the make build.
50 CheckNsyms(OutPath('no_postprocess'), 29 + expected_extra_symbol_count) 52 CheckNsyms(OutPath('no_postprocess'), 29 + expected_extra_symbol_count)
51 CheckNsyms(OutPath('no_strip'), 29 + expected_extra_symbol_count) 53 CheckNsyms(OutPath('no_strip'), 29 + expected_extra_symbol_count)
52 CheckNsyms(OutPath('strip_all'), 0) 54 CheckNsyms(OutPath('strip_all'), 0)
53 CheckNsyms(OutPath('strip_nonglobal'), 6) 55 CheckNsyms(OutPath('strip_nonglobal'), 6)
54 CheckNsyms(OutPath('strip_debugging'), 7) 56 CheckNsyms(OutPath('strip_debugging'), 7)
55 CheckNsyms(OutPath('strip_all_custom_flags'), 0) 57 CheckNsyms(OutPath('strip_all_custom_flags'), 0)
56 CheckNsyms(test.built_file_path( 58 CheckNsyms(test.built_file_path(
57 'strip_all_bundle.framework/Versions/A/strip_all_bundle', chdir='strip'), 59 'strip_all_bundle.framework/Versions/A/strip_all_bundle', chdir='strip'),
58 0) 60 0)
59 CheckNsyms(OutPath('strip_save'), 7) 61 CheckNsyms(OutPath('strip_save'), 7)
60 62
61 test.pass_test() 63 test.pass_test()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698