diff options
| author | Johnny Chen <johnny.chen@apple.com> | 2010-09-21 23:33:30 +0000 |
|---|---|---|
| committer | Johnny Chen <johnny.chen@apple.com> | 2010-09-21 23:33:30 +0000 |
| commit | 9c48b8d79cf0c112e481f9b564807b3fa1a44e4e (patch) | |
| tree | b4fc730e9ce8bf749a993b77177117d70c3ca879 | |
| parent | d64f9b83811e35eb582f974fb524d587e2d0e59e (diff) | |
| download | bcm5719-llvm-9c48b8d79cf0c112e481f9b564807b3fa1a44e4e.tar.gz bcm5719-llvm-9c48b8d79cf0c112e481f9b564807b3fa1a44e4e.zip | |
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.
llvm-svn: 114501
| -rw-r--r-- | lldb/test/array_types/TestArrayTypes.py | 25 | ||||
| -rw-r--r-- | lldb/test/lldbtest.py | 40 |
2 files changed, 52 insertions, 13 deletions
diff --git a/lldb/test/array_types/TestArrayTypes.py b/lldb/test/array_types/TestArrayTypes.py index ca622da97e2..f284490105a 100644 --- a/lldb/test/array_types/TestArrayTypes.py +++ b/lldb/test/array_types/TestArrayTypes.py @@ -84,6 +84,14 @@ class ArrayTypesTestCase(TestBase): 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 @@ class ArrayTypesTestCase(TestBase): 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") diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 1050e74ec55..1a4d5bd436f 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -152,8 +152,11 @@ VARIABLES_DISPLAYED_CORRECTLY = "Variable(s) displayed correctly" # # 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 @@ class TestBase(unittest2.TestCase): 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 @@ class TestBase(unittest2.TestCase): 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) + 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() + # 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 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 @@ class TestBase(unittest2.TestCase): 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.""" |

