summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
Diffstat (limited to 'lldb')
-rw-r--r--lldb/test/benchmarks/stepping/TestRunHooksThenSteppings.py2
-rw-r--r--lldb/test/lldbtest.py18
2 files changed, 15 insertions, 5 deletions
diff --git a/lldb/test/benchmarks/stepping/TestRunHooksThenSteppings.py b/lldb/test/benchmarks/stepping/TestRunHooksThenSteppings.py
index ec538a72fa0..b46216499eb 100644
--- a/lldb/test/benchmarks/stepping/TestRunHooksThenSteppings.py
+++ b/lldb/test/benchmarks/stepping/TestRunHooksThenSteppings.py
@@ -38,7 +38,7 @@ class RunHooksThenSteppingsBench(BenchBase):
#lldb.runHooks = ['process attach -n Mail']
# Perform the run hooks to bring lldb debugger to the desired state.
- self.runHooks(child, prompt)
+ self.runHooks(child=child, child_prompt=prompt)
# Reset the stopwatch now.
self.stopwatch.reset()
diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py
index 9952b933798..bdbc10b7077 100644
--- a/lldb/test/lldbtest.py
+++ b/lldb/test/lldbtest.py
@@ -565,9 +565,13 @@ class Base(unittest2.TestCase):
# See HideStdout(self).
self.sys_stdout_hidden = False
- def runHooks(self, child, prompt):
+ def runHooks(self, child=None, child_prompt=None, use_cmd_api=False):
"""Perform the run hooks to bring lldb debugger to the desired state.
+ By default, expect a pexpect spawned child and child prompt to be
+ supplied (use_cmd_api=False). If use_cmd_api is true, ignore the child
+ and child prompt and use self.runCmd() to run the hooks one by one.
+
Note that child is a process spawned by pexpect.spawn(). If not, your
test case is mostly likely going to fail.
@@ -575,9 +579,15 @@ class Base(unittest2.TestCase):
"""
if not lldb.runHooks:
self.skipTest("No runhooks specified for lldb, skip the test")
- for hook in lldb.runHooks:
- child.sendline(hook)
- child.expect_exact(prompt)
+ if use_cmd_api:
+ for hook in lldb.runhooks:
+ self.runCmd(hook)
+ else:
+ if not child or not child_prompt:
+ self.fail("Both child and child_prompt need to be defined.")
+ for hook in lldb.runHooks:
+ child.sendline(hook)
+ child.expect_exact(child_prompt)
def HideStdout(self):
"""Hide output to stdout from the user.
OpenPOWER on IntegriCloud