Home | History | Annotate | Download | only in ios
      1 #!/usr/bin/env python
      2 
      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
      5 # found in the LICENSE file.
      6 
      7 """
      8 Verifies that device and simulator bundles are built correctly.
      9 """
     10 
     11 import plistlib
     12 import TestGyp
     13 import os
     14 import struct
     15 import subprocess
     16 import sys
     17 import tempfile
     18 
     19 
     20 def CheckFileType(file, expected):
     21   proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE)
     22   o = proc.communicate()[0].strip()
     23   assert not proc.returncode
     24   if not expected in o:
     25     print 'File: Expected %s, got %s' % (expected, o)
     26     test.fail_test()
     27 
     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 
     43 if sys.platform == 'darwin':
     44   test = TestGyp.TestGyp()
     45 
     46   test.run_gyp('test-archs.gyp', chdir='app-bundle')
     47   test.set_configuration('Default')
     48 
     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')
     58     result_file = test.built_file_path(
     59         '%s.bundle/%s' % (filename, filename), chdir='app-bundle')
     60     test.must_exist(result_file)
     61 
     62     expected = 'i386'
     63     if 'x86_64' in filename:
     64       expected = 'x86_64'
     65       CheckFileType(result_file, expected)
     66 
     67   test.pass_test()
     68