[Lldb-commits] [lldb] r111652 - in /lldb/trunk/test: class_types/TestClassTypes.py command_source/TestCommandSource.py dead-strip/TestDeadStrip.py lldbtest.py
Johnny Chen
johnny.chen at apple.com
Fri Aug 20 10:04:20 PDT 2010
Author: johnny
Date: Fri Aug 20 12:04:20 2010
New Revision: 111652
URL: http://llvm.org/viewvc/llvm-project?rev=111652&view=rev
Log:
Converted some more test cases to use runCmd()/expect().
Modified:
lldb/trunk/test/class_types/TestClassTypes.py
lldb/trunk/test/command_source/TestCommandSource.py
lldb/trunk/test/dead-strip/TestDeadStrip.py
lldb/trunk/test/lldbtest.py
Modified: lldb/trunk/test/class_types/TestClassTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=111652&r1=111651&r2=111652&view=diff
==============================================================================
--- lldb/trunk/test/class_types/TestClassTypes.py (original)
+++ lldb/trunk/test/class_types/TestClassTypes.py Fri Aug 20 12:04:20 2010
@@ -11,41 +11,27 @@
def test_class_types(self):
"""Test 'variable list this' when stopped on a class constructor."""
- 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 on the ctor function of class C.
- self.ci.HandleCommand("breakpoint set -f main.cpp -l 73", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint list'))
- self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: file ='main.cpp', line = 73, locations = 1"),
- BREAKPOINT_CREATED)
-
- self.ci.HandleCommand("run", res)
- self.runStarted = True
- self.assertTrue(res.Succeeded(), RUN_STOPPED)
+ self.expect("breakpoint set -f main.cpp -l 73", BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='main.cpp', line = 73, 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'])
# We should be stopped on the ctor function of class C.
- self.ci.HandleCommand("variable list this", res);
- self.assertTrue(res.Succeeded(), CMD_MSG('variable list ...'))
- self.assertTrue(res.GetOutput().startswith('(class C *const) this = '),
- VARIABLES_DISPLAYED_CORRECTLY)
+ self.expect("variable list this", VARIABLES_DISPLAYED_CORRECTLY,
+ startstr = '(class C *const) this = ')
if __name__ == '__main__':
Modified: lldb/trunk/test/command_source/TestCommandSource.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/command_source/TestCommandSource.py?rev=111652&r1=111651&r2=111652&view=diff
==============================================================================
--- lldb/trunk/test/command_source/TestCommandSource.py (original)
+++ lldb/trunk/test/command_source/TestCommandSource.py Fri Aug 20 12:04:20 2010
@@ -15,18 +15,13 @@
def test_command_source(self):
"""Test that lldb command "command source" works correctly."""
- res = self.res
# Sourcing .lldb in the current working directory, which in turn imports
# the "my" package that defines the date() function.
- self.ci.HandleCommand("command source .lldb", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('command source .lldb'))
+ self.runCmd("command source .lldb")
# Python should evaluate "my.date()" successfully.
- self.ci.HandleCommand("script my.date()", res)
- if (not res.Succeeded()):
- print res.GetError()
- self.assertTrue(res.Succeeded(), CMD_MSG('script my.date()'))
+ self.runCmd("script my.date()")
if __name__ == '__main__':
Modified: lldb/trunk/test/dead-strip/TestDeadStrip.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dead-strip/TestDeadStrip.py?rev=111652&r1=111651&r2=111652&view=diff
==============================================================================
--- lldb/trunk/test/dead-strip/TestDeadStrip.py (original)
+++ lldb/trunk/test/dead-strip/TestDeadStrip.py Fri Aug 20 12:04:20 2010
@@ -13,73 +13,46 @@
def test_dead_strip(self):
"""Test breakpoint works correctly with dead-code stripping."""
- 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 by function name f1 (live code).
- self.ci.HandleCommand("breakpoint set -s a.out -n f1", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
- self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: name = 'f1', module = a.out, locations = 1"
- ),
- BREAKPOINT_CREATED)
+ self.expect("breakpoint set -s a.out -n f1", BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: name = 'f1', module = a.out, locations = 1")
# Break by function name f2 (dead code).
- self.ci.HandleCommand("breakpoint set -s a.out -n f2", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
- self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 2: name = 'f2', module = a.out, locations = 0 "
- "(pending)"),
- BREAKPOINT_PENDING_CREATED)
+ self.expect("breakpoint set -s a.out -n f2", BREAKPOINT_PENDING_CREATED,
+ startstr = "Breakpoint created: 2: name = 'f2', module = a.out, locations = 0 (pending)")
# Break by function name f3 (live code).
- self.ci.HandleCommand("breakpoint set -s a.out -n f3", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
- self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 3: name = 'f3', module = a.out, locations = 1"
- ),
- BREAKPOINT_CREATED)
-
- self.ci.HandleCommand("run", res)
- self.runStarted = True
- self.assertTrue(res.Succeeded(), RUN_STOPPED)
+ self.expect("breakpoint set -s a.out -n f3", BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 3: name = 'f3', module = a.out, locations = 1")
+
+ self.runCmd("run", RUN_STOPPED)
# The stop reason of the thread should be breakpoint (breakpoint #1).
- self.ci.HandleCommand("thread list", res)
- output = res.GetOutput()
- self.assertTrue(res.Succeeded(), CMD_MSG('thread list'))
- self.assertTrue(output.find('state is Stopped') > 0 and
- output.find('main.c:20') > 0 and
- output.find('where = a.out`f1') > 0 and
- output.find('stop reason = breakpoint') > 0,
- STOPPED_DUE_TO_BREAKPOINT)
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['state is Stopped',
+ 'main.c:20',
+ 'where = a.out`f1',
+ 'stop reason = breakpoint'])
# The breakpoint should have a hit count of 1.
- self.ci.HandleCommand("breakpoint list 1", 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 1", BREAKPOINT_HIT_ONCE,
+ substrs = [' resolved, hit count = 1'])
- self.ci.HandleCommand("continue", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('continue'))
+ self.runCmd("continue")
# The stop reason of the thread should be breakpoint (breakpoint #3).
- self.ci.HandleCommand("thread list", res)
- output = res.GetOutput()
- self.assertTrue(res.Succeeded(), CMD_MSG('thread list'))
- self.assertTrue(output.find('state is Stopped') > 0 and
- output.find('main.c:40') > 0 and
- output.find('where = a.out`f3') > 0 and
- output.find('stop reason = breakpoint') > 0,
- STOPPED_DUE_TO_BREAKPOINT)
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['state is Stopped',
+ 'main.c:40',
+ 'where = a.out`f3',
+ 'stop reason = breakpoint'])
# The breakpoint should have a hit count of 1.
- self.ci.HandleCommand("breakpoint list 3", 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 3", BREAKPOINT_HIT_ONCE,
+ substrs = [' resolved, hit count = 1'])
if __name__ == '__main__':
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=111652&r1=111651&r2=111652&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Fri Aug 20 12:04:20 2010
@@ -126,6 +126,8 @@
if cmd.startswith("run"):
self.runStarted = True
if check:
+ if (not self.res.Succeeded()):
+ print self.res.GetError()
self.assertTrue(self.res.Succeeded(),
msg if msg else CMD_MSG(cmd))
More information about the lldb-commits
mailing list