forked from OSchip/llvm-project
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 llvm-svn: 237444
This commit is contained in:
parent
3ac979c4da
commit
6e1fd35bfe
|
@ -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."""
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue