diff options
-rw-r--r-- | lldb/test/array_types/TestArrayTypes.py | 9 | ||||
-rw-r--r-- | lldb/test/bitfields/TestBitfields.py | 3 | ||||
-rw-r--r-- | lldb/test/hello_world/TestHelloWorld.py | 9 | ||||
-rw-r--r-- | lldb/test/lldbtest.py | 21 |
4 files changed, 28 insertions, 14 deletions
diff --git a/lldb/test/array_types/TestArrayTypes.py b/lldb/test/array_types/TestArrayTypes.py index 6c8fdd10d78..ca622da97e2 100644 --- a/lldb/test/array_types/TestArrayTypes.py +++ b/lldb/test/array_types/TestArrayTypes.py @@ -88,8 +88,11 @@ class ArrayTypesTestCase(TestBase): # This does not work, and results in the process stopped at dyld_start? #process = target.LaunchProcess([''], [''], os.ctermid(), False) + self.process = target.GetProcess() + self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + # The stop reason of the thread should be breakpoint. - thread = target.GetProcess().GetThreadAtIndex(0) + thread = self.process.GetThreadAtIndex(0) self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), STOPPED_DUE_TO_BREAKPOINT) @@ -138,10 +141,6 @@ class ArrayTypesTestCase(TestBase): self.assertTrue(long(child5.GetValue(frame)) == 6, "long_6[5] == 6") - # Now kill the process, and we are done. - rc = target.GetProcess().Kill() - self.assertTrue(rc.Success()) - if __name__ == '__main__': import atexit diff --git a/lldb/test/bitfields/TestBitfields.py b/lldb/test/bitfields/TestBitfields.py index 8c5ea0e8b6b..42016fef778 100644 --- a/lldb/test/bitfields/TestBitfields.py +++ b/lldb/test/bitfields/TestBitfields.py @@ -90,6 +90,9 @@ class BitfieldsTestCase(TestBase): # This does not work, and results in the process stopped at dyld_start? #process = target.LaunchProcess([''], [''], os.ctermid(), False) + self.process = target.GetProcess() + self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + # The stop reason of the thread should be breakpoint. thread = target.GetProcess().GetThreadAtIndex(0) self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), diff --git a/lldb/test/hello_world/TestHelloWorld.py b/lldb/test/hello_world/TestHelloWorld.py index 2f7ecd6d024..9fae94854ef 100644 --- a/lldb/test/hello_world/TestHelloWorld.py +++ b/lldb/test/hello_world/TestHelloWorld.py @@ -64,19 +64,16 @@ class HelloWorldTestCase(TestBase): #self.runCmd("breakpoint list") #self.runCmd("thread list") - process = target.GetProcess() - thread = process.GetThreadAtIndex(0) + self.process = target.GetProcess() + self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + thread = self.process.GetThreadAtIndex(0) self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), STOPPED_DUE_TO_BREAKPOINT) # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) - # Now kill the process, and we are done. - rc = process.Kill() - self.assertTrue(rc.Success()) - if __name__ == '__main__': import atexit diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 543041c67c2..616b33eabf1 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -124,6 +124,10 @@ else: CURRENT_EXECUTABLE_SET = "Current executable set successfully" +PROCESS_IS_VALID = "Process is valid" + +PROCESS_KILLED = "Process is killed successfully" + RUN_SUCCEEDED = "Process is launched successfully" RUN_COMPLETED = "Process exited successfully" @@ -305,6 +309,9 @@ class TestBase(unittest2.TestCase): # We want our debugger to be synchronous. self.dbg.SetAsync(False) + # There is no process associated with the debugger as yet. + self.process = None + # Retrieve the associated command interpreter instance. self.ci = self.dbg.GetCommandInterpreter() if not self.ci: @@ -314,9 +321,15 @@ class TestBase(unittest2.TestCase): self.res = lldb.SBCommandReturnObject() def tearDown(self): - # Terminate the current process being debugged. + #import traceback + #traceback.print_stack() + + # Terminate the current process being debugged, if any. if self.runStarted: - self.ci.HandleCommand("process kill", self.res) + self.runCmd("process kill", PROCESS_KILLED, check=False) + elif self.process and self.process.IsValid(): + rc = self.process.Kill() + self.assertTrue(rc.Success(), PROCESS_KILLED) del self.dbg @@ -353,7 +366,9 @@ class TestBase(unittest2.TestCase): # Process launch failed, wait some time before the next try. time.sleep(self.timeWait) - self.runStarted = running and setCookie + # Modify runStarted only if "run" or "process launch" was encountered. + if running: + self.runStarted = running and setCookie if check: self.assertTrue(self.res.Succeeded(), |