Chromium Code Reviews| Index: test/ios/gyptest-archs.py |
| diff --git a/test/ios/gyptest-archs.py b/test/ios/gyptest-archs.py |
| index 87d0657db512379d6a3f1961ae2b49131be63d9c..ae4bd44aa396c806abbc95f5a4d8fc02f30e8613 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,48 @@ 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', 'Test No Archs', ['i386']), |
| + ('Default', 'Test Arch 32-bits', ['i386']), |
| + ('Default', 'Test Arch 64-bits', ['x86_64']), |
| + ('Default', 'Test Multi Archs', ['i386', 'x86_64']), |
| + ('Default-iphoneos', 'Test No Archs', ['armv7']), |
| + ('Default-iphoneos', 'Test Arch 32-bits', ['armv7']), |
| + ('Default-iphoneos', 'Test Arch 64-bits', ['arm64']), |
| + ('Default-iphoneos', 'Test Multi Archs', ['armv7', 'arm64']), |
| + ] |
| + |
| + xcode_version = XcodeVersion() |
| + test.run_gyp('test-archs.gyp', chdir='app-bundle') |
| + for configuration, name, 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) |
| + product = name.replace(' ', '') |
|
justincohen
2014/02/10 21:41:33
Why not just rename the products to not have space
sdefresne
2014/02/11 16:30:45
Done.
|
| + filename = '%s.bundle/%s' % (product, product) |
| + target = name.replace(' ', '_').replace('-', '_').lower() |
| + 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() |