Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / tools / gyp / test / mac / gyptest-archs.py
1 #!/usr/bin/env python
2
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
5 # found in the LICENSE file.
6
7 """
8 Tests things related to ARCHS.
9 """
10
11 import TestGyp
12 import TestMac
13
14 import re
15 import subprocess
16 import sys
17
18 if sys.platform == 'darwin':
19   test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
20
21   test.run_gyp('test-no-archs.gyp', chdir='archs')
22   test.build('test-no-archs.gyp', test.ALL, chdir='archs')
23   result_file = test.built_file_path('Test', chdir='archs')
24   test.must_exist(result_file)
25
26   if TestMac.Xcode.Version() >= '0500':
27     expected_type = ['x86_64']
28   else:
29     expected_type = ['i386']
30   TestMac.CheckFileType(test, result_file, expected_type)
31
32   test.run_gyp('test-archs-x86_64.gyp', chdir='archs')
33   test.build('test-archs-x86_64.gyp', test.ALL, chdir='archs')
34   result_file = test.built_file_path('Test64', chdir='archs')
35   test.must_exist(result_file)
36   TestMac.CheckFileType(test, result_file, ['x86_64'])
37
38   if test.format != 'make':
39     # Build all targets except 'exe_32_64_no_sources' that does build
40     # but should not cause error when generating ninja files
41     targets = [
42         'static_32_64', 'shared_32_64', 'shared_32_64_bundle',
43         'module_32_64', 'module_32_64_bundle',
44         'exe_32_64', 'exe_32_64_bundle', 'precompiled_prefix_header_mm_32_64',
45     ]
46
47     test.run_gyp('test-archs-multiarch.gyp', chdir='archs')
48     for target in targets:
49       test.build('test-archs-multiarch.gyp', target=target, chdir='archs')
50
51     result_file = test.built_file_path(
52         'static_32_64', chdir='archs', type=test.STATIC_LIB)
53     test.must_exist(result_file)
54     TestMac.CheckFileType(test, result_file, ['i386', 'x86_64'])
55
56     result_file = test.built_file_path(
57         'shared_32_64', chdir='archs', type=test.SHARED_LIB)
58     test.must_exist(result_file)
59     TestMac.CheckFileType(test, result_file, ['i386', 'x86_64'])
60
61     result_file = test.built_file_path('My Framework.framework/My Framework',
62                                        chdir='archs')
63     test.must_exist(result_file)
64     TestMac.CheckFileType(test, result_file, ['i386', 'x86_64'])
65     # Check that symbol "_x" made it into both versions of the binary:
66     if not all(['D _x' in subprocess.check_output(
67         ['nm', '-arch', arch, result_file]) for arch in ['i386', 'x86_64']]):
68       # This can only flakily fail, due to process ordering issues. If this
69       # does fail flakily, then something's broken, it's not the test at fault.
70       test.fail_test()
71
72     result_file = test.built_file_path(
73         'exe_32_64', chdir='archs', type=test.EXECUTABLE)
74     test.must_exist(result_file)
75     TestMac.CheckFileType(test, result_file, ['i386', 'x86_64'])
76
77     result_file = test.built_file_path('Test App.app/Contents/MacOS/Test App',
78                                        chdir='archs')
79     test.must_exist(result_file)
80     TestMac.CheckFileType(test, result_file, ['i386', 'x86_64'])