[Lldb-commits] [lldb] r133457 - in /lldb/trunk/test: lldbtest.py plugins/builder_base.py plugins/builder_darwin.py plugins/builder_linux2.py plugins/darwin.py

Peter Collingbourne peter at pcc.me.uk
Mon Jun 20 12:06:20 PDT 2011


Author: pcc
Date: Mon Jun 20 14:06:20 2011
New Revision: 133457

URL: http://llvm.org/viewvc/llvm-project?rev=133457&view=rev
Log:
Add a builder module for Linux (plus some refactoring)

Added:
    lldb/trunk/test/plugins/builder_base.py
      - copied, changed from r133456, lldb/trunk/test/plugins/darwin.py
    lldb/trunk/test/plugins/builder_darwin.py
    lldb/trunk/test/plugins/builder_linux2.py
Removed:
    lldb/trunk/test/plugins/darwin.py
Modified:
    lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=133457&r1=133456&r2=133457&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Mon Jun 20 14:06:20 2011
@@ -338,6 +338,9 @@
     except:
         return repr(obj)
 
+def builder_module():
+    return __import__("builder_" + sys.platform)
+
 class TestBase(unittest2.TestCase):
     """
     This abstract base class is meant to be subclassed.  It provides default
@@ -443,7 +446,7 @@
 
         if doCleanup:
             # First, let's do the platform-specific cleanup.
-            module = __import__(sys.platform)
+            module = builder_module()
             if not module.cleanup():
                 raise Exception("Don't know how to do cleanup")
 
@@ -717,13 +720,13 @@
 
         # Perform registered teardown cleanup.
         if doCleanup and self.doTearDownCleanup:
-            module = __import__(sys.platform)
+            module = builder_module()
             if not module.cleanup(self, dictionary=self.dict):
                 raise Exception("Don't know how to do cleanup with dictionary: " + self.dict)
 
         # In rare cases where there are multiple teardown cleanups added.
         if doCleanup and self.doTearDownCleanups:
-            module = __import__(sys.platform)
+            module = builder_module()
             if self.dicts:
                 for dict in reversed(self.dicts):
                     if not module.cleanup(self, dictionary=dict):
@@ -874,12 +877,12 @@
 
     def getArchitecture(self):
         """Returns the architecture in effect the test suite is running with."""
-        module = __import__(sys.platform)
+        module = builder_module()
         return module.getArchitecture()
 
     def getCompiler(self):
         """Returns the compiler in effect the test suite is running with."""
-        module = __import__(sys.platform)
+        module = builder_module()
         return module.getCompiler()
 
     def getRunOptions(self):
@@ -899,19 +902,19 @@
 
     def buildDefault(self, architecture=None, compiler=None, dictionary=None):
         """Platform specific way to build the default binaries."""
-        module = __import__(sys.platform)
+        module = builder_module()
         if not module.buildDefault(self, architecture, compiler, dictionary):
             raise Exception("Don't know how to build default binary")
 
     def buildDsym(self, architecture=None, compiler=None, dictionary=None):
         """Platform specific way to build binaries with dsym info."""
-        module = __import__(sys.platform)
+        module = builder_module()
         if not module.buildDsym(self, architecture, compiler, dictionary):
             raise Exception("Don't know how to build binary with dsym")
 
     def buildDwarf(self, architecture=None, compiler=None, dictionary=None):
         """Platform specific way to build binaries with dwarf maps."""
-        module = __import__(sys.platform)
+        module = builder_module()
         if not module.buildDwarf(self, architecture, compiler, dictionary):
             raise Exception("Don't know how to build binary with dwarf")
 

Copied: lldb/trunk/test/plugins/builder_base.py (from r133456, lldb/trunk/test/plugins/darwin.py)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/builder_base.py?p2=lldb/trunk/test/plugins/builder_base.py&p1=lldb/trunk/test/plugins/darwin.py&r1=133456&r2=133457&rev=133457&view=diff
==============================================================================
--- lldb/trunk/test/plugins/darwin.py (original)
+++ lldb/trunk/test/plugins/builder_base.py Mon Jun 20 14:06:20 2011
@@ -15,8 +15,6 @@
 import os
 import lldbtest
 
-#print "Hello, darwin plugin!"
-
 def getArchitecture():
     """Returns the architecture in effect the test suite is running with."""
     return os.environ["ARCH"] if "ARCH" in os.environ else ""
@@ -76,18 +74,6 @@
     # True signifies that we can handle building default.
     return True
 
-def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None):
-    """Build the binaries with dsym debug info."""
-    lldbtest.system(["/bin/sh", "-c",
-                     "make clean" + getCmdLine(dictionary)
-                     + "; make MAKE_DSYM=YES"
-                     + getArchSpec(architecture) + getCCSpec(compiler)
-                     + getCmdLine(dictionary)],
-                    sender=sender)
-
-    # True signifies that we can handle building dsym.
-    return True
-
 def buildDwarf(sender=None, architecture=None, compiler=None, dictionary=None):
     """Build the binaries with dwarf debug info."""
     lldbtest.system(["/bin/sh", "-c",

Added: lldb/trunk/test/plugins/builder_darwin.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/builder_darwin.py?rev=133457&view=auto
==============================================================================
--- lldb/trunk/test/plugins/builder_darwin.py (added)
+++ lldb/trunk/test/plugins/builder_darwin.py Mon Jun 20 14:06:20 2011
@@ -0,0 +1,18 @@
+import os
+import lldbtest
+
+from builder_base import *
+
+#print "Hello, darwin plugin!"
+
+def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None):
+    """Build the binaries with dsym debug info."""
+    lldbtest.system(["/bin/sh", "-c",
+                     "make clean" + getCmdLine(dictionary)
+                     + "; make MAKE_DSYM=YES"
+                     + getArchSpec(architecture) + getCCSpec(compiler)
+                     + getCmdLine(dictionary)],
+                    sender=sender)
+
+    # True signifies that we can handle building dsym.
+    return True

Added: lldb/trunk/test/plugins/builder_linux2.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/builder_linux2.py?rev=133457&view=auto
==============================================================================
--- lldb/trunk/test/plugins/builder_linux2.py (added)
+++ lldb/trunk/test/plugins/builder_linux2.py Mon Jun 20 14:06:20 2011
@@ -0,0 +1,4 @@
+from builder_base import *
+
+def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None):
+    return False

Removed: lldb/trunk/test/plugins/darwin.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/darwin.py?rev=133456&view=auto
==============================================================================
--- lldb/trunk/test/plugins/darwin.py (original)
+++ lldb/trunk/test/plugins/darwin.py (removed)
@@ -1,110 +0,0 @@
-"""
-If the build* function is passed the compiler argument, for example, 'llvm-gcc',
-it is passed as a make variable to the make command.  Otherwise, we check the
-LLDB_CC environment variable; if it is defined, it is passed as a make variable
-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
-import lldbtest
-
-#print "Hello, darwin plugin!"
-
-def getArchitecture():
-    """Returns the architecture in effect the test suite is running with."""
-    return os.environ["ARCH"] if "ARCH" in os.environ else ""
-
-def getCompiler():
-    """Returns the compiler in effect the test suite is running with."""
-    return os.environ["CC"] if "CC" in os.environ 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 "ARCH" in os.environ:
-        arch = os.environ["ARCH"]
-
-    # Note the leading space character.
-    return (" ARCH=" + arch) if arch else ""
-
-def getCCSpec(compiler):
-    """
-    Helper function to return the key-value string to specify the compiler
-    used for the make system.
-    """
-    cc = compiler if compiler else None
-    if not cc and "CC" in os.environ:
-        cc = os.environ["CC"]
-
-    # Note the leading space character.
-    return (" CC=" + cc) if cc else ""
-
-def getCmdLine(d):
-    """
-    Helper function to return a properly formatted command line argument(s)
-    string used for the make system.
-    """
-
-    # If d is None or an empty mapping, just return an empty string.
-    if not d:
-        return ""
-
-    cmdline = " ".join(["%s='%s'" % (k, v) for k, v in d.items()])
-
-    # Note the leading space character.
-    return " " + cmdline
-
-
-def buildDefault(sender=None, architecture=None, compiler=None, dictionary=None):
-    """Build the binaries the default way."""
-    lldbtest.system(["/bin/sh", "-c",
-                     "make clean" + getCmdLine(dictionary) + "; make"
-                     + getArchSpec(architecture) + getCCSpec(compiler)
-                     + getCmdLine(dictionary)],
-                    sender=sender)
-
-    # True signifies that we can handle building default.
-    return True
-
-def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None):
-    """Build the binaries with dsym debug info."""
-    lldbtest.system(["/bin/sh", "-c",
-                     "make clean" + getCmdLine(dictionary)
-                     + "; make MAKE_DSYM=YES"
-                     + getArchSpec(architecture) + getCCSpec(compiler)
-                     + getCmdLine(dictionary)],
-                    sender=sender)
-
-    # True signifies that we can handle building dsym.
-    return True
-
-def buildDwarf(sender=None, architecture=None, compiler=None, dictionary=None):
-    """Build the binaries with dwarf debug info."""
-    lldbtest.system(["/bin/sh", "-c",
-                     "make clean" + getCmdLine(dictionary)
-                     + "; make MAKE_DSYM=NO"
-                     + getArchSpec(architecture) + getCCSpec(compiler)
-                     + getCmdLine(dictionary)],
-                    sender=sender)
-
-    # True signifies that we can handle building dwarf.
-    return True
-
-def cleanup(sender=None, dictionary=None):
-    """Perform a platform-specific cleanup after the test."""
-    if os.path.isfile("Makefile"):
-        lldbtest.system(["/bin/sh", "-c", "make clean"+getCmdLine(dictionary)],
-                        sender=sender)
-
-    # True signifies that we can handle cleanup.
-    return True





More information about the lldb-commits mailing list