Changeset View
Changeset View
Standalone View
Standalone View
packages/Python/lldbsuite/test/lldbtest.py
Show First 20 Lines • Show All 734 Lines • ▼ Show 20 Lines | def expectedFailureDarwin(bugnumber=None, compilers=None, debug_info=None): | ||||
return expectedFailureOS(getDarwinOSTriples(), bugnumber, compilers, debug_info=debug_info) | return expectedFailureOS(getDarwinOSTriples(), bugnumber, compilers, debug_info=debug_info) | ||||
def expectedFailureFreeBSD(bugnumber=None, compilers=None, debug_info=None): | def expectedFailureFreeBSD(bugnumber=None, compilers=None, debug_info=None): | ||||
return expectedFailureOS(['freebsd'], bugnumber, compilers, debug_info=debug_info) | return expectedFailureOS(['freebsd'], bugnumber, compilers, debug_info=debug_info) | ||||
def expectedFailureLinux(bugnumber=None, compilers=None, debug_info=None): | def expectedFailureLinux(bugnumber=None, compilers=None, debug_info=None): | ||||
return expectedFailureOS(['linux'], bugnumber, compilers, debug_info=debug_info) | return expectedFailureOS(['linux'], bugnumber, compilers, debug_info=debug_info) | ||||
def expectedFailureNetBSD(bugnumber=None, compilers=None, debug_info=None): | |||||
return expectedFailureOS(['netbsd'], bugnumber, compilers, debug_info=debug_info) | |||||
def expectedFailureWindows(bugnumber=None, compilers=None, debug_info=None): | def expectedFailureWindows(bugnumber=None, compilers=None, debug_info=None): | ||||
return expectedFailureOS(['windows'], bugnumber, compilers, debug_info=debug_info) | return expectedFailureOS(['windows'], bugnumber, compilers, debug_info=debug_info) | ||||
def expectedFailureHostWindows(bugnumber=None, compilers=None): | def expectedFailureHostWindows(bugnumber=None, compilers=None): | ||||
return expectedFailureHostOS(['windows'], bugnumber, compilers) | return expectedFailureHostOS(['windows'], bugnumber, compilers) | ||||
def matchAndroid(api_levels=None, archs=None): | def matchAndroid(api_levels=None, archs=None): | ||||
def match(self): | def match(self): | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | def fn(self): | ||||
return (self.getPlatform() in oslist and | return (self.getPlatform() in oslist and | ||||
self.expectedCompiler(compilers)) | self.expectedCompiler(compilers)) | ||||
return expectedFlakey(fn, bugnumber) | return expectedFlakey(fn, bugnumber) | ||||
def expectedFlakeyDarwin(bugnumber=None, compilers=None): | def expectedFlakeyDarwin(bugnumber=None, compilers=None): | ||||
# For legacy reasons, we support both "darwin" and "macosx" as OS X triples. | # For legacy reasons, we support both "darwin" and "macosx" as OS X triples. | ||||
return expectedFlakeyOS(getDarwinOSTriples(), bugnumber, compilers) | return expectedFlakeyOS(getDarwinOSTriples(), bugnumber, compilers) | ||||
def expectedFlakeyFreeBSD(bugnumber=None, compilers=None): | |||||
return expectedFlakeyOS(['freebsd'], bugnumber, compilers) | |||||
emaste: perhaps put after FlakeyLinux so we only have to move FreeBSD to put it in alpha order | |||||
def expectedFlakeyLinux(bugnumber=None, compilers=None): | def expectedFlakeyLinux(bugnumber=None, compilers=None): | ||||
return expectedFlakeyOS(['linux'], bugnumber, compilers) | return expectedFlakeyOS(['linux'], bugnumber, compilers) | ||||
def expectedFlakeyFreeBSD(bugnumber=None, compilers=None): | def expectedFlakeyNetBSD(bugnumber=None, compilers=None): | ||||
return expectedFlakeyOS(['freebsd'], bugnumber, compilers) | return expectedFlakeyOS(['netbsd'], bugnumber, compilers) | ||||
def expectedFlakeyCompiler(compiler, compiler_version=None, bugnumber=None): | def expectedFlakeyCompiler(compiler, compiler_version=None, bugnumber=None): | ||||
if compiler_version is None: | if compiler_version is None: | ||||
compiler_version=['=', None] | compiler_version=['=', None] | ||||
def fn(self): | def fn(self): | ||||
return compiler in self.getCompiler() and self.expectedCompilerVersion(compiler_version) | return compiler in self.getCompiler() and self.expectedCompilerVersion(compiler_version) | ||||
return expectedFlakey(fn, bugnumber) | return expectedFlakey(fn, bugnumber) | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
def skipIfiOSSimulator(func): | def skipIfiOSSimulator(func): | ||||
"""Decorate the item to skip tests that should be skipped on the iOS Simulator.""" | """Decorate the item to skip tests that should be skipped on the iOS Simulator.""" | ||||
return unittest2.skipIf(hasattr(lldb, 'remote_platform_name') and lldb.remote_platform_name == 'ios-simulator', 'skip on the iOS Simulator')(func) | return unittest2.skipIf(hasattr(lldb, 'remote_platform_name') and lldb.remote_platform_name == 'ios-simulator', 'skip on the iOS Simulator')(func) | ||||
def skipIfFreeBSD(func): | def skipIfFreeBSD(func): | ||||
"""Decorate the item to skip tests that should be skipped on FreeBSD.""" | """Decorate the item to skip tests that should be skipped on FreeBSD.""" | ||||
return skipIfPlatform(["freebsd"])(func) | return skipIfPlatform(["freebsd"])(func) | ||||
def skipIfNetBSD(func): | |||||
"""Decorate the item to skip tests that should be skipped on NetBSD.""" | |||||
return skipIfPlatform(["netbsd"])(func) | |||||
def getDarwinOSTriples(): | def getDarwinOSTriples(): | ||||
return ['darwin', 'macosx', 'ios'] | return ['darwin', 'macosx', 'ios'] | ||||
def skipIfDarwin(func): | def skipIfDarwin(func): | ||||
"""Decorate the item to skip tests that should be skipped on Darwin.""" | """Decorate the item to skip tests that should be skipped on Darwin.""" | ||||
return skipIfPlatform(getDarwinOSTriples())(func) | return skipIfPlatform(getDarwinOSTriples())(func) | ||||
def skipIfLinux(func): | def skipIfLinux(func): | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | def wrapper(*args, **kwargs): | ||||
func(*args, **kwargs) | func(*args, **kwargs) | ||||
return wrapper | return wrapper | ||||
def getPlatform(): | def getPlatform(): | ||||
"""Returns the target platform which the tests are running on.""" | """Returns the target platform which the tests are running on.""" | ||||
platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2] | platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2] | ||||
if platform.startswith('freebsd'): | if platform.startswith('freebsd'): | ||||
platform = 'freebsd' | platform = 'freebsd' | ||||
elif platform.startswith('netbsd'): | |||||
platform = 'netbsd' | |||||
return platform | return platform | ||||
def getHostPlatform(): | def getHostPlatform(): | ||||
"""Returns the host platform running the test suite.""" | """Returns the host platform running the test suite.""" | ||||
# Attempts to return a platform name matching a target Triple platform. | # Attempts to return a platform name matching a target Triple platform. | ||||
if sys.platform.startswith('linux'): | if sys.platform.startswith('linux'): | ||||
return 'linux' | return 'linux' | ||||
elif sys.platform.startswith('win32'): | elif sys.platform.startswith('win32'): | ||||
return 'windows' | return 'windows' | ||||
elif sys.platform.startswith('darwin'): | elif sys.platform.startswith('darwin'): | ||||
return 'darwin' | return 'darwin' | ||||
elif sys.platform.startswith('freebsd'): | elif sys.platform.startswith('freebsd'): | ||||
return 'freebsd' | return 'freebsd' | ||||
elif sys.platform.startswith('netbsd'): | |||||
return 'netbsd' | |||||
else: | else: | ||||
return sys.platform | return sys.platform | ||||
def platformIsDarwin(): | def platformIsDarwin(): | ||||
"""Returns true if the OS triple for the selected platform is any valid apple OS""" | """Returns true if the OS triple for the selected platform is any valid apple OS""" | ||||
return getPlatform() in getDarwinOSTriples() | return getPlatform() in getDarwinOSTriples() | ||||
def skipIfHostIncompatibleWithRemote(func): | def skipIfHostIncompatibleWithRemote(func): | ||||
▲ Show 20 Lines • Show All 286 Lines • ▼ Show 20 Lines | def setUpClass(cls): | ||||
# read the previous owner from the lock file | # read the previous owner from the lock file | ||||
lock_id = cls.dir_lock.handle.read() | lock_id = cls.dir_lock.handle.read() | ||||
print("LOCK ERROR: {} wants to lock '{}' but it is already locked by '{}'".format(cls.__name__, full_dir, lock_id), file=sys.stderr) | print("LOCK ERROR: {} wants to lock '{}' but it is already locked by '{}'".format(cls.__name__, full_dir, lock_id), file=sys.stderr) | ||||
raise ioerror | raise ioerror | ||||
# Set platform context. | # Set platform context. | ||||
if platformIsDarwin(): | if platformIsDarwin(): | ||||
cls.platformContext = _PlatformContext('DYLD_LIBRARY_PATH', 'lib', 'dylib') | cls.platformContext = _PlatformContext('DYLD_LIBRARY_PATH', 'lib', 'dylib') | ||||
elif getPlatform() == "linux" or getPlatform() == "freebsd": | elif getPlatform() == "linux" or getPlatform() == "freebsd" or getPlatform() == "netbsd": | ||||
joergUnsubmitted Not Done ReplyInline ActionsI'd prefer getPlatform() in ("linux", "freebsd", "netbsd") as more shorter. joerg: I'd prefer `getPlatform() in ("linux", "freebsd", "netbsd")` as more shorter. | |||||
cls.platformContext = _PlatformContext('LD_LIBRARY_PATH', 'lib', 'so') | cls.platformContext = _PlatformContext('LD_LIBRARY_PATH', 'lib', 'so') | ||||
else: | else: | ||||
cls.platformContext = None | cls.platformContext = None | ||||
@classmethod | @classmethod | ||||
def tearDownClass(cls): | def tearDownClass(cls): | ||||
""" | """ | ||||
Python unittest framework class teardown fixture. | Python unittest framework class teardown fixture. | ||||
▲ Show 20 Lines • Show All 735 Lines • ▼ Show 20 Lines | class Base(unittest2.TestCase): | ||||
# ================================================== | # ================================================== | ||||
# Build methods supported through a plugin interface | # Build methods supported through a plugin interface | ||||
# ================================================== | # ================================================== | ||||
def getstdlibFlag(self): | def getstdlibFlag(self): | ||||
""" Returns the proper -stdlib flag, or empty if not required.""" | """ Returns the proper -stdlib flag, or empty if not required.""" | ||||
if self.platformIsDarwin() or self.getPlatform() == "freebsd": | if self.platformIsDarwin() or self.getPlatform() == "freebsd": | ||||
stdlibflag = "-stdlib=libc++" | stdlibflag = "-stdlib=libc++" | ||||
else: | else: # this includes NetBSD | ||||
stdlibflag = "" | stdlibflag = "" | ||||
return stdlibflag | return stdlibflag | ||||
def getstdFlag(self): | def getstdFlag(self): | ||||
""" Returns the proper stdflag. """ | """ Returns the proper stdflag. """ | ||||
if "gcc" in self.getCompiler() and "4.6" in self.getCompilerVersion(): | if "gcc" in self.getCompiler() and "4.6" in self.getCompilerVersion(): | ||||
stdflag = "-std=c++0x" | stdflag = "-std=c++0x" | ||||
else: | else: | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | def getBuildFlags(self, use_cpp11=True, use_libcxx=False, use_libstdcxx=False): | ||||
if use_cpp11: | if use_cpp11: | ||||
cflags += "-std=" | cflags += "-std=" | ||||
if "gcc" in self.getCompiler() and "4.6" in self.getCompilerVersion(): | if "gcc" in self.getCompiler() and "4.6" in self.getCompilerVersion(): | ||||
cflags += "c++0x" | cflags += "c++0x" | ||||
else: | else: | ||||
cflags += "c++11" | cflags += "c++11" | ||||
if self.platformIsDarwin() or self.getPlatform() == "freebsd": | if self.platformIsDarwin() or self.getPlatform() == "freebsd": | ||||
cflags += " -stdlib=libc++" | cflags += " -stdlib=libc++" | ||||
elif self.getPlatform() == "netbsd": | |||||
cflags += " -stdlib=libstdc++" | |||||
elif "clang" in self.getCompiler(): | elif "clang" in self.getCompiler(): | ||||
cflags += " -stdlib=libstdc++" | cflags += " -stdlib=libstdc++" | ||||
return {'CFLAGS_EXTRAS' : cflags, | return {'CFLAGS_EXTRAS' : cflags, | ||||
'LD_EXTRAS' : ldflags, | 'LD_EXTRAS' : ldflags, | ||||
} | } | ||||
def cleanup(self, dictionary=None): | def cleanup(self, dictionary=None): | ||||
Show All 15 Lines | def getLLDBLibraryEnvVal(self): | ||||
if existing_library_path: | if existing_library_path: | ||||
return "%s:%s" % (existing_library_path, lib_dir) | return "%s:%s" % (existing_library_path, lib_dir) | ||||
elif sys.platform.startswith("darwin"): | elif sys.platform.startswith("darwin"): | ||||
return os.path.join(lib_dir, 'LLDB.framework') | return os.path.join(lib_dir, 'LLDB.framework') | ||||
else: | else: | ||||
return lib_dir | return lib_dir | ||||
def getLibcPlusPlusLibs(self): | def getLibcPlusPlusLibs(self): | ||||
if self.getPlatform() == 'freebsd' or self.getPlatform() == 'linux': | if self.getPlatform() == 'freebsd' or self.getPlatform() == 'linux' or self.getPlatform() == 'netbsd': | ||||
joergUnsubmitted Not Done ReplyInline ActionsSame, self.getPlatform in ... joerg: Same, `self.getPlatform in ...` | |||||
return ['libc++.so.1'] | return ['libc++.so.1'] | ||||
else: | else: | ||||
return ['libc++.1.dylib','libc++abi.dylib'] | return ['libc++.1.dylib','libc++abi.dylib'] | ||||
Not Done ReplyInline ActionsThis seems wrong; if a test needs libc++ it should either be skipped on NetBSD right now or use libc++ emaste: This seems wrong; if a test needs libc++ it should either be skipped on NetBSD right now or use… | |||||
# Metaclass for TestBase to change the list of test metods when a new TestCase is loaded. | # Metaclass for TestBase to change the list of test metods when a new TestCase is loaded. | ||||
# We change the test methods to create a new test method for each test for each debug info we are | # We change the test methods to create a new test method for each test for each debug info we are | ||||
# testing. The name of the new test method will be '<original-name>_<debug-info>' and with adding | # testing. The name of the new test method will be '<original-name>_<debug-info>' and with adding | ||||
# the new test method we remove the old method at the same time. | # the new test method we remove the old method at the same time. | ||||
class LLDBTestCaseFactory(type): | class LLDBTestCaseFactory(type): | ||||
def __new__(cls, name, bases, attrs): | def __new__(cls, name, bases, attrs): | ||||
newattrs = {} | newattrs = {} | ||||
▲ Show 20 Lines • Show All 629 Lines • Show Last 20 Lines |
perhaps put after FlakeyLinux so we only have to move FreeBSD to put it in alpha order