Factored the "continue" command execution of the inferior process as part of the
cleanup before finish into the test fixture in lldbtest.TestBase.tearDown().
Derivatives of TestBase is responsible for setting self.runStarted to True if an
inferior process has been started.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@111188 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/array_types/TestArrayTypes.py b/test/array_types/TestArrayTypes.py
index b3c8a5f..a51f2cd 100644
--- a/test/array_types/TestArrayTypes.py
+++ b/test/array_types/TestArrayTypes.py
@@ -24,7 +24,7 @@
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- #time.sleep(0.1)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint.
@@ -73,9 +73,6 @@
self.assertTrue(res.GetOutput().startswith('(long [6])'),
VARIABLES_DISPLAYED_CORRECTLY)
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded())
-
if __name__ == '__main__':
import atexit
diff --git a/test/class_types/TestClassTypes.py b/test/class_types/TestClassTypes.py
index 7ade905..eff6ab3 100644
--- a/test/class_types/TestClassTypes.py
+++ b/test/class_types/TestClassTypes.py
@@ -24,7 +24,7 @@
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- #time.sleep(0.1)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint.
@@ -47,9 +47,6 @@
self.assertTrue(res.GetOutput().startswith('(class C *const) this = '),
VARIABLES_DISPLAYED_CORRECTLY)
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded())
-
if __name__ == '__main__':
import atexit
diff --git a/test/dead-strip/TestDeadStrip.py b/test/dead-strip/TestDeadStrip.py
index d49987b..d705bef 100644
--- a/test/dead-strip/TestDeadStrip.py
+++ b/test/dead-strip/TestDeadStrip.py
@@ -43,7 +43,7 @@
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- #time.sleep(0.1)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint (breakpoint #1).
@@ -81,9 +81,6 @@
self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
BREAKPOINT_HIT_ONCE)
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded())
-
if __name__ == '__main__':
import atexit
diff --git a/test/function_types/TestFunctionTypes.py b/test/function_types/TestFunctionTypes.py
index 76d27d9..eef4ede 100644
--- a/test/function_types/TestFunctionTypes.py
+++ b/test/function_types/TestFunctionTypes.py
@@ -24,7 +24,7 @@
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- #time.sleep(0.1)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint.
@@ -64,9 +64,6 @@
output.find('stop reason = breakpoint') > 0,
STOPPED_DUE_TO_BREAKPOINT)
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded())
-
if __name__ == '__main__':
import atexit
diff --git a/test/global_variables/TestGlobalVariables.py b/test/global_variables/TestGlobalVariables.py
index 0cc557f..ceb7c4d 100644
--- a/test/global_variables/TestGlobalVariables.py
+++ b/test/global_variables/TestGlobalVariables.py
@@ -24,7 +24,7 @@
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- #time.sleep(0.1)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint.
@@ -53,9 +53,6 @@
output.find('g_file_global_cstr') > 0,
VARIABLES_DISPLAYED_CORRECTLY)
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded())
-
if __name__ == '__main__':
import atexit
diff --git a/test/help/TestHelp.py b/test/help/TestHelp.py
index e0782d6..1989eb5 100644
--- a/test/help/TestHelp.py
+++ b/test/help/TestHelp.py
@@ -17,7 +17,6 @@
"""A simple test of 'help' command and its output."""
res = lldb.SBCommandReturnObject()
self.ci.HandleCommand("help", res)
- #time.sleep(0.1)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
'The following is a list of built-in, permanent debugger commands'),
@@ -27,10 +26,8 @@
"""Command 'set term-width 0' should not hang the help command."""
res = lldb.SBCommandReturnObject()
self.ci.HandleCommand("set term-width 0", res)
- #time.sleep(0.1)
self.assertTrue(res.Succeeded(), CMD_MSG('set term-width 0'))
self.ci.HandleCommand("help", res)
- #time.sleep(0.1)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
'The following is a list of built-in, permanent debugger commands'),
diff --git a/test/lldbtest.py b/test/lldbtest.py
index 1987faa..75f7e51 100644
--- a/test/lldbtest.py
+++ b/test/lldbtest.py
@@ -64,6 +64,9 @@
# The concrete subclass should override this attribute.
mydir = None
+ # State pertaining to the inferior process, if any.
+ runStarted = False
+
def setUp(self):
#import traceback
#traceback.print_stack()
@@ -101,6 +104,10 @@
def tearDown(self):
+ # Finish the inferior process, if it was "run" previously.
+ if self.runStarted:
+ self.ci.HandleCommand("continue", self.res)
+
del self.dbg
# Restore old working directory.
diff --git a/test/load_unload/TestLoadUnload.py b/test/load_unload/TestLoadUnload.py
index 65da301..16629e5 100644
--- a/test/load_unload/TestLoadUnload.py
+++ b/test/load_unload/TestLoadUnload.py
@@ -28,7 +28,7 @@
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- #time.sleep(0.1)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint and at a_function.
@@ -47,9 +47,6 @@
self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
BREAKPOINT_HIT_ONCE)
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded())
-
# # We should stop agaian at a_function.
# # The stop reason of the thread should be breakpoint and at a_function.
# self.ci.HandleCommand("thread list", res)
diff --git a/test/order/TestOrderFile.py b/test/order/TestOrderFile.py
index 83c801e..031c2ee 100644
--- a/test/order/TestOrderFile.py
+++ b/test/order/TestOrderFile.py
@@ -31,6 +31,7 @@
"Symbols have correct order by the order file")
self.ci.HandleCommand("run", res)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_COMPLETED)
diff --git a/test/persistent_variables/TestPersistentVariables.py b/test/persistent_variables/TestPersistentVariables.py
index c09c816..8aff13a 100644
--- a/test/persistent_variables/TestPersistentVariables.py
+++ b/test/persistent_variables/TestPersistentVariables.py
@@ -22,6 +22,7 @@
self.assertTrue(res.Succeeded())
self.ci.HandleCommand("run", res)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
self.ci.HandleCommand("expr int $i = 5; $i + 1", res)
@@ -48,6 +49,7 @@
self.ci.HandleCommand("continue", res)
self.ci.HandleCommand("quit", res)
+ self.runStarted = False
if __name__ == '__main__':
diff --git a/test/set_values/TestSetValues.py b/test/set_values/TestSetValues.py
index ec17d1d..ac8bd3c 100644
--- a/test/set_values/TestSetValues.py
+++ b/test/set_values/TestSetValues.py
@@ -44,7 +44,7 @@
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- #time.sleep(0.1)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint.
@@ -119,9 +119,6 @@
# TODO:
# Now set variable 'i' and check that it is correctly displayed.
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded())
-
if __name__ == '__main__':
import atexit
diff --git a/test/stl/TestSTL.py b/test/stl/TestSTL.py
index 15421a6..e909e51 100644
--- a/test/stl/TestSTL.py
+++ b/test/stl/TestSTL.py
@@ -31,7 +31,7 @@
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- #time.sleep(0.1)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# Stop at 'std::string hello_world ("Hello World!");'.
@@ -70,9 +70,6 @@
output.find('stop reason = step in,') > 0,
"Command 'thread backtrace' shows we stepped in STL")
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded())
-
if __name__ == '__main__':
import atexit
diff --git a/test/struct_types/TestStructTypes.py b/test/struct_types/TestStructTypes.py
index f49d117..df83148 100644
--- a/test/struct_types/TestStructTypes.py
+++ b/test/struct_types/TestStructTypes.py
@@ -28,7 +28,7 @@
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- #time.sleep(0.1)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# We should be stopped on the first executable statement within the
@@ -47,9 +47,6 @@
self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
BREAKPOINT_HIT_ONCE)
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded())
-
if __name__ == '__main__':
import atexit
diff --git a/test/unsigned_types/TestUnsignedTypes.py b/test/unsigned_types/TestUnsignedTypes.py
index e1e99ec..91eb91e 100644
--- a/test/unsigned_types/TestUnsignedTypes.py
+++ b/test/unsigned_types/TestUnsignedTypes.py
@@ -28,7 +28,7 @@
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- #time.sleep(0.1)
+ self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint.
@@ -66,9 +66,6 @@
VARIABLES_DISPLAYED_CORRECTLY
)
-
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded())
if __name__ == '__main__':