[Lldb-commits] [lldb] r107445 - in /lldb/trunk/test: array_types/TestArrayTypes.py class_types/TestClassTypes.py dotest.py help/TestHelp.py

Johnny Chen johnny.chen at apple.com
Thu Jul 1 15:52:57 PDT 2010


Author: johnny
Date: Thu Jul  1 17:52:57 2010
New Revision: 107445

URL: http://llvm.org/viewvc/llvm-project?rev=107445&view=rev
Log:
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.

Modified:
    lldb/trunk/test/array_types/TestArrayTypes.py
    lldb/trunk/test/class_types/TestClassTypes.py
    lldb/trunk/test/dotest.py
    lldb/trunk/test/help/TestHelp.py

Modified: lldb/trunk/test/array_types/TestArrayTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=107445&r1=107444&r2=107445&view=diff
==============================================================================
--- lldb/trunk/test/array_types/TestArrayTypes.py (original)
+++ lldb/trunk/test/array_types/TestArrayTypes.py Thu Jul  1 17:52:57 2010
@@ -4,15 +4,19 @@
 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 @@
     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 @@
 
 if __name__ == '__main__':
     lldb.SBDebugger.Initialize()
+    main = True
     unittest.main()
     lldb.SBDebugger.Terminate()

Modified: lldb/trunk/test/class_types/TestClassTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=107445&r1=107444&r2=107445&view=diff
==============================================================================
--- lldb/trunk/test/class_types/TestClassTypes.py (original)
+++ lldb/trunk/test/class_types/TestClassTypes.py Thu Jul  1 17:52:57 2010
@@ -4,15 +4,19 @@
 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 @@
     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 @@
 
 if __name__ == '__main__':
     lldb.SBDebugger.Initialize()
+    main = True
     unittest.main()
     lldb.SBDebugger.Terminate()

Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=107445&r1=107444&r2=107445&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Thu Jul  1 17:52:57 2010
@@ -141,6 +141,20 @@
 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().

Modified: lldb/trunk/test/help/TestHelp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=107445&r1=107444&r2=107445&view=diff
==============================================================================
--- lldb/trunk/test/help/TestHelp.py (original)
+++ lldb/trunk/test/help/TestHelp.py Thu Jul  1 17:52:57 2010
@@ -4,15 +4,19 @@
 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 @@
     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 @@
 
 if __name__ == '__main__':
     lldb.SBDebugger.Initialize()
+    main = True
     unittest.main()
     lldb.SBDebugger.Terminate()





More information about the lldb-commits mailing list