Index: lldb/trunk/test/functionalities/plugins/commands/TestPluginCommands.py =================================================================== --- lldb/trunk/test/functionalities/plugins/commands/TestPluginCommands.py +++ lldb/trunk/test/functionalities/plugins/commands/TestPluginCommands.py @@ -20,8 +20,8 @@ self.implib_dir = os.environ["LLDB_IMPLIB_DIR"] @expectedFailureFreeBSD('llvm.org/pr17430') - @skipIfi386 # This test links against liblldb.so. Thus, the test requires a 32-bit liblldb.so. @skipIfNoSBHeaders + @skipIfHostIncompatibleWithRemote # Requires a compatible arch and platform to link against the host's built lldb lib. def test_load_plugin(self): """Test that plugins that load commands work correctly.""" Index: lldb/trunk/test/lldbtest.py =================================================================== --- lldb/trunk/test/lldbtest.py +++ lldb/trunk/test/lldbtest.py @@ -717,16 +717,50 @@ return skipUnlessPlatform(getDarwinOSTriples())(func) def getPlatform(): - """Returns the target platform the test suite is running on.""" + """Returns the target platform which the tests are running on.""" platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2] if platform.startswith('freebsd'): platform = 'freebsd' return platform +def getHostPlatform(): + """Returns the host platform running the test suite.""" + # Attempts to return a platform name matching a target Triple platform. + if sys.platform.startswith('linux'): + return 'linux' + elif sys.platform.startswith('win32'): + return 'windows' + elif sys.platform.startswith('darwin'): + return 'darwin' + elif sys.platform.startswith('freebsd'): + return 'freebsd' + else: + return sys.platform + def platformIsDarwin(): """Returns true if the OS triple for the selected platform is any valid apple OS""" return getPlatform() in getDarwinOSTriples() +def skipIfHostIncompatibleWithRemote(func): + """Decorate the item to skip tests if binaries built on this host are incompatible.""" + if isinstance(func, type) and issubclass(func, unittest2.TestCase): + raise Exception("@skipIfHostIncompatibleWithRemote can only be used to decorate a test method") + @wraps(func) + def wrapper(*args, **kwargs): + from unittest2 import case + self = args[0] + host_arch = self.getLldbArchitecture() + host_platform = getHostPlatform() + target_arch = self.getArchitecture() + target_platform = 'darwin' if self.getPlatform() in getDarwinOSTriples() else self.getPlatform() + if not (target_arch == 'x86_64' and host_arch == 'i386') and host_arch != target_arch: + self.skipTest("skipping because target %s is not compatible with host architecture %s" % (target_arch, host_arch)) + elif target_platform != host_platform: + self.skipTest("skipping because target is %s but host is %s" % (target_platform, host_platform)) + else: + func(*args, **kwargs) + return wrapper + def skipIfPlatform(oslist): """Decorate the item to skip tests if running on one of the listed platforms.""" return unittest2.skipIf(getPlatform() in oslist,