gyptest-strip-default.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/usr/bin/env python
  2. # Copyright (c) 2013 Google Inc. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """
  6. Verifies that the default STRIP_STYLEs match between different generators.
  7. """
  8. import TestGyp
  9. import re
  10. import subprocess
  11. import sys
  12. import time
  13. if sys.platform == 'darwin':
  14. test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
  15. CHDIR='strip'
  16. test.run_gyp('test-defaults.gyp', chdir=CHDIR)
  17. test.build('test-defaults.gyp', test.ALL, chdir=CHDIR)
  18. # Lightweight check if stripping was done.
  19. def OutPath(s):
  20. return test.built_file_path(s, chdir=CHDIR)
  21. def CheckNsyms(p, o_expected):
  22. proc = subprocess.Popen(['nm', '-aU', p], stdout=subprocess.PIPE)
  23. o = proc.communicate()[0]
  24. # Filter out mysterious "00 0000 OPT radr://5614542" symbol which
  25. # is apparently only printed on the bots (older toolchain?).
  26. # Yes, "radr", not "rdar".
  27. o = ''.join(filter(lambda s: 'radr://5614542' not in s, o.splitlines(True)))
  28. o = o.replace('A', 'T')
  29. o = re.sub(r'^[a-fA-F0-9]+', 'XXXXXXXX', o, flags=re.MULTILINE)
  30. assert not proc.returncode
  31. if o != o_expected:
  32. print 'Stripping: Expected symbols """\n%s""", got """\n%s"""' % (
  33. o_expected, o)
  34. test.fail_test()
  35. CheckNsyms(OutPath('libsingle_dylib.dylib'),
  36. """\
  37. XXXXXXXX S _ci
  38. XXXXXXXX S _i
  39. XXXXXXXX T _the_function
  40. XXXXXXXX t _the_hidden_function
  41. XXXXXXXX T _the_used_function
  42. XXXXXXXX T _the_visible_function
  43. """)
  44. CheckNsyms(OutPath('single_so.so'),
  45. """\
  46. XXXXXXXX S _ci
  47. XXXXXXXX S _i
  48. XXXXXXXX T _the_function
  49. XXXXXXXX t _the_hidden_function
  50. XXXXXXXX T _the_used_function
  51. XXXXXXXX T _the_visible_function
  52. """)
  53. CheckNsyms(OutPath('single_exe'),
  54. """\
  55. XXXXXXXX T __mh_execute_header
  56. """)
  57. CheckNsyms(test.built_file_path(
  58. 'bundle_dylib.framework/Versions/A/bundle_dylib', chdir=CHDIR),
  59. """\
  60. XXXXXXXX S _ci
  61. XXXXXXXX S _i
  62. XXXXXXXX T _the_function
  63. XXXXXXXX t _the_hidden_function
  64. XXXXXXXX T _the_used_function
  65. XXXXXXXX T _the_visible_function
  66. """)
  67. CheckNsyms(test.built_file_path(
  68. 'bundle_so.bundle/Contents/MacOS/bundle_so', chdir=CHDIR),
  69. """\
  70. XXXXXXXX S _ci
  71. XXXXXXXX S _i
  72. XXXXXXXX T _the_function
  73. XXXXXXXX T _the_used_function
  74. XXXXXXXX T _the_visible_function
  75. """)
  76. CheckNsyms(test.built_file_path(
  77. 'bundle_exe.app/Contents/MacOS/bundle_exe', chdir=CHDIR),
  78. """\
  79. XXXXXXXX T __mh_execute_header
  80. """)
  81. test.pass_test()