summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/test/array_types/TestArrayTypes.py79
-rw-r--r--lldb/test/array_types/main.c2
-rwxr-xr-xlldb/test/dotest.py5
-rw-r--r--lldb/test/help/TestHelp.py17
4 files changed, 96 insertions, 7 deletions
diff --git a/lldb/test/array_types/TestArrayTypes.py b/lldb/test/array_types/TestArrayTypes.py
new file mode 100644
index 00000000000..8b626a68626
--- /dev/null
+++ b/lldb/test/array_types/TestArrayTypes.py
@@ -0,0 +1,79 @@
+"""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()
diff --git a/lldb/test/array_types/main.c b/lldb/test/array_types/main.c
index b6eaf4b0d54..f395df52210 100644
--- a/lldb/test/array_types/main.c
+++ b/lldb/test/array_types/main.c
@@ -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}
};
diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py
index 9d51816d9ef..3ab116bd0a2 100755
--- a/lldb/test/dotest.py
+++ b/lldb/test/dotest.py
@@ -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')
diff --git a/lldb/test/help/TestHelp.py b/lldb/test/help/TestHelp.py
index 5b006efab8b..56ec504ff65 100644
--- a/lldb/test/help/TestHelp.py
+++ b/lldb/test/help/TestHelp.py
@@ -1,19 +1,26 @@
"""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__':
OpenPOWER on IntegriCloud