| 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 plistlib |
| 12 import TestGyp | 12 import TestGyp |
| 13 import subprocess | 13 import subprocess |
| 14 import sys | 14 import sys |
| 15 | 15 |
| 16 | 16 |
| 17 def CheckFileType(file, expected): | 17 def CheckFileType(file, expected): |
| 18 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) | 18 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) |
| 19 o = proc.communicate()[0].strip() | 19 o = proc.communicate()[0].strip() |
| 20 assert not proc.returncode | 20 assert not proc.returncode |
| 21 if not expected in o: | 21 if not expected in o: |
| 22 print 'File: Expected %s, got %s' % (expected, o) | 22 print 'File: Expected %s, got %s' % (expected, o) |
| 23 test.fail_test() | 23 test.fail_test() |
| 24 | 24 |
| 25 def CheckSignature(file): |
| 26 proc = subprocess.Popen(['codesign', '-v', file], stdout=subprocess.PIPE) |
| 27 o = proc.communicate()[0].strip() |
| 28 assert not proc.returncode |
| 29 if "code object is not signed at all" in o: |
| 30 print 'File %s not properly signed.' % (file) |
| 31 test.fail_test() |
| 25 | 32 |
| 26 def CheckPlistvalue(plist, key, expected): | 33 def CheckPlistvalue(plist, key, expected): |
| 27 if key not in plist: | 34 if key not in plist: |
| 28 print '%s not set in plist' % key | 35 print '%s not set in plist' % key |
| 29 test.fail_test() | 36 test.fail_test() |
| 30 return | 37 return |
| 31 actual = plist[key] | 38 actual = plist[key] |
| 32 if actual != expected: | 39 if actual != expected: |
| 33 print 'File: Expected %s, got %s for %s' % (expected, actual, key) | 40 print 'File: Expected %s, got %s for %s' % (expected, actual, key) |
| 34 test.fail_test() | 41 test.fail_test() |
| (...skipping 26 matching lines...) Expand all Loading... |
| 61 # plistlib doesn't support binary plists, but that's what Xcode creates. | 68 # plistlib doesn't support binary plists, but that's what Xcode creates. |
| 62 if test.format == 'xcode': | 69 if test.format == 'xcode': |
| 63 ConvertBinaryPlistToXML(info_plist) | 70 ConvertBinaryPlistToXML(info_plist) |
| 64 plist = plistlib.readPlist(info_plist) | 71 plist = plistlib.readPlist(info_plist) |
| 65 | 72 |
| 66 CheckPlistvalue(plist, 'UIDeviceFamily', [1, 2]) | 73 CheckPlistvalue(plist, 'UIDeviceFamily', [1, 2]) |
| 67 | 74 |
| 68 if configuration == 'Default-iphoneos': | 75 if configuration == 'Default-iphoneos': |
| 69 CheckFileType(result_file, 'armv7') | 76 CheckFileType(result_file, 'armv7') |
| 70 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneOS']) | 77 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneOS']) |
| 78 CheckSignature(result_file) |
| 71 else: | 79 else: |
| 72 CheckFileType(result_file, 'i386') | 80 CheckFileType(result_file, 'i386') |
| 73 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneSimulator']) | 81 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneSimulator']) |
| 74 | 82 |
| 75 test.pass_test() | 83 test.pass_test() |
| OLD | NEW |