For a test with unexpected success status, we also dump its session info into a unique file.
llvm-svn: 131011
This commit is contained in:
		
							parent
							
								
									d5a7bfc51d
								
							
						
					
					
						commit
						44932b6805
					
				| 
						 | 
				
			
			@ -812,7 +812,8 @@ if not sdir_name:
 | 
			
		|||
    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 @@ for ia in range(len(archs) if iterArchs else 1):
 | 
			
		|||
                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 @@ for ia in range(len(archs) if iterArchs else 1):
 | 
			
		|||
        
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -563,9 +563,11 @@ class TestBase(unittest2.TestCase):
 | 
			
		|||
        # 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 @@ class TestBase(unittest2.TestCase):
 | 
			
		|||
            # 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 @@ class TestBase(unittest2.TestCase):
 | 
			
		|||
        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"])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue