Skip to content
Snippets Groups Projects
Commit cb9b8579 authored by Johnny Chen's avatar Johnny Chen
Browse files

Added TestArrayTypes.py for test/array_types directory.

Also modified dotest.py so that it sets the LLDB_TEST environment variable
so that individual test cases can locate their supporting files correctly.

llvm-svn: 107220
parent 74d28bd0
No related branches found
No related tags found
No related merge requests found
"""Test breakpoint by file/line number; and list variables with array types."""
import os
import lldb
import unittest
class TestArrayTypes(unittest.TestCase):
def setUp(self):
# Save old working directory.
self.oldcwd = os.getcwd()
# Change current working directory if ${LLDB_TEST} is defined.
if ("LLDB_TEST" in os.environ):
os.chdir(os.path.join(os.environ["LLDB_TEST"], "array_types"));
self.dbg = lldb.SBDebugger.Create()
self.dbg.SetAsync(False)
self.ci = self.dbg.GetCommandInterpreter()
if not self.ci:
raise Exception('Could not get the command interpreter')
def tearDown(self):
# Restore old working directory.
os.chdir(self.oldcwd)
def test_array_types(self):
"""Test 'variable list var_name' on some variables with array types."""
res = lldb.SBCommandReturnObject()
self.ci.HandleCommand("file a.out", res)
self.assertTrue(res.Succeeded())
self.ci.HandleCommand("breakpoint set -f main.c -l 42", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
"Breakpoint created: 1: file ='main.c', line = 42, locations = 1"))
self.ci.HandleCommand("run", res)
self.assertTrue(res.Succeeded())
self.ci.HandleCommand("breakpoint list", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().find('resolved, hit count = 1'))
self.ci.HandleCommand("thread list", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().find('state is Stopped') and
res.GetOutput().find('stop reason = breakpoint'))
self.ci.HandleCommand("variable list strings", res);
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith('(char *[4])') and
res.GetOutput().find('(char *) strings[0]') and
res.GetOutput().find('(char *) strings[1]') and
res.GetOutput().find('(char *) strings[2]') and
res.GetOutput().find('(char *) strings[3]') and
res.GetOutput().find('Hello') and
res.GetOutput().find('Hola') and
res.GetOutput().find('Bonjour') and
res.GetOutput().find('Guten Tag'))
self.ci.HandleCommand("variable list char_16", res);
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().find('(char) char_16[0]') and
res.GetOutput().find('(char) char_16[15]'))
self.ci.HandleCommand("variable list ushort_matrix", res);
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith('(unsigned short [2][3])'))
self.ci.HandleCommand("variable list long_6", res);
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith('(long [6])'))
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
if __name__ == '__main__':
lldb.SBDebugger.Initialize()
unittest.main()
lldb.SBDebugger.Terminate()
......@@ -27,7 +27,7 @@ int main (int argc, char const *argv[])
short short_4[4] = { 1,2,3,4 };
short short_matrix[1][2] = { {1,2} };
unsigned short ushort_4[4] = { 1,2,3,4 };
short ushort_matrix[2][3] = {
unsigned short ushort_matrix[2][3] = {
{ 1, 2, 3},
{11,22,33}
};
......
......@@ -42,6 +42,9 @@ where options:
and:
args : specify a list of directory names to search for python Test*.py scripts
if empty, search from the curret working directory, instead
Running of this script also sets up the LLDB_TEST environment variable so that
individual test cases can locate their supporting files correctly.
"""
......@@ -54,6 +57,8 @@ def setupSysPath():
print "This script expects to reside in lldb's test directory."
sys.exit(-1)
os.environ["LLDB_TEST"] = testPath
base = os.path.abspath(os.path.join(testPath, os.pardir))
dbgPath = os.path.join(base, 'build', 'Debug', 'LLDB.framework',
'Resources', 'Python')
......
"""Test lldb help command."""
import os
import lldb
import unittest
class TestHelpCommand(unittest.TestCase):
def setUp(self):
self.debugger = lldb.SBDebugger.Create()
self.debugger.SetAsync(False)
self.ci = self.debugger.GetCommandInterpreter()
# Save old working directory.
self.oldcwd = os.getcwd()
# Change current working directory if ${LLDB_TEST} is defined.
if ("LLDB_TEST" in os.environ):
os.chdir(os.path.join(os.environ["LLDB_TEST"], "help"));
self.dbg = lldb.SBDebugger.Create()
self.dbg.SetAsync(False)
self.ci = self.dbg.GetCommandInterpreter()
if not self.ci:
raise Exception('Could not get the command interpreter')
def tearDown(self):
pass
# Restore old working directory.
os.chdir(self.oldcwd)
def test_simplehelp(self):
"""A simple test of 'help' command and its output."""
......@@ -22,7 +29,6 @@ class TestHelpCommand(unittest.TestCase):
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
'The following is a list of built-in, permanent debugger commands'))
#print res.GetOutput()
def test_help_should_not_hang_emacsshell(self):
"""'set term-width 0' should not hang the help command."""
......@@ -33,7 +39,6 @@ class TestHelpCommand(unittest.TestCase):
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
'The following is a list of built-in, permanent debugger commands'))
#print res.GetOutput()
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment