forked from OSchip/llvm-project
Add an abstract base class called BenchBase to be inherited by benchmark tests.
Modify the example TestRepeatedExprs.py to use BenchBase, instead. llvm-svn: 136649
This commit is contained in:
parent
7f3755b5ff
commit
985e740cd9
|
@ -4,9 +4,9 @@ import os
|
||||||
import unittest2
|
import unittest2
|
||||||
import lldb
|
import lldb
|
||||||
import pexpect
|
import pexpect
|
||||||
from lldbtest import *
|
from lldbbench import *
|
||||||
|
|
||||||
class RepeatedExprssCase(TestBase):
|
class RepeatedExprsCase(BenchBase):
|
||||||
|
|
||||||
mydir = os.path.join("benchmarks", "example")
|
mydir = os.path.join("benchmarks", "example")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import lldbtest
|
||||||
|
from lldbtest import benchmarks_test
|
||||||
|
|
||||||
|
class BenchBase(lldbtest.Base):
|
||||||
|
"""
|
||||||
|
Abstract base class for benchmark tests.
|
||||||
|
"""
|
||||||
|
|
|
@ -451,6 +451,14 @@ class Base(unittest2.TestCase):
|
||||||
#import traceback
|
#import traceback
|
||||||
#traceback.print_stack()
|
#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,
|
# Python API only test is decorated with @python_api_test,
|
||||||
# which also sets the "__python_api_test__" attribute of the
|
# which also sets the "__python_api_test__" attribute of the
|
||||||
# function object to True.
|
# function object to True.
|
||||||
|
@ -477,6 +485,16 @@ class Base(unittest2.TestCase):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
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.
|
# These are for customized teardown cleanup.
|
||||||
self.dict = None
|
self.dict = None
|
||||||
self.doTearDownCleanup = False
|
self.doTearDownCleanup = False
|
||||||
|
@ -562,6 +580,21 @@ class Base(unittest2.TestCase):
|
||||||
#import traceback
|
#import traceback
|
||||||
#traceback.print_stack()
|
#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.
|
# Check and run any hook functions.
|
||||||
for hook in reversed(self.hooks):
|
for hook in reversed(self.hooks):
|
||||||
with recording(self, traceAlways) as sbuf:
|
with recording(self, traceAlways) as sbuf:
|
||||||
|
@ -804,14 +837,6 @@ class TestBase(Base):
|
||||||
# Works with the test driver to conditionally skip tests via decorators.
|
# Works with the test driver to conditionally skip tests via decorators.
|
||||||
Base.setUp(self)
|
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:
|
if "LLDB_EXEC" in os.environ:
|
||||||
self.lldbExec = os.environ["LLDB_EXEC"]
|
self.lldbExec = os.environ["LLDB_EXEC"]
|
||||||
|
|
||||||
|
@ -847,15 +872,6 @@ class TestBase(Base):
|
||||||
# We want our debugger to be synchronous.
|
# We want our debugger to be synchronous.
|
||||||
self.dbg.SetAsync(False)
|
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.
|
# Retrieve the associated command interpreter instance.
|
||||||
self.ci = self.dbg.GetCommandInterpreter()
|
self.ci = self.dbg.GetCommandInterpreter()
|
||||||
if not self.ci:
|
if not self.ci:
|
||||||
|
@ -870,21 +886,6 @@ class TestBase(Base):
|
||||||
|
|
||||||
Base.tearDown(self)
|
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.
|
# Delete the target(s) from the debugger as a general cleanup step.
|
||||||
# This includes terminating the process for each target, if any.
|
# This includes terminating the process for each target, if any.
|
||||||
# We'd like to reuse the debugger for our next test without incurring
|
# We'd like to reuse the debugger for our next test without incurring
|
||||||
|
|
Loading…
Reference in New Issue