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 Verifies that device and simulator bundles are built correctly. | 8 Verifies that device and simulator bundles are built correctly. |
9 """ | 9 """ |
10 | 10 |
| 11 import plistlib |
11 import TestGyp | 12 import TestGyp |
12 import subprocess | 13 import subprocess |
13 import sys | 14 import sys |
14 | 15 |
15 | 16 |
16 def CheckFileType(file, expected): | 17 def CheckFileType(file, expected): |
17 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) | 18 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) |
18 o = proc.communicate()[0].strip() | 19 o = proc.communicate()[0].strip() |
19 assert not proc.returncode | 20 assert not proc.returncode |
20 if not expected in o: | 21 if not expected in o: |
21 print 'File: Expected %s, got %s' % (expected, o) | 22 print 'File: Expected %s, got %s' % (expected, o) |
22 test.fail_test() | 23 test.fail_test() |
23 | 24 |
24 | 25 |
| 26 def CheckPlistvalue(plist, key, expected): |
| 27 if key not in plist: |
| 28 print '%s not set in plist' % key |
| 29 test.fail_test() |
| 30 return |
| 31 actual = plist[key] |
| 32 if actual != expected: |
| 33 print 'File: Expected %s, got %s for %s' % (expected, actual, key) |
| 34 test.fail_test() |
| 35 |
| 36 def ConvertBinaryPlistToXML(path): |
| 37 proc = subprocess.call(['plutil', '-convert', 'xml1', path], |
| 38 stdout=subprocess.PIPE) |
| 39 |
25 if sys.platform == 'darwin': | 40 if sys.platform == 'darwin': |
26 # TODO(justincohen): Enable this in xcode too once ninja can codesign and bots | 41 test = TestGyp.TestGyp(formats=['ninja', 'xcode']) |
27 # are configured with signing certs. | |
28 test = TestGyp.TestGyp(formats=['ninja']) | |
29 | 42 |
30 test.run_gyp('test-device.gyp', chdir='app-bundle') | 43 test.run_gyp('test-device.gyp', chdir='app-bundle') |
31 | 44 |
32 for configuration in ['Default-iphoneos', 'Default']: | 45 test_configs = ['Default-iphoneos', 'Default'] |
| 46 # TODO(justincohen): Disabling 'Default-iphoneos' for xcode until bots are |
| 47 # configured with signing certs. |
| 48 if test.format == 'xcode': |
| 49 test_configs.remove('Default-iphoneos') |
| 50 |
| 51 for configuration in test_configs: |
33 test.set_configuration(configuration) | 52 test.set_configuration(configuration) |
34 test.build('test-device.gyp', test.ALL, chdir='app-bundle') | 53 test.build('test-device.gyp', test.ALL, chdir='app-bundle') |
35 result_file = test.built_file_path('Test App Gyp.bundle/Test App Gyp', | 54 result_file = test.built_file_path('Test App Gyp.bundle/Test App Gyp', |
36 chdir='app-bundle') | 55 chdir='app-bundle') |
37 test.must_exist(result_file) | 56 test.must_exist(result_file) |
| 57 |
| 58 info_plist = test.built_file_path('Test App Gyp.bundle/Info.plist', |
| 59 chdir='app-bundle') |
| 60 |
| 61 # plistlib doesn't support binary plists, but that's what Xcode creates. |
| 62 if test.format == 'xcode': |
| 63 ConvertBinaryPlistToXML(info_plist) |
| 64 plist = plistlib.readPlist(info_plist) |
| 65 |
| 66 CheckPlistvalue(plist, 'UIDeviceFamily', [1, 2]) |
| 67 |
38 if configuration == 'Default-iphoneos': | 68 if configuration == 'Default-iphoneos': |
39 CheckFileType(result_file, 'armv7') | 69 CheckFileType(result_file, 'armv7') |
| 70 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneOS']) |
40 else: | 71 else: |
41 CheckFileType(result_file, 'i386') | 72 CheckFileType(result_file, 'i386') |
| 73 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneSimulator']) |
42 | 74 |
43 test.pass_test() | 75 test.pass_test() |
OLD | NEW |