def testGDB(self):
     # We always use the same gdb (it supports multiple toolchains/architectures)
     expected = '/sdk_root/toolchain/mac_x86_newlib/bin/x86_64-nacl-gdb'
     for toolchain in ('newlib', 'glibc', 'pnacl'):
         for arch in ('x86_32', 'x86_64', 'arm'):
             self.assertEqual(
                 expected, nacl_config.GetToolPath(toolchain, arch, 'gdb'))
    def _TestTool(self, tool, nacl_tool=None, pnacl_tool=None):
        nacl_tool = nacl_tool or tool
        pnacl_tool = pnacl_tool or tool

        cases = {
            ('newlib', 'x86_32'):
            '/sdk_root/toolchain/mac_x86_newlib/bin/i686-nacl-%s' % nacl_tool,
            ('newlib', 'x86_64'):
            '/sdk_root/toolchain/mac_x86_newlib/bin/x86_64-nacl-%s' %
            nacl_tool,
            ('newlib', 'arm'):
            '/sdk_root/toolchain/mac_arm_newlib/bin/arm-nacl-%s' % nacl_tool,
            ('glibc', 'x86_32'):
            '/sdk_root/toolchain/mac_x86_glibc/bin/i686-nacl-%s' % nacl_tool,
            ('glibc', 'x86_64'):
            '/sdk_root/toolchain/mac_x86_glibc/bin/x86_64-nacl-%s' % nacl_tool,
            'pnacl':
            '/sdk_root/toolchain/mac_pnacl/bin/pnacl-%s' % pnacl_tool,
            ('pnacl', 'pnacl'):
            '/sdk_root/toolchain/mac_pnacl/bin/pnacl-%s' % pnacl_tool,
        }

        for tc_arch, expected in cases.iteritems():
            if isinstance(tc_arch, tuple):
                toolchain = tc_arch[0]
                arch = tc_arch[1]
            else:
                toolchain = tc_arch
                arch = None
            self.assertEqual(expected,
                             nacl_config.GetToolPath(toolchain, arch, tool))

        for toolchain in ('host', 'mac', 'win', 'linux'):
            self.assertRaises(nacl_config.Error, nacl_config.GetToolPath,
                              toolchain, None, tool)

        # Using toolchain=pnacl with any arch other than None, or 'pnacl' is an
        # error.
        for arch in ('x86_32', 'x86_64', 'arm', 'foobar'):
            self.assertRaises(nacl_config.Error, nacl_config.GetToolPath,
                              toolchain, arch, tool)

        # No arm glibc.
        self.assertRaises(nacl_config.Error, nacl_config.GetToolPath, 'glibc',
                          'arm', tool)