[Lldb-commits] [lldb] r111658 - in /lldb/trunk/test: function_types/TestFunctionTypes.py lldbtest.py
Johnny Chen
johnny.chen at apple.com
Fri Aug 20 10:57:32 PDT 2010
Author: johnny
Date: Fri Aug 20 12:57:32 2010
New Revision: 111658
URL: http://llvm.org/viewvc/llvm-project?rev=111658&view=rev
Log:
Added verbose option to runCmd()/expect() in lldbtest.py. Converted TestFunctionTypes.py.
Modified:
lldb/trunk/test/function_types/TestFunctionTypes.py
lldb/trunk/test/lldbtest.py
Modified: lldb/trunk/test/function_types/TestFunctionTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/function_types/TestFunctionTypes.py?rev=111658&r1=111657&r2=111658&view=diff
==============================================================================
--- lldb/trunk/test/function_types/TestFunctionTypes.py (original)
+++ lldb/trunk/test/function_types/TestFunctionTypes.py Fri Aug 20 12:57:32 2010
@@ -11,58 +11,37 @@
def test_function_types(self):
"""Test 'callback' has function ptr type, then break on the function."""
- res = self.res
exe = os.path.join(os.getcwd(), "a.out")
- self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Break inside the main.
- self.ci.HandleCommand("breakpoint set -f main.c -l 21", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
- self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: file ='main.c', line = 21, locations = 1"),
- BREAKPOINT_CREATED)
-
- self.ci.HandleCommand("run", res)
- self.runStarted = True
- self.assertTrue(res.Succeeded(), RUN_STOPPED)
+ self.expect("breakpoint set -f main.c -l 21", BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='main.c', line = 21, locations = 1")
+
+ self.runCmd("run", RUN_STOPPED)
# The stop reason of the thread should be breakpoint.
- self.ci.HandleCommand("thread list", res)
- #print "thread list ->", res.GetOutput()
- self.assertTrue(res.Succeeded(), CMD_MSG('thread list'))
- self.assertTrue(res.GetOutput().find('state is Stopped') > 0 and
- res.GetOutput().find('stop reason = breakpoint') > 0,
- STOPPED_DUE_TO_BREAKPOINT)
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['state is Stopped',
+ 'stop reason = breakpoint'])
# The breakpoint should have a hit count of 1.
- self.ci.HandleCommand("breakpoint list", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint list'))
- self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
- BREAKPOINT_HIT_ONCE)
+ self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
+ substrs = [' resolved, hit count = 1'])
# Check that the 'callback' variable display properly.
- self.ci.HandleCommand("variable list callback", res);
- self.assertTrue(res.Succeeded(), CMD_MSG('variable list ...'))
- output = res.GetOutput()
- self.assertTrue(output.startswith('(int (*)(char const *)) callback ='),
- VARIABLES_DISPLAYED_CORRECTLY)
+ self.expect("variable list callback", VARIABLES_DISPLAYED_CORRECTLY,
+ startstr = '(int (*)(char const *)) callback =')
# And that we can break on the callback function.
- self.ci.HandleCommand("breakpoint set -n string_not_empty", res);
- self.assertTrue(res.Succeeded(), BREAKPOINT_CREATED)
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('continue'))
+ self.runCmd("breakpoint set -n string_not_empty", BREAKPOINT_CREATED)
+ self.runCmd("continue")
# Check that we do indeed stop on the string_not_empty function.
- self.ci.HandleCommand("process status", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('process status'))
- output = res.GetOutput()
- #print "process status =", output
- self.assertTrue(output.find('where = a.out`string_not_empty') > 0 and
- output.find('main.c:12') > 0 and
- output.find('stop reason = breakpoint') > 0,
- STOPPED_DUE_TO_BREAKPOINT)
+ self.expect("process status", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['where = a.out`string_not_empty',
+ 'main.c:12',
+ 'stop reason = breakpoint'])
if __name__ == '__main__':
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=111658&r1=111657&r2=111658&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Fri Aug 20 12:57:32 2010
@@ -114,7 +114,7 @@
# Restore old working directory.
os.chdir(self.oldcwd)
- def runCmd(self, cmd, msg=None, check=True):
+ def runCmd(self, cmd, msg=None, check=True, verbose=False):
"""
Ask the command interpreter to handle the command and then check its
return status.
@@ -122,16 +122,26 @@
# Fail fast if 'cmd' is not meaningful.
if not cmd or len(cmd) == 0:
raise Exception("Bad 'cmd' parameter encountered")
+
+ if verbose:
+ print "runCmd:", cmd
+
self.ci.HandleCommand(cmd, self.res)
+
if cmd.startswith("run"):
self.runStarted = True
+
+ if not self.res.Succeeded():
+ print self.res.GetError()
+
+ if verbose:
+ print "output:", self.res.GetOutput()
+
if check:
- if (not self.res.Succeeded()):
- print self.res.GetError()
self.assertTrue(self.res.Succeeded(),
msg if msg else CMD_MSG(cmd))
- def expect(self, cmd, msg, startstr=None, substrs=None):
+ def expect(self, cmd, msg, startstr=None, substrs=None, verbose=False):
"""
Similar to runCmd; with additional expect style output matching ability.
@@ -143,7 +153,7 @@
# Fail fast if 'msg' is not meaningful.
if not msg or len(msg) == 0:
raise Exception("Bad 'msg' parameter encountered")
- self.runCmd(cmd)
+ self.runCmd(cmd, verbose = (True if verbose else False))
output = self.res.GetOutput()
matched = output.startswith(startstr) if startstr else True
More information about the lldb-commits
mailing list