Added the capability to source the configFile specified via the "-c" option in

order to customize the running of the test suite.  For the time being, the
supported customizations are:

o redirecting stdout and/or stderr
o specifying a list of compilers to build the test programs
o specifying a list of architectures to build the test programs for

Also checked into the examples/test directory some example files which
demonstrate the usage for the above customizations.

$ ./dotest.py -v -c ~/.lldbtest-config persistent_variables
$ cat ~/.lldbtest-config
sys.stderr = open("/tmp/lldbtest-stderr", "w")
sys.stdout = open("/tmp/lldbtest-stdout", "w")
compilers = ["gcc", "llvm-gcc"]
archs = ["x86_64", "i386"]
$ cat /tmp/lldbtest-stderr
----------------------------------------------------------------------
Collected 1 test


Configuration: arch=x86_64 compiler=gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok

----------------------------------------------------------------------
Ran 1 test in 1.397s

OK

Configuration: arch=x86_64 compiler=llvm-gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok

----------------------------------------------------------------------
Ran 1 test in 1.282s

OK

Configuration: arch=i386 compiler=gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok

----------------------------------------------------------------------
Ran 1 test in 1.297s

OK

Configuration: arch=i386 compiler=llvm-gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok

----------------------------------------------------------------------
Ran 1 test in 1.269s

OK
$ cat /tmp/lldbtest-stdout
$ 

llvm-svn: 114380
This commit is contained in:
Johnny Chen 2010-09-21 00:09:27 +00:00
parent 7466127a4b
commit 209cdbef64
6 changed files with 143 additions and 16 deletions

View File

@ -0,0 +1,5 @@
sys.stderr = open("/tmp/lldbtest-stderr", "w")
sys.stdout = open("/tmp/lldbtest-stdout", "w")
compilers = ["gcc", "llvm-gcc"]
archs = ["x86_64", "i386"]

View File

@ -0,0 +1,39 @@
----------------------------------------------------------------------
Collected 1 test
Configuration: arch=x86_64 compiler=gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.397s
OK
Configuration: arch=x86_64 compiler=llvm-gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.282s
OK
Configuration: arch=i386 compiler=gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.297s
OK
Configuration: arch=i386 compiler=llvm-gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.269s
OK

View File

View File

@ -0,0 +1,10 @@
# This is an example of using the "-c" option to source a config file to
# reassign the system stderr and stdout and to exercise different combinations
# of architectures and compilers.
#
# The config file is checked in as .lldbtest-config and the redirected stderr
# and stdout are checked in as lldbtest-stderr and lldbtest-stdout, all in the
# the same directory as this file.
[15:36:32] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -c ~/.lldbtest-config persistent_variables
[15:40:55] johnny:/Volumes/data/lldb/svn/trunk/test $

View File

