Turn on logging for debugging purposes if ${LLDB_LOG} environment variable is

is defined.  Use ${LLDB_LOG} to specify the log file.

Create a singleton SBDebugger in the lldb namespace, that gets used when running
the entire test suite.

llvm-svn: 107445
This commit is contained in:
Johnny Chen 2010-07-01 22:52:57 +00:00
parent e71eddac59
commit 119b53ea6d
4 changed files with 35 additions and 3 deletions

View File

@ -4,15 +4,19 @@ import os, time
import lldb
import unittest
main = False
class TestArrayTypes(unittest.TestCase):
def setUp(self):
global main
# 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 = lldb.SBDebugger.Create() if main else lldb.DBG
if not self.dbg.IsValid():
raise Exception('Invalid debugger instance')
self.dbg.SetAsync(False)
@ -23,6 +27,7 @@ class TestArrayTypes(unittest.TestCase):
def tearDown(self):
# Restore old working directory.
os.chdir(self.oldcwd)
del self.dbg
def test_array_types(self):
"""Test 'variable list var_name' on some variables with array types."""
@ -87,5 +92,6 @@ class TestArrayTypes(unittest.TestCase):
if __name__ == '__main__':
lldb.SBDebugger.Initialize()
main = True
unittest.main()
lldb.SBDebugger.Terminate()

View File

@ -4,15 +4,19 @@ import os, time
import lldb
import unittest
main = False
class TestClassTypes(unittest.TestCase):
def setUp(self):
global main
# 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"], "class_types"));
self.dbg = lldb.SBDebugger.Create()
self.dbg = lldb.SBDebugger.Create() if main else lldb.DBG
if not self.dbg.IsValid():
raise Exception('Invalid debugger instance')
self.dbg.SetAsync(False)
@ -23,6 +27,7 @@ class TestClassTypes(unittest.TestCase):
def tearDown(self):
# Restore old working directory.
os.chdir(self.oldcwd)
del self.dbg
def test_class_types(self):
"""Test 'variable list this' when stopped on a class constructor."""
@ -64,5 +69,6 @@ class TestClassTypes(unittest.TestCase):
if __name__ == '__main__':
lldb.SBDebugger.Initialize()
main = True
unittest.main()
lldb.SBDebugger.Terminate()

View File

@ -141,6 +141,20 @@ for testdir in testdirs:
import lldb
lldb.SBDebugger.Initialize()
# Create a singleton SBDebugger in the lldb namespace.
lldb.DBG = lldb.SBDebugger.Create()
# Turn on logging for debugging purposes if ${LLDB_LOG} environment variable is
# is defined. Use ${LLDB_LOG} to specify the log file.
ci = lldb.DBG.GetCommandInterpreter()
res = lldb.SBCommandReturnObject()
if ("LLDB_LOG" in os.environ):
ci.HandleCommand(
"log enable -f " + os.environ["LLDB_LOG"] + " lldb default", res)
pass
if not res.Succeeded():
raise Exception('log enable failed (check your LLDB_LOG env variable...')
unittest.TextTestRunner(verbosity=verbose).run(suite)
# Add some delay before calling SBDebugger.Terminate().

View File

@ -4,15 +4,19 @@ import os, time
import lldb
import unittest
main = False
class TestHelpCommand(unittest.TestCase):
def setUp(self):
global main
# 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 = lldb.SBDebugger.Create() if main else lldb.DBG
if not self.dbg.IsValid():
raise Exception('Invalid debugger instance')
self.dbg.SetAsync(False)
@ -23,6 +27,7 @@ class TestHelpCommand(unittest.TestCase):
def tearDown(self):
# Restore old working directory.
os.chdir(self.oldcwd)
del self.dbg
def test_simplehelp(self):
"""A simple test of 'help' command and its output."""
@ -48,5 +53,6 @@ class TestHelpCommand(unittest.TestCase):
if __name__ == '__main__':
lldb.SBDebugger.Initialize()
main = True
unittest.main()
lldb.SBDebugger.Terminate()