Home | History | Annotate | Download | only in mac
      1 #!/usr/bin/env python
      2 
      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
      5 # found in the LICENSE file.
      6 
      7 """
      8 Tests that a loadable_module target is built correctly.
      9 """
     10 
     11 import TestGyp
     12 
     13 import os
     14 import struct
     15 import sys
     16 
     17 if sys.platform == 'darwin':
     18   test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
     19 
     20   CHDIR = 'loadable-module'
     21   test.run_gyp('test.gyp', chdir=CHDIR)
     22   test.build('test.gyp', test.ALL, chdir=CHDIR)
     23 
     24   # Binary.
     25   binary = test.built_file_path(
     26       'test_loadable_module.plugin/Contents/MacOS/test_loadable_module',
     27       chdir=CHDIR)
     28   test.must_exist(binary)
     29   MH_BUNDLE = 8
     30   if struct.unpack('4I', open(binary, 'rb').read(16))[3] != MH_BUNDLE:
     31     test.fail_test()
     32 
     33   # Info.plist.
     34   info_plist = test.built_file_path(
     35       'test_loadable_module.plugin/Contents/Info.plist', chdir=CHDIR)
     36   test.must_exist(info_plist)
     37   test.must_contain(info_plist, """
     38 	<key>CFBundleExecutable</key>
     39 	<string>test_loadable_module</string>
     40 """)
     41 
     42   # PkgInfo.
     43   test.built_file_must_not_exist(
     44       'test_loadable_module.plugin/Contents/PkgInfo', chdir=CHDIR)
     45   test.built_file_must_not_exist(
     46       'test_loadable_module.plugin/Contents/Resources', chdir=CHDIR)
     47 
     48   test.pass_test()
     49