Index: test/ios/gyptest-archs.py |
diff --git a/test/ios/gyptest-archs.py b/test/ios/gyptest-archs.py |
index 87d0657db512379d6a3f1961ae2b49131be63d9c..8afda18eb64df26d199d89d2fbb32df17f5da90f 100644 |
--- a/test/ios/gyptest-archs.py |
+++ b/test/ios/gyptest-archs.py |
@@ -8,22 +8,41 @@ |
Verifies that device and simulator bundles are built correctly. |
""" |
+import collections |
import plistlib |
import TestGyp |
import os |
+import re |
import struct |
import subprocess |
import sys |
import tempfile |
-def CheckFileType(file, expected): |
+def BuildExpected(file, archs): |
+ if len(archs) == 1: |
+ return 'Non-fat file: %s is architecture: %s' % (file, archs[0]) |
+ return 'Architectures in the fat file: %s are: %s' % (file, ' '.join(archs)) |
+ |
+ |
+def CheckFileType(test, file, archs): |
proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) |
o = proc.communicate()[0].strip() |
assert not proc.returncode |
- if not expected in o: |
- print 'File: Expected %s, got %s' % (expected, o) |
+ if len(archs) == 1: |
+ pattern = re.compile('^Non-fat file: (.*) is architecture: (.*)$') |
+ else: |
+ pattern = re.compile('^Architectures in the fat file: (.*) are: (.*)$') |
+ match = pattern.match(o) |
+ if match is None: |
+ print 'Ouput does not match expected pattern: %s' % (pattern.pattern) |
test.fail_test() |
+ else: |
+ found_file, found_archs = match.groups() |
+ if found_file != file or set(found_archs.split()) != set(archs): |
+ print 'Expected file %s with arch %s, got %s with arch %s' % ( |
+ file, ' '.join(archs), found_file, ' '.join(found_archs)) |
+ test.fail_test() |
def XcodeVersion(): |
@@ -42,26 +61,46 @@ def GetStdout(cmdlist): |
if sys.platform == 'darwin': |
test = TestGyp.TestGyp() |
- |
- test.run_gyp('test-archs.gyp', chdir='app-bundle') |
- test.set_configuration('Default') |
- |
- # TODO(sdefresne): add 'Test Archs x86_64' once bots have been updated to |
- # a SDK version that supports "x86_64" architecture. |
- filenames = ['Test No Archs', 'Test Archs i386'] |
- if XcodeVersion() >= '0500': |
- filenames.append('Test Archs x86_64') |
- |
- for filename in filenames: |
- target = filename.replace(' ', '_').lower() |
- test.build('test-archs.gyp', target, chdir='app-bundle') |
- result_file = test.built_file_path( |
- '%s.bundle/%s' % (filename, filename), chdir='app-bundle') |
- test.must_exist(result_file) |
- |
- expected = 'i386' |
- if 'x86_64' in filename: |
- expected = 'x86_64' |
- CheckFileType(result_file, expected) |
- |
- test.pass_test() |
+ if test.format == 'ninja' or test.format == 'xcode': |
+ test_cases = [ |
+ ('Default', 'TestNoArchs', ['i386']), |
+ ('Default', 'TestArch32Bits', ['i386']), |
+ ('Default', 'TestArch64Bits', ['x86_64']), |
+ ('Default', 'TestMultiArchs', ['i386', 'x86_64']), |
+ ('Default-iphoneos', 'TestNoArchs', ['armv7']), |
+ ('Default-iphoneos', 'TestArch32Bits', ['armv7']), |
+ ('Default-iphoneos', 'TestArch64Bits', ['arm64']), |
+ ('Default-iphoneos', 'TestMultiArchs', ['armv7', 'arm64']), |
+ ] |
+ |
+ xcode_version = XcodeVersion() |
+ test.run_gyp('test-archs.gyp', chdir='app-bundle') |
+ for configuration, target, archs in test_cases: |
+ is_64_bit_build = ('arm64' in archs or 'x86_64' in archs) |
+ is_device_build = configuration.endswith('-iphoneos') |
+ |
+ kwds = collections.defaultdict(list) |
+ if test.format == 'xcode' and is_device_build: |
+ configuration, sdk = configuration.split('-') |
+ kwds['arguments'].extend(['-sdk', sdk]) |
+ |
+ # TODO(sdefresne): remove those special-cases once the bots have been |
+ # updated to use a more recent version of Xcode. |
+ if xcode_version < '0500': |
+ if is_64_bit_build: |
+ continue |
+ if test.format == 'xcode': |
+ arch = 'i386' |
+ if is_device_build: |
+ arch = 'armv7' |
+ kwds['arguments'].extend(['-arch', arch]) |
+ |
+ test.set_configuration(configuration) |
+ filename = '%s.bundle/%s' % (target, target) |
+ test.build('test-archs.gyp', target, chdir='app-bundle', **kwds) |
+ result_file = test.built_file_path(filename, chdir='app-bundle') |
+ |
+ test.must_exist(result_file) |
+ CheckFileType(test, result_file, archs) |
+ |
+ test.pass_test() |