diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 29ebc5409d7c..d083d186b65c 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -338,6 +338,9 @@ def getsource_if_available(obj): 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 @@ class TestBase(unittest2.TestCase): 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 @@ class TestBase(unittest2.TestCase): # 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 @@ class TestBase(unittest2.TestCase): 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 @@ class TestBase(unittest2.TestCase): 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") diff --git a/lldb/test/plugins/darwin.py b/lldb/test/plugins/builder_base.py similarity index 86% rename from lldb/test/plugins/darwin.py rename to lldb/test/plugins/builder_base.py index ba8528035233..1a4cf0e469dd 100644 --- a/lldb/test/plugins/darwin.py +++ b/lldb/test/plugins/builder_base.py @@ -15,8 +15,6 @@ 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 "" @@ -76,18 +74,6 @@ def buildDefault(sender=None, architecture=None, compiler=None, dictionary=None) # 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", diff --git a/lldb/test/plugins/builder_darwin.py b/lldb/test/plugins/builder_darwin.py new file mode 100644 index 000000000000..9ddbd18932cb --- /dev/null +++ b/lldb/test/plugins/builder_darwin.py @@ -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 diff --git a/lldb/test/plugins/builder_linux2.py b/lldb/test/plugins/builder_linux2.py new file mode 100644 index 000000000000..eb08b4035c22 --- /dev/null +++ b/lldb/test/plugins/builder_linux2.py @@ -0,0 +1,4 @@ +from builder_base import * + +def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None): + return False