[Lldb-commits] [lldb] r114501 - in /lldb/trunk/test: array_types/TestArrayTypes.py lldbtest.py
Johnny Chen
johnny.chen at apple.com
Tue Sep 21 16:33:30 PDT 2010
Author: johnny
Date: Tue Sep 21 18:33:30 2010
New Revision: 114501
URL: http://llvm.org/viewvc/llvm-project?rev=114501&view=rev
Log:
Added a subtest to exercise the capability of lldb Python objects to print
themselves. Right now, it tests a breakpoint both before and after it has been
resolved.
Updated lldbtest.TestBase.expect() with an additional keyword argument 'exe' (
default to True), which if set to False, will treat the mandatory first argument
as just the string to be matched/or not-matched against the golden input.
Modified:
lldb/trunk/test/array_types/TestArrayTypes.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=114501&r1=114500&r2=114501&view=diff
==============================================================================
--- lldb/trunk/test/array_types/TestArrayTypes.py (original)
+++ lldb/trunk/test/array_types/TestArrayTypes.py Tue Sep 21 18:33:30 2010
@@ -84,6 +84,14 @@
breakpoint = target.BreakpointCreateByLocation("main.c", 42)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+ bp = repr(breakpoint)
+ self.expect(bp, msg="Breakpoint looks good", exe=False,
+ substrs = ["file ='main.c'",
+ "line = 42",
+ "locations = 1"])
+ self.expect(bp, msg="Breakpoint is not resolved as yet", exe=False, matching=False,
+ substrs = ["resolved = 1"])
+
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)
@@ -91,17 +99,34 @@
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+ #procRepr = repr(self.process)
+ #print "procRepr:", procRepr
+
# The stop reason of the thread should be breakpoint.
thread = self.process.GetThreadAtIndex(0)
self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"),
STOPPED_DUE_TO_BREAKPOINT)
+ #threadRepr = repr(thread)
+ #print "threadRepr:", threadRepr
+
# The breakpoint should have a hit count of 1.
self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE)
+ bp = repr(breakpoint)
+ self.expect(bp, "Breakpoint looks good and is resolved", exe=False,
+ substrs = ["file ='main.c'",
+ "line = 42",
+ "locations = 1",
+ "resolved = 1"])
+
# Lookup the "strings" string array variable.
frame = thread.GetFrameAtIndex(0)
+ #frameRepr = repr(frame)
+ #print "frameRepr:", frameRepr
variable = frame.LookupVar("strings")
+ #varRepr = repr(variable)
+ #print "varRepr:", varRepr
self.DebugSBValue(frame, variable)
self.assertTrue(variable.GetNumChildren() == 4,
"Variable 'strings' should have 4 children")
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114501&r1=114500&r2=114501&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Tue Sep 21 18:33:30 2010
@@ -152,8 +152,11 @@
#
# And a generic "Command '%s' returns successfully" message generator.
#
-def CMD_MSG(command):
- return "Command '%s' returns successfully" % (command)
+def CMD_MSG(str, exe):
+ if exe:
+ return "Command '%s' returns successfully" % str
+ else:
+ return "'%s' compares successfully" % str
#
# Returns the enum from the input string.
@@ -402,9 +405,9 @@
if check:
self.assertTrue(self.res.Succeeded(),
- msg if msg else CMD_MSG(cmd))
+ msg if msg else CMD_MSG(cmd, True))
- def expect(self, cmd, msg=None, patterns=None, startstr=None, substrs=None, trace=False, error=False, matching=True):
+ def expect(self, str, msg=None, patterns=None, startstr=None, substrs=None, trace=False, error=False, matching=True, exe=True):
"""
Similar to runCmd; with additional expect style output matching ability.
@@ -422,19 +425,30 @@
If the keyword argument matching is set to False, it signifies that the API
client is expecting the output of the command not to match the golden
input.
+
+ Finally, the required argument 'str' represents the lldb command to be
+ sent to the command interpreter. In case the keyword argument 'exe' is
+ set to False, the 'str' is treated as a string to be matched/not-matched
+ against the golden input.
"""
trace = (True if traceAlways else trace)
- # First run the command. If we are expecting error, set check=False.
- self.runCmd(cmd, trace = (True if trace else False), check = not error)
-
- # Then compare the output against expected strings.
- output = self.res.GetError() if error else self.res.GetOutput()
-
- # If error is True, the API client expects the command to fail!
- if error:
- self.assertFalse(self.res.Succeeded(),
- "Command '" + cmd + "' is expected to fail!")
+ if exe:
+ # First run the command. If we are expecting error, set check=False.
+ self.runCmd(str, trace = (True if trace else False), check = not error)
+
+ # Then compare the output against expected strings.
+ output = self.res.GetError() if error else self.res.GetOutput()
+
+ # If error is True, the API client expects the command to fail!
+ if error:
+ self.assertFalse(self.res.Succeeded(),
+ "Command '" + str + "' is expected to fail!")
+ else:
+ # No execution required, just compare str against the golden input.
+ output = str
+ if trace:
+ print >> sys.stderr, "look at:", output
# The heading says either "Expecting" or "Not expecting".
if trace:
@@ -479,7 +493,7 @@
print >> sys.stderr
self.assertTrue(matched if matching else not matched,
- msg if msg else CMD_MSG(cmd))
+ msg if msg else CMD_MSG(str, exe))
def invoke(self, obj, name, trace=False):
"""Use reflection to call a method dynamically with no argument."""
More information about the lldb-commits
mailing list