Make debug info specification use categories system.

Reviewed By: Tamas Berghammer, Pavel Labath
Differential Revision: http://reviews.llvm.org/D15428

llvm-svn: 255525
This commit is contained in:
Zachary Turner 2015-12-14 18:49:16 +00:00
parent 4ae76c2692
commit f098e4fb19
8 changed files with 41 additions and 106 deletions

View File

@ -56,10 +56,6 @@ def setupCrashInfoHook():
# The test suite.
suite = unittest2.TestSuite()
dont_do_dsym_test = False
dont_do_dwarf_test = False
dont_do_dwo_test = False
# The list of categories we said we care about
categoriesList = None
# set to true if we are going to use categories for cherry-picking test cases

View File

@ -281,14 +281,6 @@ def parseOptionsAndInitTestdirs():
cflags_extras = args.E
os.environ['CFLAGS_EXTRAS'] = cflags_extras
# argparse makes sure we have correct options
if args.N == 'dwarf':
configuration.dont_do_dwarf_test = True
elif args.N == 'dwo':
configuration.dont_do_dwo_test = True
elif args.N == 'dsym':
configuration.dont_do_dsym_test = True
if args.d:
sys.stdout.write("Suspending the process %d to wait for debugger to attach...\n" % os.getpid())
sys.stdout.flush()
@ -945,15 +937,6 @@ def run_suite():
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
# By default, both dsym, dwarf and dwo tests are performed.
# Use @dsym_test, @dwarf_test or @dwo_test decorators, defined in lldbtest.py, to mark a test as
# a dsym, dwarf or dwo test. Use '-N dsym', '-N dwarf' or '-N dwo' to exclude dsym, dwarf or
# dwo tests from running.
configuration.dont_do_dsym_test = configuration.dont_do_dsym_test \
or any(platform in target_platform for platform in ["linux", "freebsd", "windows"])
configuration.dont_do_dwo_test = configuration.dont_do_dwo_test \
or any(platform in target_platform for platform in ["darwin", "macosx", "ios"])
# Don't do debugserver tests on everything except OS X.
configuration.dont_do_debugserver_test = "linux" in target_platform or "freebsd" in target_platform or "windows" in target_platform

View File

@ -59,7 +59,6 @@ def create_parser():
# Test filtering options
group = parser.add_argument_group('Test filtering options')
group.add_argument('-N', choices=['dwarf', 'dwo', 'dsym'], help="Don't do test cases marked with the @dsym_test/@dwarf_test/@dwo_test decorator by passing dsym/dwarf/dwo as the option arg")
group.add_argument('-f', metavar='filterspec', action='append', help='Specify a filter, which consists of the test class name, a dot, followed by the test method, to only admit such test into the test suite') # FIXME: Example?
X('-l', "Don't skip long running tests")
group.add_argument('-p', metavar='pattern', help='Specify a regexp filename pattern for inclusion in the test suite')

View File

@ -117,7 +117,7 @@ for d in test_source_dirs:
# Generate test cases based on the collected source files
for f in test_source_files:
if f.endswith(".cpp") or f.endswith(".c"):
@dwarf_test
@add_test_categories(["dwarf"])
@unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test")
def test_function_dwarf(self, f=f):
if f.endswith(".cpp"):

View File

@ -13,20 +13,11 @@ class TypedefTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@skipUnlessDarwin
@dsym_test
@expectedFailureClang("llvm.org/pr19238")
def test_with_dsym(self):
@expectedFailureAll(bugnumber="llvm.org/pr19238", compiler="clang")
@expectedFailureAll(bugnumber="llvm.org/pr25626 expectedFailureClang fails on FreeBSD", oslist=["freebsd"])
def test_typedef(self):
"""Test 'image lookup -t a' and check for correct display at different scopes."""
self.buildDsym()
self.image_lookup_for_multiple_typedefs()
@dwarf_test
@expectedFailureClang("llvm.org/pr19238")
@expectedFailureFreeBSD("llvm.org/pr25626 expectedFailureClang fails on FreeBSD")
def test_with_dwarf(self):
"""Test 'image lookup -t a' and check for correct display at different scopes."""
self.buildDwarf()
self.build()
self.image_lookup_for_multiple_typedefs()
def image_lookup_for_multiple_typedefs(self):

View File

@ -6,9 +6,9 @@ class TestWithLimitDebugInfo(TestBase):
mydir = TestBase.compute_mydir(__file__)
@dwarf_test
def test_with_dwarf(self):
self.buildDwarf()
@skipIf(debug_info=not_in(["dwarf"]))
def test_limit_debug_info(self):
self.build()
cwd = os.getcwd()

