gyptest-archs.py 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/usr/bin/env python
  2. # Copyright (c) 2012 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. Tests things related to ARCHS.
  7. """
  8. import TestGyp
  9. import TestMac
  10. import re
  11. import subprocess
  12. import sys
  13. if sys.platform == 'darwin':
  14. test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
  15. test.run_gyp('test-no-archs.gyp', chdir='archs')
  16. test.build('test-no-archs.gyp', test.ALL, chdir='archs')
  17. result_file = test.built_file_path('Test', chdir='archs')
  18. test.must_exist(result_file)
  19. if TestMac.Xcode.Version() >= '0500':
  20. expected_type = ['x86_64']
  21. else:
  22. expected_type = ['i386']
  23. TestMac.CheckFileType(test, result_file, expected_type)
  24. test.run_gyp('test-valid-archs.gyp', chdir='archs')
  25. test.build('test-valid-archs.gyp', test.ALL, chdir='archs')
  26. result_file = test.built_file_path('Test', chdir='archs')
  27. test.must_exist(result_file)
  28. TestMac.CheckFileType(test, result_file, ['x86_64'])
  29. test.run_gyp('test-archs-x86_64.gyp', chdir='archs')
  30. test.build('test-archs-x86_64.gyp', test.ALL, chdir='archs')
  31. result_file = test.built_file_path('Test64', chdir='archs')
  32. test.must_exist(result_file)
  33. TestMac.CheckFileType(test, result_file, ['x86_64'])
  34. test.run_gyp('test-dependencies.gyp', chdir='archs')
  35. test.build('test-dependencies.gyp', target=test.ALL, chdir='archs')
  36. products = ['c_standalone', 'd_standalone']
  37. for product in products:
  38. result_file = test.built_file_path(
  39. product, chdir='archs', type=test.STATIC_LIB)
  40. test.must_exist(result_file)
  41. if test.format != 'make':
  42. # Build all targets except 'exe_32_64_no_sources' that does build
  43. # but should not cause error when generating ninja files
  44. targets = [
  45. 'static_32_64', 'shared_32_64', 'shared_32_64_bundle',
  46. 'module_32_64', 'module_32_64_bundle',
  47. 'exe_32_64', 'exe_32_64_bundle', 'precompiled_prefix_header_mm_32_64',
  48. ]
  49. test.run_gyp('test-archs-multiarch.gyp', chdir='archs')
  50. for target in targets:
  51. test.build('test-archs-multiarch.gyp', target=target, chdir='archs')
  52. result_file = test.built_file_path(
  53. 'static_32_64', chdir='archs', type=test.STATIC_LIB)
  54. test.must_exist(result_file)
  55. TestMac.CheckFileType(test, result_file, ['i386', 'x86_64'])
  56. result_file = test.built_file_path(
  57. 'shared_32_64', chdir='archs', type=test.SHARED_LIB)
  58. test.must_exist(result_file)
  59. TestMac.CheckFileType(test, result_file, ['i386', 'x86_64'])
  60. result_file = test.built_file_path('My Framework.framework/My Framework',
  61. chdir='archs')
  62. test.must_exist(result_file)
  63. TestMac.CheckFileType(test, result_file, ['i386', 'x86_64'])
  64. # Check that symbol "_x" made it into both versions of the binary:
  65. if not all(['D _x' in subprocess.check_output(
  66. ['nm', '-arch', arch, result_file]) for arch in ['i386', 'x86_64']]):
  67. # This can only flakily fail, due to process ordering issues. If this
  68. # does fail flakily, then something's broken, it's not the test at fault.
  69. test.fail_test()
  70. result_file = test.built_file_path(
  71. 'exe_32_64', chdir='archs', type=test.EXECUTABLE)
  72. test.must_exist(result_file)
  73. TestMac.CheckFileType(test, result_file, ['i386', 'x86_64'])
  74. result_file = test.built_file_path('Test App.app/Contents/MacOS/Test App',
  75. chdir='archs')
  76. test.must_exist(result_file)
  77. TestMac.CheckFileType(test, result_file, ['i386', 'x86_64'])