Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: test/ios/gyptest-per-config-settings.py

Issue 26895006: ninja/mac: Support iOS codesign for ninja builds. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/ios/app-bundle/test-device.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 HasCerts():
26 # Because the bots do not have certs, don't check them if there are no
27 # certs available.
28 proc = subprocess.Popen(['security','find-identity','-p', 'codesigning',
29 '-v'], stdout=subprocess.PIPE)
30 return "0 valid identities found" not in proc.communicate()[0].strip()
31
32 def CheckSignature(file):
33 proc = subprocess.Popen(['codesign', '-v', file], stdout=subprocess.PIPE)
34 o = proc.communicate()[0].strip()
35 assert not proc.returncode
36 if "code object is not signed at all" in o:
37 print 'File %s not properly signed.' % (file)
38 test.fail_test()
25 39
26 def CheckPlistvalue(plist, key, expected): 40 def CheckPlistvalue(plist, key, expected):
27 if key not in plist: 41 if key not in plist:
28 print '%s not set in plist' % key 42 print '%s not set in plist' % key
29 test.fail_test() 43 test.fail_test()
30 return 44 return
31 actual = plist[key] 45 actual = plist[key]
32 if actual != expected: 46 if actual != expected:
33 print 'File: Expected %s, got %s for %s' % (expected, actual, key) 47 print 'File: Expected %s, got %s for %s' % (expected, actual, key)
34 test.fail_test() 48 test.fail_test()
35 49
36 def ConvertBinaryPlistToXML(path): 50 def ConvertBinaryPlistToXML(path):
37 proc = subprocess.call(['plutil', '-convert', 'xml1', path], 51 proc = subprocess.call(['plutil', '-convert', 'xml1', path],
38 stdout=subprocess.PIPE) 52 stdout=subprocess.PIPE)
39 53
40 if sys.platform == 'darwin': 54 if sys.platform == 'darwin':
41 test = TestGyp.TestGyp(formats=['ninja', 'xcode']) 55 test = TestGyp.TestGyp(formats=['ninja', 'xcode'])
42 56
43 test.run_gyp('test-device.gyp', chdir='app-bundle') 57 test.run_gyp('test-device.gyp', chdir='app-bundle')
44 58
45 test_configs = ['Default-iphoneos', 'Default'] 59 test_configs = ['Default-iphoneos', 'Default']
46 # TODO(justincohen): Disabling 'Default-iphoneos' for xcode until bots are 60 # TODO(justincohen): Disabling 'Default-iphoneos' for xcode until bots are
47 # configured with signing certs. 61 # configured with signing certs.
48 if test.format == 'xcode': 62 if test.format == 'xcode':
49 test_configs.remove('Default-iphoneos') 63 test_configs.remove('Default-iphoneos')
50 64
51 for configuration in test_configs: 65 for configuration in test_configs:
52 test.set_configuration(configuration) 66 test.set_configuration(configuration)
53 test.build('test-device.gyp', test.ALL, chdir='app-bundle') 67 test.build('test-device.gyp', 'test_app', chdir='app-bundle')
54 result_file = test.built_file_path('Test App Gyp.bundle/Test App Gyp', 68 result_file = test.built_file_path('Test App Gyp.bundle/Test App Gyp',
55 chdir='app-bundle') 69 chdir='app-bundle')
56 test.must_exist(result_file) 70 test.must_exist(result_file)
57 71
58 info_plist = test.built_file_path('Test App Gyp.bundle/Info.plist', 72 info_plist = test.built_file_path('Test App Gyp.bundle/Info.plist',
59 chdir='app-bundle') 73 chdir='app-bundle')
60 74
61 # plistlib doesn't support binary plists, but that's what Xcode creates. 75 # plistlib doesn't support binary plists, but that's what Xcode creates.
62 if test.format == 'xcode': 76 if test.format == 'xcode':
63 ConvertBinaryPlistToXML(info_plist) 77 ConvertBinaryPlistToXML(info_plist)
64 plist = plistlib.readPlist(info_plist) 78 plist = plistlib.readPlist(info_plist)
65 79
66 CheckPlistvalue(plist, 'UIDeviceFamily', [1, 2]) 80 CheckPlistvalue(plist, 'UIDeviceFamily', [1, 2])
67 81
68 if configuration == 'Default-iphoneos': 82 if configuration == 'Default-iphoneos':
69 CheckFileType(result_file, 'armv7') 83 CheckFileType(result_file, 'armv7')
70 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneOS']) 84 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneOS'])
71 else: 85 else:
72 CheckFileType(result_file, 'i386') 86 CheckFileType(result_file, 'i386')
73 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneSimulator']) 87 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneSimulator'])
74 88
89 if HasCerts() and configuration == 'Default-iphoneos':
90 test.build('test-device.gyp', 'sig_test', chdir='app-bundle')
91 result_file = test.built_file_path('sig_test.bundle/sig_test',
92 chdir='app-bundle')
93 CheckSignature(result_file)
94 info_plist = test.built_file_path('sig_test.bundle/Info.plist',
95 chdir='app-bundle')
96
97 plist = plistlib.readPlist(info_plist)
98 CheckPlistvalue(plist, 'UIDeviceFamily', [1])
99
75 test.pass_test() 100 test.pass_test()
OLDNEW
« no previous file with comments | « test/ios/app-bundle/test-device.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698