[Lldb-commits] [lldb] r114380 - in /lldb/trunk: examples/test/ examples/test/.lldbtest-config examples/test/lldbtest-stderr examples/test/lldbtest-stdout examples/test/usage-config test/dotest.py test/plugins/darwin.py

Johnny Chen johnny.chen at apple.com
Mon Sep 20 17:09:27 PDT 2010


Author: johnny
Date: Mon Sep 20 19:09:27 2010
New Revision: 114380

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

Added:
    lldb/trunk/examples/test/
    lldb/trunk/examples/test/.lldbtest-config
    lldb/trunk/examples/test/lldbtest-stderr
    lldb/trunk/examples/test/lldbtest-stdout
    lldb/trunk/examples/test/usage-config
Modified:
    lldb/trunk/test/dotest.py
    lldb/trunk/test/plugins/darwin.py

Added: lldb/trunk/examples/test/.lldbtest-config
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/test/.lldbtest-config?rev=114380&view=auto
==============================================================================
--- lldb/trunk/examples/test/.lldbtest-config (added)
+++ lldb/trunk/examples/test/.lldbtest-config Mon Sep 20 19:09:27 2010
@@ -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"]
+

Added: lldb/trunk/examples/test/lldbtest-stderr
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/test/lldbtest-stderr?rev=114380&view=auto
==============================================================================
--- lldb/trunk/examples/test/lldbtest-stderr (added)
+++ lldb/trunk/examples/test/lldbtest-stderr Mon Sep 20 19:09:27 2010
@@ -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

Added: lldb/trunk/examples/test/lldbtest-stdout
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/test/lldbtest-stdout?rev=114380&view=auto
==============================================================================
    (empty)

Added: lldb/trunk/examples/test/usage-config
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/test/usage-config?rev=114380&view=auto
==============================================================================
--- lldb/trunk/examples/test/usage-config (added)
+++ lldb/trunk/examples/test/usage-config Mon Sep 20 19:09:27 2010
@@ -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 $ 

Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=114380&r1=114379&r2=114380&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Mon Sep 20 19:09:27 2010
@@ -48,6 +48,9 @@
 # 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 @@
 # Separator string.
 separator = '-' * 70
 
-# Decorated sys.stderr for our consumption.
-err = _WritelnDecorator(sys.stderr)
-
 
 def usage():
     print """
@@ -73,6 +73,7 @@
 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 @@
     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 @@
 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 @@
 # 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.

Modified: lldb/trunk/test/plugins/darwin.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/darwin.py?rev=114380&r1=114379&r2=114380&view=diff
==============================================================================
--- lldb/trunk/test/plugins/darwin.py (original)
+++ lldb/trunk/test/plugins/darwin.py Mon Sep 20 19:09:27 2010
@@ -7,6 +7,9 @@
 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 @@
 
 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 @@
     # 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





More information about the lldb-commits mailing list