[Lldb-commits] [lldb] r116778 - in /lldb/trunk/test: dotest.py lldbtest.py

Johnny Chen johnny.chen at apple.com
Mon Oct 18 17:25:01 PDT 2010


Author: johnny
Date: Mon Oct 18 19:25:01 2010
New Revision: 116778

URL: http://llvm.org/viewvc/llvm-project?rev=116778&view=rev
Log:
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.

Modified:
    lldb/trunk/test/dotest.py
    lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=116778&r1=116777&r2=116778&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Mon Oct 18 19:25:01 2010
@@ -502,6 +502,15 @@
 # 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 @@
                 # 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)

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=116778&r1=116777&r2=116778&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Mon Oct 18 19:25:01 2010
@@ -411,15 +411,25 @@
         # 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 @@
 
     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 @@
                 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):





More information about the lldb-commits mailing list