[Lldb-commits] [lldb] r107220 - in /lldb/trunk/test: array_types/TestArrayTypes.py array_types/main.c dotest.py help/TestHelp.py
Johnny Chen
johnny.chen at apple.com
Tue Jun 29 16:10:39 PDT 2010
Author: johnny
Date: Tue Jun 29 18:10:39 2010
New Revision: 107220
URL: http://llvm.org/viewvc/llvm-project?rev=107220&view=rev
Log:
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.
Added:
lldb/trunk/test/array_types/TestArrayTypes.py
Modified:
lldb/trunk/test/array_types/main.c
lldb/trunk/test/dotest.py
lldb/trunk/test/help/TestHelp.py
Added: lldb/trunk/test/array_types/TestArrayTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=107220&view=auto
==============================================================================
--- lldb/trunk/test/array_types/TestArrayTypes.py (added)
+++ lldb/trunk/test/array_types/TestArrayTypes.py Tue Jun 29 18:10:39 2010
@@ -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()
Modified: lldb/trunk/test/array_types/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/main.c?rev=107220&r1=107219&r2=107220&view=diff
==============================================================================
--- lldb/trunk/test/array_types/main.c (original)
+++ lldb/trunk/test/array_types/main.c Tue Jun 29 18:10:39 2010
@@ -27,7 +27,7 @@
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}
};
Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=107220&r1=107219&r2=107220&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Tue Jun 29 18:10:39 2010
@@ -42,6 +42,9 @@
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 @@
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')
Modified: lldb/trunk/test/help/TestHelp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=107220&r1=107219&r2=107220&view=diff
==============================================================================
--- lldb/trunk/test/help/TestHelp.py (original)
+++ lldb/trunk/test/help/TestHelp.py Tue Jun 29 18:10:39 2010
@@ -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 @@
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 @@
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__':
More information about the lldb-commits
mailing list