[Lldb-commits] [lldb] r112863 - in /lldb/trunk/test: array_types/TestArrayTypes.py bitfields/TestBitfields.py hello_world/TestHelloWorld.py lldbtest.py
Johnny Chen
johnny.chen at apple.com
Thu Sep 2 14:23:13 PDT 2010
Author: johnny
Date: Thu Sep 2 16:23:12 2010
New Revision: 112863
URL: http://llvm.org/viewvc/llvm-project?rev=112863&view=rev
Log:
Moved the process cleanup of Script-Bridge-based APIs into TestBase.tearDown()
method where they belong. Also fixed a logic error in maintaining the command
interface flag (runStarted) indicating whether the lldb "run"/"process launch"
command has been issued. It was erroneously cleared.
Modified the test cases to take advantage of the refactoring.
Modified:
lldb/trunk/test/array_types/TestArrayTypes.py
lldb/trunk/test/bitfields/TestBitfields.py
lldb/trunk/test/hello_world/TestHelloWorld.py
lldb/trunk/test/lldbtest.py
Modified: lldb/trunk/test/array_types/TestArrayTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=112863&r1=112862&r2=112863&view=diff
==============================================================================
--- lldb/trunk/test/array_types/TestArrayTypes.py (original)
+++ lldb/trunk/test/array_types/TestArrayTypes.py Thu Sep 2 16:23:12 2010
@@ -88,8 +88,11 @@
# 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 @@
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
Modified: lldb/trunk/test/bitfields/TestBitfields.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=112863&r1=112862&r2=112863&view=diff
==============================================================================
--- lldb/trunk/test/bitfields/TestBitfields.py (original)
+++ lldb/trunk/test/bitfields/TestBitfields.py Thu Sep 2 16:23:12 2010
@@ -90,6 +90,9 @@
# 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"),
Modified: lldb/trunk/test/hello_world/TestHelloWorld.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=112863&r1=112862&r2=112863&view=diff
==============================================================================
--- lldb/trunk/test/hello_world/TestHelloWorld.py (original)
+++ lldb/trunk/test/hello_world/TestHelloWorld.py Thu Sep 2 16:23:12 2010
@@ -64,19 +64,16 @@
#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
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=112863&r1=112862&r2=112863&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Thu Sep 2 16:23:12 2010
@@ -124,6 +124,10 @@
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 @@
# 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 @@
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 @@
# 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(),
More information about the lldb-commits
mailing list