29
30
def CheckNsyms(p, n_expected):
30
31
r = re.compile(r'nsyms\s+(\d+)')
31
proc = subprocess.Popen(['otool', '-l', p], stdout=subprocess.PIPE)
32
o = proc.communicate()[0]
33
assert not proc.returncode
32
o = subprocess.check_output(['otool', '-l', p])
35
34
n = int(m.group(1))
36
35
if n != n_expected:
37
36
print 'Stripping: Expected %d symbols, got %d' % (n_expected, n)
39
# 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
41
# with Xcode 5.0 or higher, take this additional symbol into consideration
42
# for unstripped builds (it is stripped by all strip commands).
43
expected_extra_symbol_count = 0
44
if test.format in ['ninja', 'xcode-ninja'] \
45
and TestMac.Xcode.Version() >= '0500':
46
expected_extra_symbol_count = 1
40
48
# The actual numbers here are not interesting, they just need to be the same
41
49
# in both the xcode and the make build.
42
CheckNsyms(OutPath('no_postprocess'), 10)
43
CheckNsyms(OutPath('no_strip'), 10)
50
CheckNsyms(OutPath('no_postprocess'), 29 + expected_extra_symbol_count)
51
CheckNsyms(OutPath('no_strip'), 29 + expected_extra_symbol_count)
44
52
CheckNsyms(OutPath('strip_all'), 0)
45
CheckNsyms(OutPath('strip_nonglobal'), 2)
46
CheckNsyms(OutPath('strip_debugging'), 2)
53
CheckNsyms(OutPath('strip_nonglobal'), 6)
54
CheckNsyms(OutPath('strip_debugging'), 7)
47
55
CheckNsyms(OutPath('strip_all_custom_flags'), 0)
48
56
CheckNsyms(test.built_file_path(
49
57
'strip_all_bundle.framework/Versions/A/strip_all_bundle', chdir='strip'),
51
CheckNsyms(OutPath('strip_save'), 2)
59
CheckNsyms(OutPath('strip_save'), 7)