o Added a new feature to the test framework to skip long running tests conditionally.

To not skip long running tests, pass '-l' to the test driver (dotest.py).

  An example:

    @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test")
    def test_foundation_disasm(self):
        ...

o Added a long running disassemble test to the foundation directory, which iterates
  the code symbols from Foundation.framework and kicks off a disassemble command for
  for the named function symbol.  Found a crasher: rdar://problem/8504895.

o Plus added/updated some comments for the TestBase class.

llvm-svn: 115368
This commit is contained in:
Johnny Chen 2010-10-01 22:59:49 +00:00
parent 111c550dea
commit da88434b39
3 changed files with 66 additions and 1 deletions

View File

@ -57,6 +57,9 @@ delay = False
# Ignore the build search path relative to this script to locate the lldb.py module.
ignore = False
# By default, we skip long running test case. Use "-l" option to override.
skipLongRunningTest = True
# The regular expression pattern to match against eligible filenames as our test cases.
regexp = None
@ -80,6 +83,7 @@ where options:
-d : delay startup for 10 seconds (in order for the debugger to attach)
-i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build
tree relative to this script; use PYTHONPATH to locate the module
-l : don't skip long running test
-p : specify a regexp filename pattern for inclusion in the test suite
-t : trace lldb command execution and result
-v : do verbose mode of unittest framework
@ -114,6 +118,7 @@ def parseOptionsAndInitTestdirs():
global configFile
global delay
global ignore
global skipLongRunningTest
global regexp
global verbose
global testdirs
@ -146,6 +151,9 @@ def parseOptionsAndInitTestdirs():
elif sys.argv[index].startswith('-i'):
ignore = True
index += 1
elif sys.argv[index].startswith('-l'):
skipLongRunningTest = False
index += 1
elif sys.argv[index].startswith('-p'):
# Increment by 1 to fetch the reg exp pattern argument.
index += 1
@ -334,6 +342,11 @@ setupSysPath()
if delay:
doDelay(10)
#
# If '-l' is specified, do not skip the long running tests.
if not skipLongRunningTest:
os.environ["LLDB_SKIP_LONG_RUNNING_TEST"] = "NO"
#
# Walk through the testdirs while collecting test cases.
#

View File

@ -12,6 +12,39 @@ class FoundationDisassembleTestCase(TestBase):
mydir = "foundation"
# rdar://problem/8504895
# Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]"
@unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test")
def test_foundation_disasm(self):
"""Do 'disassemble -n func' on each and every 'Code' symbol entry from the Foundation.framework."""
self.buildDefault()
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
self.runCmd("run", RUN_SUCCEEDED)
self.runCmd("image list")
raw_output = self.res.GetOutput()
# Grok the full path to the foundation framework.
for line in raw_output.split(os.linesep):
match = re.search(" (/.*/Foundation.framework/.*)$", line)
if match:
foundation_framework = match.group(1)
break
self.assertTrue(match, "Foundation.framework path located")
self.runCmd("image dump symtab %s" % foundation_framework)
raw_output = self.res.GetOutput()
# Now, grab every 'Code' symbol and feed it into the 'disassemble -n func' command.
for line in raw_output.split(os.linesep):
# The symbol name is on the last column and trails the flag column which ends with '0000'.
match = re.search(" Code .+0000 (.+)$", line)
if match:
func = match.group(1)
print "line:", line
print "func:", func
self.runCmd('disassemble -n "%s"' % func)
def test_simple_disasm_with_dsym(self):
"""Test the lldb 'disassemble' command"""
self.buildDsym()

View File

@ -264,6 +264,17 @@ def system(*popenargs, **kwargs):
class TestBase(unittest2.TestCase):
"""This LLDB abstract base class is meant to be subclassed."""
@classmethod
def skipLongRunningTest(cls):
"""
By default, we skip long running test case.
This can be overridden by passing '-l' to the test driver (dotest.py).
"""
if "LLDB_SKIP_LONG_RUNNING_TEST" in os.environ and "NO" == os.environ["LLDB_SKIP_LONG_RUNNING_TEST"]:
return False
else:
return True
# The concrete subclass should override this attribute.
mydir = None
@ -286,6 +297,11 @@ class TestBase(unittest2.TestCase):
@classmethod
def setUpClass(cls):
"""
Python unittest framework class setup fixture.
Do current directory manipulation.
"""
# Fail fast if 'mydir' attribute is not overridden.
if not cls.mydir or len(cls.mydir) == 0:
raise Exception("Subclasses must override the 'mydir' attribute.")
@ -301,7 +317,10 @@ class TestBase(unittest2.TestCase):
@classmethod
def tearDownClass(cls):
"""Do class-wide cleanup."""
"""
Python unittest framework class teardown fixture.
Do class-wide cleanup.
"""
# First, let's do the platform-specific cleanup.
module = __import__(sys.platform)