@ -48,6 +48,9 @@ suite = unittest2.TestSuite()
# The config file is optional.
configFile = None
# The dictionary as a result of sourcing configFile.
config = {}
# Delay startup in order for the debugger to attach.
delay = False
@ -63,9 +66,6 @@ testdirs = [ os.getcwd() ]
# Separator string.
separator = '-' * 70
# Decorated sys.stderr for our consumption.
err = _WritelnDecorator(sys.stderr)
def usage():
print """
@ -73,6 +73,7 @@ Usage: dotest.py [option] [args]
where options:
-h : print this help message and exit (also --help)
-c : read a config file specified after this option
(see also lldb-trunk/example/test/usage-config)
-d : delay startup for 10 seconds (in order for the debugger to attach)
-i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build
tree relative to this script; use PYTHONPATH to locate the module
@ -154,6 +155,25 @@ def parseOptionsAndInitTestdirs():
if len(sys.argv) > index:
testdirs = map(os.path.abspath, sys.argv[index:])
# Source the configFile if specified.
# The side effect, if any, will be felt from this point on. An example
# config file may be these simple two lines:
#
# sys.stderr = open("/tmp/lldbtest-stderr", "w")
# sys.stdout = open("/tmp/lldbtest-stdout", "w")
#
# which will reassign the two file objects to sys.stderr and sys.stdout,
# respectively.
#
# See also lldb-trunk/example/test/usage-config.
global config
if configFile:
# Pass config (a dictionary) as the locals namespace for side-effect.
execfile(configFile, globals(), config)
#print "config:", config
#print "sys.stderr:", sys.stderr
#print "sys.stdout:", sys.stdout
def setupSysPath():
"""Add LLDB.framework/Resources/Python to the search paths for modules."""
@ -297,13 +317,15 @@ if delay:
for testdir in testdirs:
os.path.walk(testdir, visit, 'Test')
#
# Now that we have loaded all the test cases, run the whole test suite.
#
# First, write out the number of collected test cases.
err.writeln(separator)
err.writeln("Collected %d test%s" % (suite.countTestCases(),
suite.countTestCases() != 1 and "s" or ""))
err.writeln()
sys.stderr.write(separator + "\n")
sys.stderr.write("Collected %d test%s\n\n"
% (suite.countTestCases(),
suite.countTestCases() != 1 and "s" or ""))
# For the time being, let's bracket the test runner within the
# lldb.SBDebugger.Initialize()/Terminate() pair.
@ -320,8 +342,41 @@ lldbLoggings()
# Install the control-c handler.
unittest2.signals.installHandler()
# Invoke the default TextTestRunner to run the test suite.
result = unittest2.TextTestRunner(verbosity=verbose).run(suite)
#
# Invoke the default TextTestRunner to run the test suite, possibly iterating
# over different configurations.
#
iterCompilers = False
iterArchs = False
from types import *
if "archs" in config:
archs = config["archs"]
if type(archs) is ListType and len(archs) >= 1:
iterArchs = True
if "compilers" in config:
compilers = config["compilers"]
if type(compilers) is ListType and len(compilers) >= 1:
iterCompilers = True
for ia in range(len(archs) if iterArchs else 1):
archConfig = ""
if iterArchs:
os.environ["LLDB_ARCH"] = archs[ia]
archConfig = "arch=%s" % archs[ia]
for ic in range(len(compilers) if iterCompilers else 1):
if iterCompilers:
os.environ["LLDB_CC"] = compilers[ic]
configString = "%s compiler=%s" % (archConfig, compilers[ic])
else:
configString = archConfig
# Invoke the test runner.
if iterArchs or iterCompilers:
sys.stderr.write("\nConfiguration: " + configString + "\n")
result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose).run(suite)
# Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined.
# This should not be necessary now.

View File

@ -7,6 +7,9 @@ to the make command.
If neither the compiler keyword argument nor the LLDB_CC environment variable is
specified, no CC make variable is passed to the make command. The Makefile gets
to define the default CC being used.
Same idea holds for LLDB_ARCH environment variable, which maps to the ARCH make
variable.
"""
import os
@ -16,7 +19,7 @@ import lldbtest
def getCCSpec(compiler):
"""
Helper function to return the key-value pair string to specify the compiler
Helper function to return the key-value string to specify the compiler
used for the make system.
"""
cc = compiler if compiler else None
@ -26,27 +29,42 @@ def getCCSpec(compiler):
# Note the leading space character.
return (" CC=" + cc) if cc else ""
def getArchSpec(architecture):
"""
Helper function to return the key-value string to specify the architecture
used for the make system.
"""
arch = architecture if architecture else None
if not arch and "LLDB_ARCH" in os.environ:
arch = os.environ["LLDB_ARCH"]
def buildDefault(compiler=None):
# Note the leading space character.
return (" ARCH=" + arch) if arch else ""
def buildDefault(architecture=None, compiler=None):
"""Build the binaries the default way."""
lldbtest.system(["/bin/sh", "-c",
"make clean; make" + getCCSpec(compiler)])
"make clean; make"
+ getArchSpec(architecture) + getCCSpec(compiler)])
# True signifies that we can handle building default.
return True
def buildDsym(compiler=None):
def buildDsym(architecture=None, compiler=None):
"""Build the binaries with dsym debug info."""
lldbtest.system(["/bin/sh", "-c",
"make clean; make MAKE_DSYM=YES" + getCCSpec(compiler)])
"make clean; make MAKE_DSYM=YES"
+ getArchSpec(architecture) + getCCSpec(compiler)])
# True signifies that we can handle building dsym.
return True
def buildDwarf(compiler=None):
def buildDwarf(architecture=None, compiler=None):
"""Build the binaries with dwarf debug info."""
lldbtest.system(["/bin/sh", "-c",
"make clean; make MAKE_DSYM=NO" + getCCSpec(compiler)])
"make clean; make MAKE_DSYM=NO"
+ getArchSpec(architecture) + getCCSpec(compiler)])
# True signifies that we can handle building dsym.
return True