Modify the test driver and lldbtest.TestBase so that the dumping of session info

now goes into a timestamp-specific directory instead of the previous .session-*
files.

[17:24:34] johnny:/Volumes/data/lldb/svn/trunk $ ls -l test/2010-10-18-16:56:12.935342
total 48
-rw-r--r--  1 johnny  admin  1695 Oct 18 16:56 TestArrayTypes.ArrayTypesTestCase.test_with_dsym_and_run_command.log
-rw-r--r--  1 johnny  admin  1652 Oct 18 16:56 TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
-rw-r--r--  1 johnny  admin  2967 Oct 18 16:56 TestBreakpointCommand.BreakpointCommandTestCase.test_with_dsym.log
-rw-r--r--  1 johnny  admin  1648 Oct 18 16:56 TestClassTypes.ClassTypesTestCase.test_with_dwarf_and_run_command.log
-rw-r--r--  1 johnny  admin  1665 Oct 18 16:56 TestClassTypesDisassembly.IterateFrameAndDisassembleTestCase.test_with_dsym_and_python_api.log
-rw-r--r--  1 johnny  admin  3873 Oct 18 16:58 TestFloatTypesExpr.FloatTypesTestCase.test_float_types_with_dsym.log
[17:24:37] johnny:/Volumes/data/lldb/svn/trunk $ 

Also, the dumping happens when a test errored in additioned to when it failed.

llvm-svn: 116778
This commit is contained in:
Johnny Chen 2010-10-19 00:25:01 +00:00
parent eac5e381cc
commit 04d2c5cb0e
2 changed files with 41 additions and 9 deletions

View File

@ -502,6 +502,15 @@ lldbLoggings()
# Install the control-c handler.
unittest2.signals.installHandler()
# Now get a timestamp string and export it as LLDB_TIMESTAMP environment var.
# This will be useful when/if we want to dump the session info of individual
# test cases later on.
#
# See also TestBase.dumpSessionInfo() in lldbtest.py.
import datetime
raw_timestamp = str(datetime.datetime.today())
os.environ["LLDB_TIMESTAMP"] = raw_timestamp.replace(' ', '-')
#
# Invoke the default TextTestRunner to run the test suite, possibly iterating
# over different configurations.
@ -611,6 +620,12 @@ for ia in range(len(archs) if iterArchs else 1):
# Now put this singleton into the lldb module namespace.
lldb.test_result = self
def addError(self, test, err):
super(LLDBTestResult, self).addError(test, err)
method = getattr(test, "markError", None)
if method:
method()
def addFailure(self, test, err):
super(LLDBTestResult, self).addFailure(test, err)
method = getattr(test, "markFailure", None)

View File

@ -411,15 +411,25 @@ class TestBase(unittest2.TestCase):
# test case specific file if test failure is encountered.
self.session = StringIO.StringIO()
# Optimistically set self.__failed__ to False initially. If the test
# failed, the session info (self.session) is then dumped into a session
# specific file for diagnosis.
# Optimistically set self.__errored__ and self.__failed__ to False
# initially. If the test errored/failed, the session info
# (self.session) is then dumped into a session specific file for
# diagnosis.
self.__errored__ = False
self.__failed__ = False
def setTearDownCleanup(self, dictionary=None):
self.dict = dictionary
self.doTearDownCleanup = True
def markError(self):
"""Callback invoked when we (the test case instance) errored."""
self.__errored__ = True
with recording(self, False) as sbuf:
# False because there's no need to write "ERROR" to the stderr twice.
# Once by the Python unittest framework, and a second time by us.
print >> sbuf, "ERROR"
def markFailure(self):
"""Callback invoked when we (the test case instance) failed."""
self.__failed__ = True
@ -430,14 +440,21 @@ class TestBase(unittest2.TestCase):
def dumpSessionInfo(self):
"""
Dump the debugger interactions leading to a test failure. This allows
for more convenient postmortem analysis.
Dump the debugger interactions leading to a test error/failure. This
allows for more convenient postmortem analysis.
"""
for test, err in lldb.test_result.errors:
if test is self:
print >> self.session, err
for test, err in lldb.test_result.failures:
if test is self:
print >> self.session, err
fname = os.path.join(os.environ["LLDB_TEST"], ".session-" + self.id())
dname = os.path.join(os.environ["LLDB_TEST"],
os.environ["LLDB_TIMESTAMP"])
if not os.path.isdir(dname):
os.mkdir(dname)
fname = os.path.join(dname, "%s.log" % self.id())
with open(fname, "w") as f:
print >> f, self.session.getvalue()
@ -462,9 +479,9 @@ class TestBase(unittest2.TestCase):
raise Exception("Don't know how to do cleanup")
# See also LLDBTestResult (dotest.py) which is a singlton class derived
# from TextTestResult and overwrites addFailure() method to allow us to
# to check the failure status here.
if self.__failed__:
# from TextTestResult and overwrites addError()/addFailure() methods to
# allow us to to check the error/failure status here.
if self.__errored__ or self.__failed__:
self.dumpSessionInfo()
def runCmd(self, cmd, msg=None, check=True, trace=False, setCookie=True):