| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 '/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, |
| 81 ('newlib', 'arm'): | 81 ('newlib', 'arm'): |
| 82 '/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, |
| 83 | 83 |
| 84 ('glibc', 'x86_32'): | 84 ('glibc', 'x86_32'): |
| 85 '/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, |
| 86 ('glibc', 'x86_64'): | 86 ('glibc', 'x86_64'): |
| 87 '/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, |
| 88 | 88 |
| 89 'pnacl': '/sdk_root/toolchain/mac_pnacl/bin/pnacl-%s' % pnacl_tool, | 89 'pnacl': '/sdk_root/toolchain/mac_pnacl/bin/pnacl-%s' % pnacl_tool, |
| 90 ('pnacl', 'pnacl'): |
| 91 '/sdk_root/toolchain/mac_pnacl/bin/pnacl-%s' % pnacl_tool, |
| 90 } | 92 } |
| 91 | 93 |
| 92 for tc_arch, expected in cases.iteritems(): | 94 for tc_arch, expected in cases.iteritems(): |
| 93 if isinstance(tc_arch, tuple): | 95 if isinstance(tc_arch, tuple): |
| 94 toolchain = tc_arch[0] | 96 toolchain = tc_arch[0] |
| 95 arch = tc_arch[1] | 97 arch = tc_arch[1] |
| 96 else: | 98 else: |
| 97 toolchain = tc_arch | 99 toolchain = tc_arch |
| 98 arch = None | 100 arch = None |
| 99 self.assertEqual(expected, nacl_config.GetToolPath(toolchain, arch, tool)) | 101 self.assertEqual(expected, nacl_config.GetToolPath(toolchain, arch, tool)) |
| 100 | 102 |
| 101 for toolchain in ('host', 'mac', 'win', 'linux'): | 103 for toolchain in ('host', 'mac', 'win', 'linux'): |
| 102 self.assertRaises(nacl_config.Error, | 104 self.assertRaises(nacl_config.Error, |
| 103 nacl_config.GetToolPath, toolchain, None, tool) | 105 nacl_config.GetToolPath, toolchain, None, tool) |
| 104 | 106 |
| 107 # Using toolchain=pnacl with any arch other than None, or 'pnacl' is an |
| 108 # error. |
| 109 for arch in ('x86_32', 'x86_64', 'arm', 'foobar'): |
| 110 self.assertRaises(nacl_config.Error, |
| 111 nacl_config.GetToolPath, toolchain, arch, tool) |
| 112 |
| 105 # No arm glibc. | 113 # No arm glibc. |
| 106 self.assertRaises(nacl_config.Error, | 114 self.assertRaises(nacl_config.Error, |
| 107 nacl_config.GetToolPath, 'glibc', 'arm', tool) | 115 nacl_config.GetToolPath, 'glibc', 'arm', tool) |
| 108 | 116 |
| 109 def testCC(self): | 117 def testCC(self): |
| 110 self._TestTool('cc', 'gcc', 'clang') | 118 self._TestTool('cc', 'gcc', 'clang') |
| 111 | 119 |
| 112 def testCXX(self): | 120 def testCXX(self): |
| 113 self._TestTool('c++', 'g++', 'clang++') | 121 self._TestTool('c++', 'g++', 'clang++') |
| 114 | 122 |
| 115 def testLD(self): | 123 def testLD(self): |
| 116 self._TestTool('ld', 'g++', 'clang++') | 124 self._TestTool('ld', 'g++', 'clang++') |
| 117 | 125 |
| 118 def testStandardTool(self): | 126 def testStandardTool(self): |
| 119 for tool in ('nm', 'strip', 'ar', 'ranlib'): | 127 for tool in ('nm', 'strip', 'ar', 'ranlib'): |
| 120 self._TestTool(tool) | 128 self._TestTool(tool) |
| 121 | 129 |
| 122 def testGDB(self): | 130 def testGDB(self): |
| 123 # We always use the same gdb (it supports multiple toolchains/architectures) | 131 # We always use the same gdb (it supports multiple toolchains/architectures) |
| 124 expected = '/sdk_root/toolchain/mac_x86_newlib/bin/x86_64-nacl-gdb' | 132 expected = '/sdk_root/toolchain/mac_x86_newlib/bin/x86_64-nacl-gdb' |
| 125 for toolchain in ('newlib', 'glibc', 'pnacl'): | 133 for toolchain in ('newlib', 'glibc', 'pnacl'): |
| 126 for arch in ('x86_32', 'x86_64', 'arm'): | 134 for arch in ('x86_32', 'x86_64', 'arm'): |
| 127 self.assertEqual(expected, | 135 self.assertEqual(expected, |
| 128 nacl_config.GetToolPath(toolchain, arch, 'gdb')) | 136 nacl_config.GetToolPath(toolchain, arch, 'gdb')) |
| 129 | 137 |
| 130 | 138 |
| 131 if __name__ == '__main__': | 139 if __name__ == '__main__': |
| 132 unittest.main() | 140 unittest.main() |
| OLD | NEW |