[Lldb-commits] [lldb] r136649 - in /lldb/trunk/test: benchmarks/example/TestRepeatedExprs.py lldbbench.py lldbtest.py

Johnny Chen johnny.chen at apple.com
Mon Aug 1 14:13:26 PDT 2011


Author: johnny
Date: Mon Aug  1 16:13:26 2011
New Revision: 136649

URL: http://llvm.org/viewvc/llvm-project?rev=136649&view=rev
Log:
Add an abstract base class called BenchBase to be inherited by benchmark tests.
Modify the example TestRepeatedExprs.py to use BenchBase, instead.

Added:
    lldb/trunk/test/lldbbench.py
Modified:
    lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py
    lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py?rev=136649&r1=136648&r2=136649&view=diff
==============================================================================
--- lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py (original)
+++ lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py Mon Aug  1 16:13:26 2011
@@ -4,9 +4,9 @@
 import unittest2
 import lldb
 import pexpect
-from lldbtest import *
+from lldbbench import *
 
-class RepeatedExprssCase(TestBase):
+class RepeatedExprsCase(BenchBase):
 
     mydir = os.path.join("benchmarks", "example")
 

Added: lldb/trunk/test/lldbbench.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbbench.py?rev=136649&view=auto
==============================================================================
--- lldb/trunk/test/lldbbench.py (added)
+++ lldb/trunk/test/lldbbench.py Mon Aug  1 16:13:26 2011
@@ -0,0 +1,8 @@
+import lldbtest
+from lldbtest import benchmarks_test
+
+class BenchBase(lldbtest.Base):
+    """
+    Abstract base class for benchmark tests.
+    """
+

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=136649&r1=136648&r2=136649&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Mon Aug  1 16:13:26 2011
@@ -451,6 +451,14 @@
         #import traceback
         #traceback.print_stack()
 
+        # Assign the test method name to self.testMethodName.
+        #
+        # For an example of the use of this attribute, look at test/types dir.
+        # There are a bunch of test cases under test/types and we don't want the
+        # module cacheing subsystem to be confused with executable name "a.out"
+        # used for all the test cases.
+        self.testMethodName = self._testMethodName
+
         # Python API only test is decorated with @python_api_test,
         # which also sets the "__python_api_test__" attribute of the
         # function object to True.
@@ -477,6 +485,16 @@
         except AttributeError:
             pass
 
+        # This is for the case of directly spawning 'lldb'/'gdb' and interacting
+        # with it using pexpect.
+        self.child = None
+        self.child_prompt = "(lldb) "
+        # If the child is interacting with the embedded script interpreter,
+        # there are two exits required during tear down, first to quit the
+        # embedded script interpreter and second to quit the lldb command
+        # interpreter.
+        self.child_in_script_interpreter = False
+
         # These are for customized teardown cleanup.
         self.dict = None
         self.doTearDownCleanup = False
@@ -562,6 +580,21 @@
         #import traceback
         #traceback.print_stack()
 
+        # This is for the case of directly spawning 'lldb' and interacting with it
+        # using pexpect.
+        import pexpect
+        if self.child and self.child.isalive():
+            with recording(self, traceAlways) as sbuf:
+                print >> sbuf, "tearing down the child process...."
+            if self.child_in_script_interpreter:
+                self.child.sendline('quit()')
+                self.child.expect_exact(self.child_prompt)
+            self.child.sendline('quit')
+            try:
+                self.child.expect(pexpect.EOF)
+            except:
+                pass
+
         # Check and run any hook functions.
         for hook in reversed(self.hooks):
             with recording(self, traceAlways) as sbuf:
@@ -804,14 +837,6 @@
         # Works with the test driver to conditionally skip tests via decorators.
         Base.setUp(self)
 
-        # Assign the test method name to self.testMethodName.
-        #
-        # For an example of the use of this attribute, look at test/types dir.
-        # There are a bunch of test cases under test/types and we don't want the
-        # module cacheing subsystem to be confused with executable name "a.out"
-        # used for all the test cases.
-        self.testMethodName = self._testMethodName
-
         if "LLDB_EXEC" in os.environ:
             self.lldbExec = os.environ["LLDB_EXEC"]
 
@@ -847,15 +872,6 @@
         # We want our debugger to be synchronous.
         self.dbg.SetAsync(False)
 
-        # This is for the case of directly spawning 'lldb' and interacting with
-        # it using pexpect.
-        self.child = None
-        # If the child is interacting with the embedded script interpreter,
-        # there are two exits required during tear down, first to quit the
-        # embedded script interpreter and second to quit the lldb command
-        # interpreter.
-        self.child_in_script_interpreter = False
-
         # Retrieve the associated command interpreter instance.
         self.ci = self.dbg.GetCommandInterpreter()
         if not self.ci:
@@ -870,21 +886,6 @@
 
         Base.tearDown(self)
 
-        # This is for the case of directly spawning 'lldb' and interacting with it
-        # using pexpect.
-        import pexpect
-        if self.child and self.child.isalive():
-            with recording(self, traceAlways) as sbuf:
-                print >> sbuf, "tearing down the child process...."
-            if self.child_in_script_interpreter:
-                self.child.sendline('quit()')
-                self.child.expect_exact('(lldb) ')
-            self.child.sendline('quit')
-            try:
-                self.child.expect(pexpect.EOF)
-            except:
-                pass
-
         # Delete the target(s) from the debugger as a general cleanup step.
         # This includes terminating the process for each target, if any.
         # We'd like to reuse the debugger for our next test without incurring





More information about the lldb-commits mailing list