OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 import unittest | 8 import unittest |
9 | 9 |
10 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 10 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 'glibc': '-I/sdk_root/include -I/sdk_root/include/glibc', | 46 'glibc': '-I/sdk_root/include -I/sdk_root/include/glibc', |
47 'pnacl': '-I/sdk_root/include -I/sdk_root/include/pnacl', | 47 'pnacl': '-I/sdk_root/include -I/sdk_root/include/pnacl', |
48 'win': '-I/sdk_root/include -I/sdk_root/include/win', | 48 'win': '-I/sdk_root/include -I/sdk_root/include/win', |
49 'mac': '-I/sdk_root/include -I/sdk_root/include/mac', | 49 'mac': '-I/sdk_root/include -I/sdk_root/include/mac', |
50 'linux': '-I/sdk_root/include -I/sdk_root/include/linux' | 50 'linux': '-I/sdk_root/include -I/sdk_root/include/linux' |
51 } | 51 } |
52 for toolchain, expected in cases.iteritems(): | 52 for toolchain, expected in cases.iteritems(): |
53 self.assertEqual(expected, nacl_config.GetCFlags(toolchain)) | 53 self.assertEqual(expected, nacl_config.GetCFlags(toolchain)) |
54 self.assertRaises(nacl_config.Error, nacl_config.GetCFlags, 'foo') | 54 self.assertRaises(nacl_config.Error, nacl_config.GetCFlags, 'foo') |
55 | 55 |
| 56 def testIncludeDirs(self): |
| 57 cases = { |
| 58 'newlib': '/sdk_root/include /sdk_root/include/newlib', |
| 59 'glibc': '/sdk_root/include /sdk_root/include/glibc', |
| 60 'pnacl': '/sdk_root/include /sdk_root/include/pnacl', |
| 61 'win': '/sdk_root/include /sdk_root/include/win', |
| 62 'mac': '/sdk_root/include /sdk_root/include/mac', |
| 63 'linux': '/sdk_root/include /sdk_root/include/linux' |
| 64 } |
| 65 for toolchain, expected in cases.iteritems(): |
| 66 self.assertEqual(expected, nacl_config.GetIncludeDirs(toolchain)) |
| 67 self.assertRaises(nacl_config.Error, nacl_config.GetIncludeDirs, 'foo') |
| 68 |
56 def testLDFlags(self): | 69 def testLDFlags(self): |
57 self.assertEqual('-L/sdk_root/lib', nacl_config.GetLDFlags()) | 70 self.assertEqual('-L/sdk_root/lib', nacl_config.GetLDFlags()) |
58 | 71 |
59 def _TestTool(self, tool, nacl_tool=None, pnacl_tool=None): | 72 def _TestTool(self, tool, nacl_tool=None, pnacl_tool=None): |
60 nacl_tool = nacl_tool or tool | 73 nacl_tool = nacl_tool or tool |
61 pnacl_tool = pnacl_tool or tool | 74 pnacl_tool = pnacl_tool or tool |
62 | 75 |
63 cases = { | 76 cases = { |
64 ('newlib', 'x86_32'): | 77 ('newlib', 'x86_32'): |
65 '/sdk_root/toolchain/mac_x86_newlib/bin/i686-nacl-%s' % nacl_tool, | 78 '/sdk_root/toolchain/mac_x86_newlib/bin/i686-nacl-%s' % nacl_tool, |
66 ('newlib', 'x86_64'): | 79 ('newlib', 'x86_64'): |
67 '/sdk_root/toolchain/mac_x86_newlib/bin/x86_64-nacl-%s' % nacl_tool, | 80 '/sdk_root/toolchain/mac_x86_newlib/bin/x86_64-nacl-%s' % nacl_tool, |
68 ('newlib', 'arm'): | 81 ('newlib', 'arm'): |
69 '/sdk_root/toolchain/mac_arm_newlib/bin/arm-nacl-%s' % nacl_tool, | 82 '/sdk_root/toolchain/mac_arm_newlib/bin/arm-nacl-%s' % nacl_tool, |
70 | 83 |
71 ('glibc', 'x86_32'): | 84 ('glibc', 'x86_32'): |
72 '/sdk_root/toolchain/mac_x86_glibc/bin/i686-nacl-%s' % nacl_tool, | 85 '/sdk_root/toolchain/mac_x86_glibc/bin/i686-nacl-%s' % nacl_tool, |
73 ('glibc', 'x86_64'): | 86 ('glibc', 'x86_64'): |
74 '/sdk_root/toolchain/mac_x86_glibc/bin/x86_64-nacl-%s' % nacl_tool, | 87 '/sdk_root/toolchain/mac_x86_glibc/bin/x86_64-nacl-%s' % nacl_tool, |
75 ('glibc', 'arm'): | |
76 '/sdk_root/toolchain/mac_arm_glibc/bin/arm-nacl-%s' % nacl_tool, | |
77 | 88 |
78 'pnacl': '/sdk_root/toolchain/mac_pnacl/bin/pnacl-%s' % pnacl_tool, | 89 'pnacl': '/sdk_root/toolchain/mac_pnacl/bin/pnacl-%s' % pnacl_tool, |
79 } | 90 } |
80 | 91 |
81 for tc_arch, expected in cases.iteritems(): | 92 for tc_arch, expected in cases.iteritems(): |
82 if isinstance(tc_arch, tuple): | 93 if isinstance(tc_arch, tuple): |
83 toolchain = tc_arch[0] | 94 toolchain = tc_arch[0] |
84 arch = tc_arch[1] | 95 arch = tc_arch[1] |
85 else: | 96 else: |
86 toolchain = tc_arch | 97 toolchain = tc_arch |
87 arch = None | 98 arch = None |
88 self.assertEqual(expected, nacl_config.GetToolPath(toolchain, arch, tool)) | 99 self.assertEqual(expected, nacl_config.GetToolPath(toolchain, arch, tool)) |
89 | 100 |
90 for toolchain in ('host', 'mac', 'win', 'linux'): | 101 for toolchain in ('host', 'mac', 'win', 'linux'): |
91 self.assertRaises(nacl_config.Error, | 102 self.assertRaises(nacl_config.Error, |
92 nacl_config.GetToolPath, toolchain, None, tool) | 103 nacl_config.GetToolPath, toolchain, None, tool) |
93 | 104 |
| 105 # No arm glibc. |
| 106 self.assertRaises(nacl_config.Error, |
| 107 nacl_config.GetToolPath, 'glibc', 'arm', tool) |
| 108 |
94 def testCC(self): | 109 def testCC(self): |
95 self._TestTool('cc', 'gcc', 'clang') | 110 self._TestTool('cc', 'gcc', 'clang') |
96 | 111 |
97 def testCXX(self): | 112 def testCXX(self): |
98 self._TestTool('c++', 'g++', 'clang++') | 113 self._TestTool('c++', 'g++', 'clang++') |
99 | 114 |
100 def testLD(self): | 115 def testLD(self): |
101 self._TestTool('ld', 'g++', 'clang++') | 116 self._TestTool('ld', 'g++', 'clang++') |
102 | 117 |
103 def testStandardTool(self): | 118 def testStandardTool(self): |
104 for tool in ('nm', 'strip', 'ar', 'ranlib'): | 119 for tool in ('nm', 'strip', 'ar', 'ranlib'): |
105 self._TestTool(tool) | 120 self._TestTool(tool) |
106 | 121 |
107 def testGDB(self): | 122 def testGDB(self): |
108 # We always use the same gdb (it supports multiple toolchains/architectures) | 123 # We always use the same gdb (it supports multiple toolchains/architectures) |
109 expected = '/sdk_root/toolchain/mac_x86_newlib/bin/x86_64-nacl-gdb' | 124 expected = '/sdk_root/toolchain/mac_x86_newlib/bin/x86_64-nacl-gdb' |
110 for toolchain in ('newlib', 'glibc', 'pnacl'): | 125 for toolchain in ('newlib', 'glibc', 'pnacl'): |
111 for arch in ('x86_32', 'x86_64', 'arm'): | 126 for arch in ('x86_32', 'x86_64', 'arm'): |
112 self.assertEqual(expected, | 127 self.assertEqual(expected, |
113 nacl_config.GetToolPath(toolchain, arch, 'gdb')) | 128 nacl_config.GetToolPath(toolchain, arch, 'gdb')) |
114 | 129 |
115 | 130 |
116 | |
117 if __name__ == '__main__': | 131 if __name__ == '__main__': |
118 unittest.main() | 132 unittest.main() |
OLD | NEW |