OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2013 Google Inc. All rights reserved. | 3 # Copyright (c) 2013 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 os | 13 import os |
14 import struct | 14 import struct |
15 import subprocess | 15 import subprocess |
16 import sys | 16 import sys |
17 import tempfile | 17 import tempfile |
18 | 18 |
19 | 19 |
20 def CheckFileType(file, expected): | 20 def CheckFileType(file, expected): |
21 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) | 21 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) |
22 o = proc.communicate()[0].strip() | 22 o = proc.communicate()[0].strip() |
23 assert not proc.returncode | 23 assert not proc.returncode |
24 if not expected in o: | 24 if not expected in o: |
25 print 'File: Expected %s, got %s' % (expected, o) | 25 print 'File: Expected %s, got %s' % (expected, o) |
26 test.fail_test() | 26 test.fail_test() |
27 | 27 |
28 | 28 |
| 29 def XcodeVersion(): |
| 30 xcode, build = GetStdout(['xcodebuild', '-version']).splitlines() |
| 31 xcode = xcode.split()[-1].replace('.', '') |
| 32 xcode = (xcode + '0' * (3 - len(xcode))).zfill(4) |
| 33 return xcode |
| 34 |
| 35 |
| 36 def GetStdout(cmdlist): |
| 37 proc = subprocess.Popen(cmdlist, stdout=subprocess.PIPE) |
| 38 o = proc.communicate()[0].strip() |
| 39 assert not proc.returncode |
| 40 return o |
| 41 |
| 42 |
29 if sys.platform == 'darwin': | 43 if sys.platform == 'darwin': |
30 test = TestGyp.TestGyp() | 44 test = TestGyp.TestGyp() |
31 | 45 |
32 test.run_gyp('test-archs.gyp', chdir='app-bundle') | 46 test.run_gyp('test-archs.gyp', chdir='app-bundle') |
33 test.set_configuration('Default') | 47 test.set_configuration('Default') |
34 test.build('test-archs.gyp', test.ALL, chdir='app-bundle') | |
35 | 48 |
36 for filename in ['Test No Archs', 'Test Archs i386', 'Test Archs x86_64']: | 49 # TODO(sdefresne): add 'Test Archs x86_64' once bots have been updated to |
| 50 # a SDK version that supports "x86_64" architecture. |
| 51 filenames = ['Test No Archs', 'Test Archs i386'] |
| 52 if XcodeVersion() >= '0500': |
| 53 filenames.append('Test Archs x86_64') |
| 54 |
| 55 for filename in filenames: |
| 56 target = filename.replace(' ', '_').lower() |
| 57 test.build('test-archs.gyp', target, chdir='app-bundle') |
37 result_file = test.built_file_path( | 58 result_file = test.built_file_path( |
38 '%s.bundle/%s' % (filename, filename), chdir='app-bundle') | 59 '%s.bundle/%s' % (filename, filename), chdir='app-bundle') |
39 test.must_exist(result_file) | 60 test.must_exist(result_file) |
40 | 61 |
41 expected = 'i386' | 62 expected = 'i386' |
42 if 'x86_64' in filename: | 63 if 'x86_64' in filename: |
43 expected = 'x86_64' | 64 expected = 'x86_64' |
44 CheckFileType(result_file, expected) | 65 CheckFileType(result_file, expected) |
45 | 66 |
46 test.pass_test() | 67 test.pass_test() |
OLD | NEW |