Converted to use runCmd() and expect() for more abstraction.

llvm-svn: 111593
This commit is contained in:
Johnny Chen 2010-08-20 00:27:37 +00:00
parent d8e8a2945e
commit f85b0b866c
1 changed files with 26 additions and 47 deletions

View File

@ -11,67 +11,46 @@ class TestArrayTypes(TestBase):
def test_array_types(self): def test_array_types(self):
"""Test 'variable list var_name' on some variables with array types.""" """Test 'variable list var_name' on some variables with array types."""
res = self.res
exe = os.path.join(os.getcwd(), "a.out") exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
# Break on line 42 inside main(). # Break on line 42 inside main().
self.ci.HandleCommand("breakpoint set -f main.c -l 42", res) self.expect("breakpoint set -f main.c -l 42", BREAKPOINT_CREATED,
self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set')) startstr = "Breakpoint created: 1: file ='main.c', line = 42, locations = 1")
self.assertTrue(res.GetOutput().startswith(
"Breakpoint created: 1: file ='main.c', line = 42, locations = 1"),
BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res) self.runCmd("run", RUN_STOPPED)
self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint. # The stop reason of the thread should be breakpoint.
self.ci.HandleCommand("thread list", res) self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
#print "thread list ->", res.GetOutput() substrs = ['state is Stopped',
self.assertTrue(res.Succeeded()) 'stop reason = breakpoint'])
self.assertTrue(res.GetOutput().find('state is Stopped') > 0 and
res.GetOutput().find('stop reason = breakpoint') > 0,
STOPPED_DUE_TO_BREAKPOINT)
# The breakpoint should have a hit count of 1. # The breakpoint should have a hit count of 1.
self.ci.HandleCommand("breakpoint list", res) self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
self.assertTrue(res.Succeeded()) substrs = ['resolved, hit count = 1'])
self.assertTrue(res.GetOutput().find('resolved, hit count = 1') > 0,
BREAKPOINT_HIT_ONCE)
# Issue 'variable list' command on several array-type variables. # Issue 'variable list' command on several array-type variables.
self.ci.HandleCommand("variable list strings", res); self.expect("variable list strings", VARIABLES_DISPLAYED_CORRECTLY,
self.assertTrue(res.Succeeded(), CMD_MSG('variable list ...')) startstr = '(char *[4])',
output = res.GetOutput() substrs = ['(char *) strings[0]',
self.assertTrue(output.startswith('(char *[4])') and '(char *) strings[1]',
output.find('(char *) strings[0]') > 0 and '(char *) strings[2]',
output.find('(char *) strings[1]') > 0 and '(char *) strings[3]',
output.find('(char *) strings[2]') > 0 and 'Hello',
output.find('(char *) strings[3]') > 0 and 'Hola',
output.find('Hello') > 0 and 'Bonjour',
output.find('Hola') > 0 and 'Guten Tag'])
output.find('Bonjour') > 0 and
output.find('Guten Tag') > 0,
VARIABLES_DISPLAYED_CORRECTLY)
self.ci.HandleCommand("variable list char_16", res); self.expect("variable list char_16", VARIABLES_DISPLAYED_CORRECTLY,
self.assertTrue(res.Succeeded(), CMD_MSG('variable list ...')) substrs = ['(char) char_16[0]',
self.assertTrue(res.GetOutput().find('(char) char_16[0]') > 0 and '(char) char_16[15]'])
res.GetOutput().find('(char) char_16[15]') > 0,
VARIABLES_DISPLAYED_CORRECTLY)
self.ci.HandleCommand("variable list ushort_matrix", res); self.expect("variable list ushort_matrix", VARIABLES_DISPLAYED_CORRECTLY,
self.assertTrue(res.Succeeded(), CMD_MSG('variable list ...')) startstr = '(unsigned short [2][3])')
self.assertTrue(res.GetOutput().startswith('(unsigned short [2][3])'),
VARIABLES_DISPLAYED_CORRECTLY)
self.ci.HandleCommand("variable list long_6", res); self.expect("variable list long_6", VARIABLES_DISPLAYED_CORRECTLY,
self.assertTrue(res.Succeeded(), CMD_MSG('variable list ...')) startstr = '(long [6])')
self.assertTrue(res.GetOutput().startswith('(long [6])'),
VARIABLES_DISPLAYED_CORRECTLY)
if __name__ == '__main__': if __name__ == '__main__':