[Lldb-commits] [lldb] r112682 - in /lldb/trunk/test: array_types/TestArrayTypes.py bitfields/TestBitfields.py lldbtest.py

Johnny Chen johnny.chen at apple.com
Tue Aug 31 17:15:19 PDT 2010


Author: johnny
Date: Tue Aug 31 19:15:19 2010
New Revision: 112682

URL: http://llvm.org/viewvc/llvm-project?rev=112682&view=rev
Log:
Avoid killing the inferior process twice by passing a setCookie=False keyword
argument when issuing a "run" lldb command within the test case meant to
exercise the Python APIs, but is using the command interface due to certain
reason (such as target.LaunchProcess() does not reliably bring up the inferior).

Modified:
    lldb/trunk/test/array_types/TestArrayTypes.py
    lldb/trunk/test/bitfields/TestBitfields.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=112682&r1=112681&r2=112682&view=diff
==============================================================================
--- lldb/trunk/test/array_types/TestArrayTypes.py (original)
+++ lldb/trunk/test/array_types/TestArrayTypes.py Tue Aug 31 19:15:19 2010
@@ -84,7 +84,7 @@
         breakpoint = target.BreakpointCreateByLocation("main.c", 42)
         self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
 
-        self.runCmd("run", RUN_SUCCEEDED)
+        self.runCmd("run", RUN_SUCCEEDED, setCookie=False)
         # This does not work, and results in the process stopped at dyld_start?
         #process = target.LaunchProcess([''], [''], os.ctermid(), False)
 

Modified: lldb/trunk/test/bitfields/TestBitfields.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=112682&r1=112681&r2=112682&view=diff
==============================================================================
--- lldb/trunk/test/bitfields/TestBitfields.py (original)
+++ lldb/trunk/test/bitfields/TestBitfields.py Tue Aug 31 19:15:19 2010
@@ -86,7 +86,7 @@
         breakpoint = target.BreakpointCreateByLocation("main.c", 42)
         self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
 
-        self.runCmd("run", RUN_SUCCEEDED)
+        self.runCmd("run", RUN_SUCCEEDED, setCookie=False)
         # This does not work, and results in the process stopped at dyld_start?
         #process = target.LaunchProcess([''], [''], os.ctermid(), False)
 
@@ -131,6 +131,10 @@
                         int(four.GetValue(frame), 16) == 0x0f,
                         'bits.four has type uint32_t:4, is in scope, and == 0x0f')
 
+        # 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/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=112682&r1=112681&r2=112682&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Tue Aug 31 19:15:19 2010
@@ -323,7 +323,7 @@
         # Restore old working directory.
         os.chdir(self.oldcwd)
 
-    def runCmd(self, cmd, msg=None, check=True, trace=False):
+    def runCmd(self, cmd, msg=None, check=True, trace=False, setCookie=True):
         """
         Ask the command interpreter to handle the command and then check its
         return status.
@@ -334,10 +334,9 @@
 
         trace = (True if traceAlways else trace)
 
-        self.runStarted = (cmd.startswith("run") or
-                           cmd.startswith("process launch"))
+        running = (cmd.startswith("run") or cmd.startswith("process launch"))
 
-        for i in range(self.maxLaunchCount if self.runStarted else 1):
+        for i in range(self.maxLaunchCount if running else 1):
             self.ci.HandleCommand(cmd, self.res)
 
             if trace:
@@ -350,10 +349,12 @@
             if self.res.Succeeded():
                 break
             else:
-                if self.runStarted:
+                if running:
                     # Process launch failed, wait some time before the next try.
                     time.sleep(self.timeWait)
 
+        self.runStarted = running and setCookie
+
         if check:
             self.assertTrue(self.res.Succeeded(),
                             msg if msg else CMD_MSG(cmd))





More information about the lldb-commits mailing list