diff options
author | Johnny Chen <johnny.chen@apple.com> | 2010-08-20 21:03:09 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2010-08-20 21:03:09 +0000 |
commit | ff3d01d0b784b28d887e846b0368fbd954ede202 (patch) | |
tree | 49824106d9dcf6c756a8261c635adb5b15f371c2 | |
parent | 2b2b79eddee48e5d415d2efe4aa11577a9361ce8 (diff) | |
download | bcm5719-llvm-ff3d01d0b784b28d887e846b0368fbd954ede202.tar.gz bcm5719-llvm-ff3d01d0b784b28d887e846b0368fbd954ede202.zip |
Print the verbose output of runCmd()/expect() to stderr instead of stdout.
And converted the rest of the test cases to runCmd()/expect().
llvm-svn: 111677
-rw-r--r-- | lldb/test/lldbtest.py | 17 | ||||
-rw-r--r-- | lldb/test/load_unload/TestLoadUnload.py | 61 | ||||
-rw-r--r-- | lldb/test/order/TestOrderFile.py | 13 | ||||
-rw-r--r-- | lldb/test/persistent_variables/TestPersistentVariables.py | 31 | ||||
-rw-r--r-- | lldb/test/set_values/TestSetValues.py | 112 | ||||
-rw-r--r-- | lldb/test/stl/TestSTL.py | 50 | ||||
-rw-r--r-- | lldb/test/struct_types/TestStructTypes.py | 31 |
7 files changed, 108 insertions, 207 deletions
diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index da282d699fa..8296a72002e 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -28,6 +28,7 @@ $ """ import os +import sys import unittest2 import lldb @@ -37,7 +38,7 @@ import lldb CURRENT_EXECUTABLE_SET = "Current executable set successfully" -RUN_STOPPED = "Process is stopped successfully" +RUN_STOPPED = "Process is launched and then stopped successfully" RUN_COMPLETED = "Process exited successfully" @@ -124,18 +125,18 @@ class TestBase(unittest2.TestCase): raise Exception("Bad 'cmd' parameter encountered") if verbose: - print "runCmd:", cmd + print >> sys.stderr, "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 self.res.Succeeded(): + print >> sys.stderr, "output:", self.res.GetOutput() + else: + print >> sys.stderr, self.res.GetError() if check: self.assertTrue(self.res.Succeeded(), @@ -159,14 +160,14 @@ class TestBase(unittest2.TestCase): matched = output.startswith(startstr) if startstr else True if not matched and startstr and verbose: - print "Startstr not matched:", startstr + print >> sys.stderr, "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 + print >> sys.stderr, "Substring not matched:", str break self.assertTrue(matched, msg if msg else CMD_MSG(cmd)) diff --git a/lldb/test/load_unload/TestLoadUnload.py b/lldb/test/load_unload/TestLoadUnload.py index 91d2bdf70e1..d9c014dee40 100644 --- a/lldb/test/load_unload/TestLoadUnload.py +++ b/lldb/test/load_unload/TestLoadUnload.py @@ -13,57 +13,38 @@ class TestLoadUnload(TestBase): def test_load_unload(self): """Test breakpoint by name works correctly with dlopen'ing.""" - 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 a_function (not yet loaded). - self.ci.HandleCommand("breakpoint set -n a_function", res) - self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) - self.assertTrue(res.GetOutput().startswith( - "Breakpoint created: 1: name = 'a_function', locations = 0 " - "(pending)" - ), - BREAKPOINT_CREATED) + self.expect("breakpoint set -n a_function", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: name = 'a_function', locations = 0 (pending)") - 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 and at a_function. - 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('a_function') > 0 and - output.find('a.c:14') > 0 and - output.find('stop reason = breakpoint') > 0, - STOPPED_DUE_TO_BREAKPOINT) + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['state is Stopped', + 'a_function', + 'a.c:14', + '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 stop agaian at a_function. +# # Issue the 'contnue' command. We should stop agaian at a_function. # # The stop reason of the thread should be breakpoint and at a_function. -# self.ci.HandleCommand("thread list", res) -# output = res.GetOutput() -# self.assertTrue(res.Succeeded()) -# self.assertTrue(output.find('state is Stopped') > 0 and -# output.find('a_function') > 0 and -# output.find('a.c:14') > 0 and -# output.find('stop reason = breakpoint') > 0) - +# self.runCmd("continue") +# self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, +# substrs = ['state is Stopped', +# 'a_function', +# 'a.c:14', +# 'stop reason = breakpoint']) +# # # The breakpoint should have a hit count of 2. -# self.ci.HandleCommand("breakpoint list", res) -# self.assertTrue(res.Succeeded()) -# self.assertTrue(res.GetOutput().find(' resolved, hit count = 2') > 0) - -# self.ci.HandleCommand("continue", res) -# self.assertTrue(res.Succeeded()) +# self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, +# substrs = [' resolved, hit count = 2']) if __name__ == '__main__': diff --git a/lldb/test/order/TestOrderFile.py b/lldb/test/order/TestOrderFile.py index bd6ed54e395..d9ad6997dc8 100644 --- a/lldb/test/order/TestOrderFile.py +++ b/lldb/test/order/TestOrderFile.py @@ -14,15 +14,12 @@ class TestOrderFile(TestBase): def test_order_file(self): """Test debug symbols follow the correct order by the order file.""" - 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) # Test that the debug symbols have Function f3 before Function f1. - self.ci.HandleCommand("image dump symtab a.out", res) - self.assertTrue(res.Succeeded(), CMD_MSG('image dump')) - output = res.GetOutput() + self.runCmd("image dump symtab a.out") + output = self.res.GetOutput() mo_f3 = re.search("Function +.+f3", output) mo_f1 = re.search("Function +.+f1", output) @@ -30,9 +27,7 @@ class TestOrderFile(TestBase): self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(), "Symbols have correct order by the order file") - self.ci.HandleCommand("run", res) - self.runStarted = True - self.assertTrue(res.Succeeded(), RUN_COMPLETED) + self.runCmd("run", RUN_COMPLETED) if __name__ == '__main__': diff --git a/lldb/test/persistent_variables/TestPersistentVariables.py b/lldb/test/persistent_variables/TestPersistentVariables.py index 1c2de452838..64637e3c33f 100644 --- a/lldb/test/persistent_variables/TestPersistentVariables.py +++ b/lldb/test/persistent_variables/TestPersistentVariables.py @@ -13,38 +13,23 @@ class TestPersistentVariables(TestBase): def test_persistent_variables(self): """Test that lldb persistent variables works correctly.""" - res = self.res + self.runCmd("file ../array_types/a.out", CURRENT_EXECUTABLE_SET) - self.ci.HandleCommand("file ../array_types/a.out", res) - self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET) + self.runCmd("breakpoint set --name main") - self.ci.HandleCommand("breakpoint set --name main", res) - self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) + self.runCmd("run", RUN_STOPPED) - self.ci.HandleCommand("run", res) - self.runStarted = True - self.assertTrue(res.Succeeded(), RUN_STOPPED) - - self.ci.HandleCommand("expr int $i = 5; $i + 1", res) - self.assertTrue(res.Succeeded(), CMD_MSG('expr int $i = 5; $i + 1')) - #print res.GetOutput() + self.runCmd("expr int $i = 5; $i + 1") # $0 = (int)6 - self.ci.HandleCommand("expr $i + 3", res) - self.assertTrue(res.Succeeded(), CMD_MSG('expr $i + 3')) - #print res.GetOutput() + self.runCmd("expr $i + 3") # $1 = (int)8 - self.ci.HandleCommand("expr $1 + $0", res) - self.assertTrue(res.Succeeded(), CMD_MSG('expr $1 + $0')) - #print res.GetOutput() + self.runCmd("expr $1 + $0") # $2 = (int)14 - self.ci.HandleCommand("expr $2", res) - self.assertTrue(res.Succeeded() and - res.GetOutput().startswith("$3 = (int) 14"), - CMD_MSG('expr $2')) - #print res.GetOutput() + self.expect("expr $2", + startstr = "$3 = (int) 14") # $3 = (int)14 diff --git a/lldb/test/set_values/TestSetValues.py b/lldb/test/set_values/TestSetValues.py index 521f72fa9c9..b115dee7c56 100644 --- a/lldb/test/set_values/TestSetValues.py +++ b/lldb/test/set_values/TestSetValues.py @@ -11,111 +11,81 @@ class TestSetValues(TestBase): def test_set_values(self): """Test settings and readings of program variables.""" - 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) # Set breakpoints on several places to set program variables. - self.ci.HandleCommand("breakpoint set -f main.c -l 15", res) - self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) - self.assertTrue(res.GetOutput().startswith( - "Breakpoint created: 1: file ='main.c', line = 15, locations = 1"), - BREAKPOINT_CREATED) - self.ci.HandleCommand("breakpoint set -f main.c -l 36", res) - self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) - self.assertTrue(res.GetOutput().startswith( - "Breakpoint created: 2: file ='main.c', line = 36, locations = 1"), - BREAKPOINT_CREATED) - self.ci.HandleCommand("breakpoint set -f main.c -l 57", res) - self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) - self.assertTrue(res.GetOutput().startswith( - "Breakpoint created: 3: file ='main.c', line = 57, locations = 1"), - BREAKPOINT_CREATED) - self.ci.HandleCommand("breakpoint set -f main.c -l 78", res) - self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) - self.assertTrue(res.GetOutput().startswith( - "Breakpoint created: 4: file ='main.c', line = 78, locations = 1"), - BREAKPOINT_CREATED) - self.ci.HandleCommand("breakpoint set -f main.c -l 85", res) - self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) - self.assertTrue(res.GetOutput().startswith( - "Breakpoint created: 5: file ='main.c', line = 85, 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 15", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.c', line = 15, locations = 1") + + self.expect("breakpoint set -f main.c -l 36", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 2: file ='main.c', line = 36, locations = 1") + + self.expect("breakpoint set -f main.c -l 57", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 3: file ='main.c', line = 57, locations = 1") + + self.expect("breakpoint set -f main.c -l 78", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 4: file ='main.c', line = 78, locations = 1") + + self.expect("breakpoint set -f main.c -l 85", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 5: file ='main.c', line = 85, 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']) # main.c:15 # Check that 'variable list' displays the correct data type and value. - self.ci.HandleCommand("variable list", res); - self.assertTrue(res.Succeeded(), CMD_MSG('variable list')) - self.assertTrue(res.GetOutput().startswith("i = (char) 'a'"), - VARIABLES_DISPLAYED_CORRECTLY) + self.expect("variable list", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "i = (char) 'a'") + # TODO: # Now set variable 'i' and check that it is correctly displayed. - self.ci.HandleCommand("continue", res) - self.assertTrue(res.Succeeded(), CMD_MSG('continue')) + self.runCmd("continue") # main.c:36 # Check that 'variable list' displays the correct data type and value. - self.ci.HandleCommand("variable list", res); - self.assertTrue(res.Succeeded(), CMD_MSG('variable list')) - self.assertTrue(res.GetOutput().startswith( - "i = (short unsigned int) 0x0021"), - VARIABLES_DISPLAYED_CORRECTLY) + self.expect("variable list", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "i = (short unsigned int) 0x0021") + # TODO: # Now set variable 'i' and check that it is correctly displayed. - self.ci.HandleCommand("continue", res) - self.assertTrue(res.Succeeded(), CMD_MSG('continue')) + self.runCmd("continue") # main.c:57 # Check that 'variable list' displays the correct data type and value. - self.ci.HandleCommand("variable list", res); - self.assertTrue(res.Succeeded(), CMD_MSG('variable list')) - self.assertTrue(res.GetOutput().startswith("i = (long int) 33"), - VARIABLES_DISPLAYED_CORRECTLY) + self.expect("variable list", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "i = (long int) 33") + # TODO: # Now set variable 'i' and check that it is correctly displayed. - self.ci.HandleCommand("continue", res) - self.assertTrue(res.Succeeded(), CMD_MSG('continue')) + self.runCmd("continue") # main.c:78 # Check that 'variable list' displays the correct data type and value. - self.ci.HandleCommand("variable list", res); - self.assertTrue(res.Succeeded(), CMD_MSG('variable list')) - self.assertTrue(res.GetOutput().startswith("i = (double) 3.14159"), - VARIABLES_DISPLAYED_CORRECTLY) + self.expect("variable list", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "i = (double) 3.14159") + # TODO: # Now set variable 'i' and check that it is correctly displayed. - self.ci.HandleCommand("continue", res) - self.assertTrue(res.Succeeded(), CMD_MSG('continue')) + self.runCmd("continue") # main.c:85 # Check that 'variable list' displays the correct data type and value. - self.ci.HandleCommand("variable list", res); - self.assertTrue(res.Succeeded(), CMD_MSG('variable list')) - self.assertTrue(res.GetOutput().startswith("i = (long double) "), - VARIABLES_DISPLAYED_CORRECTLY) + self.expect("variable list", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "i = (long double) ") + # TODO: # Now set variable 'i' and check that it is correctly displayed. diff --git a/lldb/test/stl/TestSTL.py b/lldb/test/stl/TestSTL.py index 0cad84ddf23..e89c5ad6761 100644 --- a/lldb/test/stl/TestSTL.py +++ b/lldb/test/stl/TestSTL.py @@ -14,58 +14,40 @@ class TestSTL(TestBase): @unittest2.expectedFailure def test_step_into_stl(self): """Test that we can successfully step into an STL function.""" - res = self.res exe = os.path.join(os.getcwd(), "a.out") + # The following two lines, if uncommented, will enable loggings. #self.ci.HandleCommand("log enable -f /tmp/lldb.log lldb default", res) #self.assertTrue(res.Succeeded()) - self.ci.HandleCommand("file " + exe, res) - self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET) + + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break on line 13 of main.cpp. - self.ci.HandleCommand("breakpoint set -f main.cpp -l 13", res) - self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) - self.assertTrue(res.GetOutput().startswith( - "Breakpoint created: 1: file ='main.cpp', line = 13, locations = 1" - ), - BREAKPOINT_CREATED) + self.expect("breakpoint set -f main.cpp -l 13", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = 13, locations = 1") - self.ci.HandleCommand("run", res) - self.runStarted = True - self.assertTrue(res.Succeeded(), RUN_STOPPED) + self.runCmd("run", RUN_STOPPED) # Stop at 'std::string hello_world ("Hello World!");'. - self.ci.HandleCommand("thread list", res) - #print "thread list ->", res.GetOutput() - self.assertTrue(res.Succeeded(), CMD_MSG('thread list')) - output = res.GetOutput() - self.assertTrue(output.find('main.cpp:13') > 0 and - output.find('stop reason = breakpoint') > 0, - STOPPED_DUE_TO_BREAKPOINT) + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['main.cpp:13', + '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']) # Now do 'thread step-in', we should stop on the basic_string template. - self.ci.HandleCommand("thread step-in", res) - #print "thread step-in:", res.GetOutput() - # # This assertion currently always fails. # This might be related: rdar://problem/8247112. # - self.assertTrue(res.Succeeded(), CMD_MSG("thread step-in")) + #self.runCmd("thread step-in", verbose=True) + self.runCmd("thread step-in") - self.ci.HandleCommand("thread backtrace", res) - print "thread backtrace:", res.GetOutput() - self.assertTrue(res.Succeeded(), CMD_MSG('thread backtarce')) - output = res.GetOutput() - self.assertTrue(output.find('[inlined]') > 0 and - output.find('basic_string.h'), - "Command 'thread backtrace' shows we stepped in STL") + self.expect("thread backtrace", "We have stepped in STL", + substrs = ['[inlined]', + 'basic_string.h']) if __name__ == '__main__': diff --git a/lldb/test/struct_types/TestStructTypes.py b/lldb/test/struct_types/TestStructTypes.py index 6ad0180ac9b..ddd8ec820a8 100644 --- a/lldb/test/struct_types/TestStructTypes.py +++ b/lldb/test/struct_types/TestStructTypes.py @@ -15,37 +15,24 @@ class TestStructTypes(TestBase): def test_struct_types(self): """Test that break on a struct declaration has no effect.""" - 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.c -l 14", res) - self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) - self.assertTrue(res.GetOutput().startswith( - "Breakpoint created: 1: file ='main.c', line = 14, locations = 1"), - BREAKPOINT_CREATED) + self.expect("breakpoint set -f main.c -l 14", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.c', line = 14, locations = 1") - self.ci.HandleCommand("run", res) - self.runStarted = True - self.assertTrue(res.Succeeded(), RUN_STOPPED) + self.runCmd("run", RUN_STOPPED) # We should be stopped on the first executable statement within the # function where the original breakpoint was attempted. - self.ci.HandleCommand("thread backtrace", res) - #print "thread backtrace ->", res.GetOutput() - self.assertTrue(res.Succeeded(), CMD_MSG('thread backtarce')) - output = res.GetOutput() - self.assertTrue(output.find('main.c:20') > 0 and - output.find('stop reason = breakpoint') > 0, - STOPPED_DUE_TO_BREAKPOINT) + self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['main.c:20', + 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. - self.ci.HandleCommand("breakpoint list", res) - self.assertTrue(res.Succeeded()) - 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']) if __name__ == '__main__': |