summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2010-09-21 00:09:27 +0000
committerJohnny Chen <johnny.chen@apple.com>2010-09-21 00:09:27 +0000
commit209cdbef6474d3bfcf4fcda49f9928b92fcdef35 (patch)
tree9d2252695f11bd04de1c5abe92f49665d24b4ae1
parent7466127a4b4e2e3493108d5f747d8625faa19104 (diff)
downloadbcm5719-llvm-209cdbef6474d3bfcf4fcda49f9928b92fcdef35.tar.gz
bcm5719-llvm-209cdbef6474d3bfcf4fcda49f9928b92fcdef35.zip
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
-rw-r--r--lldb/examples/test/.lldbtest-config5
-rw-r--r--lldb/examples/test/lldbtest-stderr39
-rw-r--r--lldb/examples/test/lldbtest-stdout0
-rw-r--r--lldb/examples/test/usage-config10
-rwxr-xr-xlldb/test/dotest.py73
-rw-r--r--lldb/test/plugins/darwin.py32
6 files changed, 143 insertions, 16 deletions
diff --git a/lldb/examples/test/.lldbtest-config b/lldb/examples/test/.lldbtest-config
new file mode 100644
index 00000000000..d93ad3b108c
--- /dev/null
+++ b/lldb/examples/test/.lldbtest-config
@@ -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"]
+
diff --git a/lldb/examples/test/lldbtest-stderr b/lldb/examples/test/lldbtest-stderr
new file mode 100644
index 00000000000..7934d92835c
--- /dev/null
+++ b/lldb/examples/test/lldbtest-stderr
@@ -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
diff --git a/lldb/examples/test/lldbtest-stdout b/lldb/examples/test/lldbtest-stdout
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/lldb/examples/test/lldbtest-stdout
diff --git a/lldb/examples/test/usage-config b/lldb/examples/test/usage-config
new file mode 100644
index 00000000000..4f3d3b222f1
--- /dev/null
+++ b/lldb/examples/test/usage-config
@@ -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 $
diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py
index 653319ccb84..b765d541bee 100755
--- a/lldb/test/dotest.py
+++ b/lldb/test/dotest.py
@@ -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.
diff --git a/lldb/test/plugins/darwin.py b/lldb/test/plugins/darwin.py
index 1f10d86ab95..ee861dc3e3d 100644
--- a/lldb/test/plugins/darwin.py
+++ b/lldb/test/plugins/darwin.py
@@ -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"]
+
+ # Note the leading space character.
+ return (" ARCH=" + arch) if arch else ""
+
-def buildDefault(compiler=None):
+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
OpenPOWER on IntegriCloud