gyptest-loadable-module.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 that a loadable_module target is built correctly.
  7. """
  8. import TestGyp
  9. import os
  10. import struct
  11. import sys
  12. if sys.platform == 'darwin':
  13. test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
  14. CHDIR = 'loadable-module'
  15. test.run_gyp('test.gyp', chdir=CHDIR)
  16. test.build('test.gyp', test.ALL, chdir=CHDIR)
  17. # Binary.
  18. binary = test.built_file_path(
  19. 'test_loadable_module.plugin/Contents/MacOS/test_loadable_module',
  20. chdir=CHDIR)
  21. test.must_exist(binary)
  22. MH_BUNDLE = 8
  23. if struct.unpack('4I', open(binary, 'rb').read(16))[3] != MH_BUNDLE:
  24. test.fail_test()
  25. # Info.plist.
  26. info_plist = test.built_file_path(
  27. 'test_loadable_module.plugin/Contents/Info.plist', chdir=CHDIR)
  28. test.must_exist(info_plist)
  29. test.must_contain(info_plist, """
  30. <key>CFBundleExecutable</key>
  31. <string>test_loadable_module</string>
  32. """)
  33. # PkgInfo.
  34. test.built_file_must_not_exist(
  35. 'test_loadable_module.plugin/Contents/PkgInfo', chdir=CHDIR)
  36. test.built_file_must_not_exist(
  37. 'test_loadable_module.plugin/Contents/Resources', chdir=CHDIR)
  38. test.pass_test()