View File

@ -549,48 +549,6 @@ def no_debug_info_test(func):
wrapper.__no_debug_info_test__ = True
return wrapper
def dsym_test(func):
"""Decorate the item as a dsym test."""
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
raise Exception("@dsym_test can only be used to decorate a test method")
@wraps(func)
def wrapper(self, *args, **kwargs):
if configuration.dont_do_dsym_test:
self.skipTest("dsym tests")
return func(self, *args, **kwargs)
# Mark this function as such to separate them from the regular tests.
wrapper.__dsym_test__ = True
return wrapper
def dwarf_test(func):
"""Decorate the item as a dwarf test."""
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
raise Exception("@dwarf_test can only be used to decorate a test method")
@wraps(func)
def wrapper(self, *args, **kwargs):
if configuration.dont_do_dwarf_test:
self.skipTest("dwarf tests")
return func(self, *args, **kwargs)
# Mark this function as such to separate them from the regular tests.
wrapper.__dwarf_test__ = True
return wrapper
def dwo_test(func):
"""Decorate the item as a dwo test."""
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
raise Exception("@dwo_test can only be used to decorate a test method")
@wraps(func)
def wrapper(self, *args, **kwargs):
if configuration.dont_do_dwo_test:
self.skipTest("dwo tests")
return func(self, *args, **kwargs)
# Mark this function as such to separate them from the regular tests.
wrapper.__dwo_test__ = True
return wrapper
def debugserver_test(func):
"""Decorate the item as a debugserver test."""
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
@ -2270,32 +2228,26 @@ class LLDBTestCaseFactory(type):
newattrs = {}
for attrname, attrvalue in attrs.items():
if attrname.startswith("test") and not getattr(attrvalue, "__no_debug_info_test__", False):
@dsym_test
@wraps(attrvalue)
def dsym_test_method(self, attrvalue=attrvalue):
self.debug_info = "dsym"
return attrvalue(self)
dsym_method_name = attrname + "_dsym"
dsym_test_method.__name__ = dsym_method_name
newattrs[dsym_method_name] = dsym_test_method
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
@dwarf_test
@wraps(attrvalue)
def dwarf_test_method(self, attrvalue=attrvalue):
self.debug_info = "dwarf"
return attrvalue(self)
dwarf_method_name = attrname + "_dwarf"
dwarf_test_method.__name__ = dwarf_method_name
newattrs[dwarf_method_name] = dwarf_test_method
@dwo_test
@wraps(attrvalue)
def dwo_test_method(self, attrvalue=attrvalue):
self.debug_info = "dwo"
return attrvalue(self)
dwo_method_name = attrname + "_dwo"
dwo_test_method.__name__ = dwo_method_name
newattrs[dwo_method_name] = dwo_test_method
# If any debug info categories were explicitly tagged, assume that list to be
# authoritative. If none were specified, try with all debug info formats.
all_dbginfo_categories = set(test_categories.debug_info_categories)
categories = set(getattr(attrvalue, "categories", [])) & all_dbginfo_categories
if not categories:
categories = all_dbginfo_categories
supported_categories = [x for x in categories
if test_categories.is_supported_on_platform(x, target_platform)]
for category in supported_categories:
@add_test_categories([category])
@wraps(attrvalue)
def test_method(self, attrvalue=attrvalue):
self.debug_info = category
return attrvalue(self)
method_name = attrname + "_" + category
test_method.__name__ = method_name
newattrs[method_name] = test_method
else:
newattrs[attrname] = attrvalue
return super(LLDBTestCaseFactory, cls).__new__(cls, name, bases, newattrs)

View File

@ -12,8 +12,15 @@ import sys
# LLDB modules
debug_info_categories = [
'dwarf', 'dwo', 'dsym'
]
all_categories = {
'dataformatters': 'Tests related to the type command and the data formatters subsystem',
'dwarf' : 'Tests that can be run with DWARF debug information',
'dwo' : 'Tests that can be run with DWO debug information',
'dsym' : 'Tests that can be run with DSYM debug information',
'expression' : 'Tests related to the expression parser',
'objc' : 'Tests related to the Objective-C programming language support',
'pyapi' : 'Tests related to the Python API',
@ -35,6 +42,13 @@ def unique_string_match(yourentry, list):
candidate = item
return candidate
def is_supported_on_platform(category, platform):
if category == "dwo":
return platform in ["linux", "freebsd", "windows"]
elif category == "dsym":
return platform in ["darwin", "macosx", "ios"]
return True
def validate(categories, exact_match):
"""
For each category in categories, ensure that it's a valid category (if exact_match is false,