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

Johnny Chen johnny.chen at apple.com
Fri May 6 13:30:22 PDT 2011


Author: johnny
Date: Fri May  6 15:30:22 2011
New Revision: 131011

URL: http://llvm.org/viewvc/llvm-project?rev=131011&view=rev
Log:
For a test with unexpected success status, we also dump its session info into a unique file.

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=131011&r1=131010&r2=131011&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Fri May  6 15:30:22 2011
@@ -812,7 +812,8 @@
     sdir_name = timestamp
 os.environ["LLDB_SESSION_DIRNAME"] = sdir_name
 
-sys.stderr.write("\nSession logs for test failures/errors will go into directory '%s'\n" % sdir_name)
+sys.stderr.write("\nSession logs for test failures/errors/unexpected successes"
+                 " will go into directory '%s'\n" % sdir_name)
 sys.stderr.write("Command invoked: %s\n" % getMyCommandLine())
 
 #
@@ -979,6 +980,14 @@
                 if method:
                     method()
 
+            def addUnexpectedSuccess(self, test):
+                global sdir_has_content
+                sdir_has_content = True
+                super(LLDBTestResult, self).addUnexpectedSuccess(test)
+                method = getattr(test, "markUnexpectedSuccess", None)
+                if method:
+                    method()
+
         # Invoke the test runner.
         if count == 1:
             result = unittest2.TextTestRunner(stream=sys.stderr,
@@ -998,7 +1007,8 @@
         
 
 if sdir_has_content:
-    sys.stderr.write("Session logs for test failures/errors can be found in directory '%s'\n" % sdir_name)
+    sys.stderr.write("Session logs for test failures/errors/unexpected successes"
+                     " can be found in directory '%s'\n" % sdir_name)
 
 # Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined.
 # This should not be necessary now.

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=131011&r1=131010&r2=131011&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Fri May  6 15:30:22 2011
@@ -563,9 +563,11 @@
         # 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
-        self.__expected__ = False
+        self.__errored__    = False
+        self.__failed__     = False
+        self.__expected__   = False
+        # We are also interested in unexpected success.
+        self.__unexpected__ = False
 
         # See addTearDownHook(self, hook) which allows the client to add a hook
         # function to be run during tearDown() time.
@@ -599,6 +601,15 @@
             # Once by the Python unittest framework, and a second time by us.
             print >> sbuf, "expected failure"
 
+    def markUnexpectedSuccess(self):
+        """Callback invoked when an unexpected success occurred."""
+        self.__unexpected__ = True
+        with recording(self, False) as sbuf:
+            # False because there's no need to write "unexpected success" to the
+            # stderr twice.
+            # Once by the Python unittest framework, and a second time by us.
+            print >> sbuf, "unexpected success"
+
     def dumpSessionInfo(self):
         """
         Dump the debugger interactions leading to a test error/failure.  This
@@ -628,13 +639,16 @@
         elif self.__expected__:
             pairs = lldb.test_result.expectedFailures
             prefix = 'ExpectedFailure'
+        elif self.__unexpected__:
+            prefix = "UnexpectedSuccess"
         else:
             # Simply return, there's no session info to dump!
             return
 
-        for test, traceback in pairs:
-            if test is self:
-                print >> self.session, traceback
+        if not self.__unexpected__:
+            for test, traceback in pairs:
+                if test is self:
+                    print >> self.session, traceback
 
         dname = os.path.join(os.environ["LLDB_TEST"],
                              os.environ["LLDB_SESSION_DIRNAME"])





More information about the lldb-commits mailing list