[Lldb-commits] [lldb] r237444 - Skip TestPluginCommands.py if host lldb library is incompatible with remote.

Robert Flack flackr at gmail.com
Fri May 15 05:39:33 PDT 2015


Author: flackr
Date: Fri May 15 07:39:33 2015
New Revision: 237444

URL: http://llvm.org/viewvc/llvm-project?rev=237444&view=rev
Log:
Skip TestPluginCommands.py if host lldb library is incompatible with remote.

TestPluginCommands.py attempts to build a library which links against the host
built lldb library. This will only work if the remote is compatible with
binaries produced by the host.

Test Plan:
./dotest.py $DOTEST_OPTS -v -t -p TestPluginCommands.py
Test is skipped if remote platform is incompatible with host platform (i.e. mac
-> linux).

Differential Revision: http://reviews.llvm.org/D9770

Modified:
    lldb/trunk/test/functionalities/plugins/commands/TestPluginCommands.py
    lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/functionalities/plugins/commands/TestPluginCommands.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/plugins/commands/TestPluginCommands.py?rev=237444&r1=237443&r2=237444&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/plugins/commands/TestPluginCommands.py (original)
+++ lldb/trunk/test/functionalities/plugins/commands/TestPluginCommands.py Fri May 15 07:39:33 2015
@@ -20,8 +20,8 @@ class PluginCommandTestCase(TestBase):
         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."""
 

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=237444&r1=237443&r2=237444&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Fri May 15 07:39:33 2015
@@ -717,16 +717,50 @@ def skipUnlessDarwin(func):
     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,





More information about the lldb-commits mailing list