diff options
author | Johnny Chen <johnny.chen@apple.com> | 2010-08-20 18:25:15 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2010-08-20 18:25:15 +0000 |
commit | b145bbaf4b8b7d3ea0997d43d3f1bc65085a6ece (patch) | |
tree | 6f3e65fa20361591dad9a78224e781a7db9ddf74 | |
parent | 84c29a096b5e27aad4f765ac1b1c79e853c71c06 (diff) | |
download | bcm5719-llvm-b145bbaf4b8b7d3ea0997d43d3f1bc65085a6ece.tar.gz bcm5719-llvm-b145bbaf4b8b7d3ea0997d43d3f1bc65085a6ece.zip |
Added more verbose output when string match fails. Converted TestGlobalVariables.py.
llvm-svn: 111666
-rw-r--r-- | lldb/test/global_variables/TestGlobalVariables.py | 47 | ||||
-rw-r--r-- | lldb/test/lldbtest.py | 6 |
2 files changed, 22 insertions, 31 deletions
diff --git a/lldb/test/global_variables/TestGlobalVariables.py b/lldb/test/global_variables/TestGlobalVariables.py index bd9e23e43f7..c12305fd89a 100644 --- a/lldb/test/global_variables/TestGlobalVariables.py +++ b/lldb/test/global_variables/TestGlobalVariables.py @@ -11,47 +11,32 @@ class TestGlobalVariables(TestBase): def test_global_variables(self): """Test 'variable list -s -a' which omits args and shows scopes.""" - 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 20", res) - self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) - self.assertTrue(res.GetOutput().startswith( - "Breakpoint created: 1: file ='main.c', line = 20, locations = 1"), - BREAKPOINT_CREATED) + self.expect("breakpoint set -f main.c -l 20", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.c', line = 20, locations = 1") - self.ci.HandleCommand("run", res) - self.runStarted = True - self.assertTrue(res.Succeeded(), RUN_STOPPED) + 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 GLOBAL scopes are indicated for the variables. - self.ci.HandleCommand("variable list -s -a", res); - self.assertTrue(res.Succeeded(), CMD_MSG('variable list ...')) - output = res.GetOutput() - self.assertTrue(output.find('GLOBAL: g_file_static_cstr') > 0 and - output.find('g_file_static_cstr') > 0 and - output.find('GLOBAL: g_file_global_int') > 0 and - output.find('(int) 42') > 0 and - output.find('GLOBAL: g_file_global_cstr') > 0 and - output.find('g_file_global_cstr') > 0, - VARIABLES_DISPLAYED_CORRECTLY) + self.expect("variable list -s -a", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['GLOBAL: g_file_static_cstr', + '"g_file_static_cstr"', + 'GLOBAL: g_file_global_int', + '(int) 42', + 'GLOBAL: g_file_global_cstr', + '"g_file_global_cstr"']) if __name__ == '__main__': diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 3a1c6fde950..60ef05fc986 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -157,10 +157,16 @@ class TestBase(unittest2.TestCase): output = self.res.GetOutput() matched = output.startswith(startstr) if startstr else True + + if not matched and startstr and verbose: + print "Startstr not matched:", startstr + if substrs: for str in substrs: matched = output.find(str) > 0 if not matched: + if verbose: + print "Substring not matched:", str break self.assertTrue(matched, msg) |