OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 Google Inc. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 Tests that a loadable_module target is built correctly. | 8 Tests that a loadable_module target is built correctly. |
9 """ | 9 """ |
10 | 10 |
11 import TestGyp | 11 import TestGyp |
12 | 12 |
13 import os | 13 import os |
| 14 import struct |
14 import sys | 15 import sys |
15 | 16 |
16 if sys.platform == 'darwin': | 17 if sys.platform == 'darwin': |
17 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) | 18 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) |
18 | 19 |
19 test.run_gyp('test.gyp', chdir='loadable-module') | 20 CHDIR = 'loadable-module' |
20 test.build('test.gyp', test.ALL, chdir='loadable-module') | 21 test.run_gyp('test.gyp', chdir=CHDIR) |
| 22 test.build('test.gyp', test.ALL, chdir=CHDIR) |
21 | 23 |
22 # Binary. | 24 # Binary. |
23 test.built_file_must_exist( | 25 binary = test.built_file_path( |
24 'test_loadable_module.plugin/Contents/MacOS/test_loadable_module', | 26 'test_loadable_module.plugin/Contents/MacOS/test_loadable_module', |
25 chdir='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() |
26 | 32 |
27 # Info.plist. | 33 # Info.plist. |
28 info_plist = test.built_file_path( | 34 info_plist = test.built_file_path( |
29 'test_loadable_module.plugin/Contents/Info.plist', | 35 'test_loadable_module.plugin/Contents/Info.plist', chdir=CHDIR) |
30 chdir='loadable-module') | |
31 test.must_exist(info_plist) | 36 test.must_exist(info_plist) |
32 test.must_contain(info_plist, """ | 37 test.must_contain(info_plist, """ |
33 <key>CFBundleExecutable</key> | 38 <key>CFBundleExecutable</key> |
34 <string>test_loadable_module</string> | 39 <string>test_loadable_module</string> |
35 """) | 40 """) |
36 | 41 |
37 # PkgInfo. | 42 # PkgInfo. |
38 test.built_file_must_not_exist( | 43 test.built_file_must_not_exist( |
39 'test_loadable_module.plugin/Contents/PkgInfo', | 44 'test_loadable_module.plugin/Contents/PkgInfo', chdir=CHDIR) |
40 chdir='loadable-module') | |
41 test.built_file_must_not_exist( | 45 test.built_file_must_not_exist( |
42 'test_loadable_module.plugin/Contents/Resources', | 46 'test_loadable_module.plugin/Contents/Resources', chdir=CHDIR) |
43 chdir='loadable-module') | |
44 | 47 |
45 test.pass_test() | 48 test.pass_test() |
OLD | NEW |