2010-09-14 04:54:30 +08:00
|
|
|
"""
|
|
|
|
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.
|
2010-09-21 08:09:27 +08:00
|
|
|
|
|
|
|
Same idea holds for LLDB_ARCH environment variable, which maps to the ARCH make
|
|
|
|
variable.
|
2010-09-14 04:54:30 +08:00
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
2013-06-24 23:40:27 +08:00
|
|
|
import platform
|
2010-09-01 01:42:54 +08:00
|
|
|
import lldbtest
|
|
|
|
|
2011-01-27 10:58:54 +08:00
|
|
|
def getArchitecture():
|
2011-05-28 07:42:45 +08:00
|
|
|
"""Returns the architecture in effect the test suite is running with."""
|
2011-01-27 10:58:54 +08:00
|
|
|
return os.environ["ARCH"] if "ARCH" in os.environ else ""
|
|
|
|
|
2010-11-17 08:52:41 +08:00
|
|
|
def getCompiler():
|
2011-05-28 07:42:45 +08:00
|
|
|
"""Returns the compiler in effect the test suite is running with."""
|
2011-08-25 02:12:53 +08:00
|
|
|
return os.environ["CC"] if "CC" in os.environ else "clang"
|
2010-11-17 08:52:41 +08:00
|
|
|
|
2013-01-25 08:31:48 +08:00
|
|
|
def getArchFlag():
|
|
|
|
"""Returns the flag required to specify the arch"""
|
|
|
|
compiler = getCompiler()
|
|
|
|
if compiler is None:
|
|
|
|
return ""
|
|
|
|
elif "gcc" in compiler:
|
|
|
|
archflag = "-m"
|
|
|
|
elif "clang" in compiler:
|
|
|
|
archflag = "-arch "
|
|
|
|
else:
|
|
|
|
archflag = None
|
|
|
|
|
|
|
|
return (" ARCHFLAG=" + archflag) if archflag else ""
|
|
|
|
|
2013-06-24 23:40:27 +08:00
|
|
|
def getMake():
|
|
|
|
"""Returns the name for GNU make"""
|
|
|
|
if platform.system() == "FreeBSD":
|
|
|
|
return "gmake "
|
|
|
|
else:
|
|
|
|
return "make "
|
|
|
|
|
2010-09-23 07:00:20 +08:00
|
|
|
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
|
2010-10-01 01:11:58 +08:00
|
|
|
if not arch and "ARCH" in os.environ:
|
|
|
|
arch = os.environ["ARCH"]
|
2010-09-23 07:00:20 +08:00
|
|
|
|
|
|
|
# Note the leading space character.
|
|
|
|
return (" ARCH=" + arch) if arch else ""
|
|
|
|
|
2010-09-14 04:54:30 +08:00
|
|
|
def getCCSpec(compiler):
|
|
|
|
"""
|
2010-09-21 08:09:27 +08:00
|
|
|
Helper function to return the key-value string to specify the compiler
|
2010-09-14 04:54:30 +08:00
|
|
|
used for the make system.
|
|
|
|
"""
|
|
|
|
cc = compiler if compiler else None
|
2010-10-01 01:11:58 +08:00
|
|
|
if not cc and "CC" in os.environ:
|
|
|
|
cc = os.environ["CC"]
|
2010-09-14 04:54:30 +08:00
|
|
|
|
|
|
|
# Note the leading space character.
|
|
|
|
return (" CC=" + cc) if cc else ""
|
|
|
|
|
2010-09-23 07:00:20 +08:00
|
|
|
def getCmdLine(d):
|
2010-09-21 08:09:27 +08:00
|
|
|
"""
|
2010-09-23 07:00:20 +08:00
|
|
|
Helper function to return a properly formatted command line argument(s)
|
|
|
|
string used for the make system.
|
2010-09-21 08:09:27 +08:00
|
|
|
"""
|
2010-09-23 07:00:20 +08:00
|
|
|
|
|
|
|
# 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()])
|
2010-09-21 08:09:27 +08:00
|
|
|
|
|
|
|
# Note the leading space character.
|
2010-09-23 07:00:20 +08:00
|
|
|
return " " + cmdline
|
2010-09-21 08:09:27 +08:00
|
|
|
|
2010-09-14 04:54:30 +08:00
|
|
|
|
2012-02-01 09:49:50 +08:00
|
|
|
def buildDefault(sender=None, architecture=None, compiler=None, dictionary=None, clean=True):
|
2010-09-14 04:54:30 +08:00
|
|
|
"""Build the binaries the default way."""
|
2012-02-01 09:49:50 +08:00
|
|
|
if clean:
|
|
|
|
lldbtest.system(["/bin/sh", "-c",
|
2013-06-24 23:40:27 +08:00
|
|
|
getMake() + "clean" + getCmdLine(dictionary) + ";"
|
|
|
|
+ getMake()
|
2012-02-01 09:49:50 +08:00
|
|
|
+ getArchSpec(architecture) + getCCSpec(compiler)
|
|
|
|
+ getCmdLine(dictionary)],
|
|
|
|
sender=sender)
|
|
|
|
else:
|
|
|
|
lldbtest.system(["/bin/sh", "-c",
|
2013-06-24 23:40:27 +08:00
|
|
|
getMake() + getArchSpec(architecture) + getCCSpec(compiler)
|
2012-02-01 09:49:50 +08:00
|
|
|
+ getCmdLine(dictionary)],
|
|
|
|
sender=sender)
|
2010-09-04 07:49:16 +08:00
|
|
|
|
|
|
|
# True signifies that we can handle building default.
|
|
|
|
return True
|
|
|
|
|
2012-02-01 09:49:50 +08:00
|
|
|
def buildDwarf(sender=None, architecture=None, compiler=None, dictionary=None, clean=True):
|
2010-09-14 04:54:30 +08:00
|
|
|
"""Build the binaries with dwarf debug info."""
|
2012-02-01 09:49:50 +08:00
|
|
|
if clean:
|
|
|
|
lldbtest.system(["/bin/sh", "-c",
|
2013-06-24 23:40:27 +08:00
|
|
|
getMake() + "clean" + getCmdLine(dictionary)
|
|
|
|
+ ";" + getMake() + "MAKE_DSYM=NO"
|
2012-02-01 09:49:50 +08:00
|
|
|
+ getArchSpec(architecture) + getCCSpec(compiler)
|
|
|
|
+ getCmdLine(dictionary)],
|
|
|
|
sender=sender)
|
|
|
|
else:
|
|
|
|
lldbtest.system(["/bin/sh", "-c",
|
2013-06-24 23:40:27 +08:00
|
|
|
getMake() + "MAKE_DSYM=NO"
|
2012-02-01 09:49:50 +08:00
|
|
|
+ getArchSpec(architecture) + getCCSpec(compiler)
|
|
|
|
+ getCmdLine(dictionary)],
|
|
|
|
sender=sender)
|
2010-09-01 01:42:54 +08:00
|
|
|
|
2011-02-11 08:06:48 +08:00
|
|
|
# True signifies that we can handle building dwarf.
|
2010-09-01 01:42:54 +08:00
|
|
|
return True
|
2010-09-16 09:53:04 +08:00
|
|
|
|
Some re-achitecturing of the plugins interface. The caller is now required to
pass in a 'sender' arg to the buildDefault(), buildDsym(), buildDwarf(), and
cleanup() functions. The sender arg will be the test instance itself (i.e.,
an instance of TestBase). This is so that the relevant command execution can be
recorded in the TestBase.session object if sender is available.
The lldbtest.system() command has been modified to pop the 'sender' arg out of
the keyword arguments dictionary and use it as the test instance to facilitate
seesion recordings. An example is in test/types/AbstractBase.py:
def generic_type_tester(self, atoms, quotedDisplay=False):
"""Test that variables with basic types are displayed correctly."""
# First, capture the golden output emitted by the oracle, i.e., the
# series of printf statements.
go = system("./a.out", sender=self)
There are cases when sender is None. This is the case when the @classmethod is
involved in the use of these APIs. When this happens, there is no recording
into a session object, but printing on the sys.stderr is still honored if the
trace flag is ON.
An example is in test/settings/TestSettings.py:
@classmethod
def classCleanup(cls):
system(["/bin/sh", "-c", "rm -f output.txt"])
system(["/bin/sh", "-c", "rm -f stdout.txt"])
llvm-svn: 116648
2010-10-16 07:55:05 +08:00
|
|
|
def cleanup(sender=None, dictionary=None):
|
2010-09-23 07:00:20 +08:00
|
|
|
"""Perform a platform-specific cleanup after the test."""
|
2012-08-21 06:36:58 +08:00
|
|
|
#import traceback
|
|
|
|
#traceback.print_stack()
|
2010-09-16 09:53:04 +08:00
|
|
|
if os.path.isfile("Makefile"):
|
2013-06-24 23:40:27 +08:00
|
|
|
lldbtest.system(["/bin/sh", "-c",
|
|
|
|
getMake() + "clean" + getCmdLine(dictionary)],
|
Some re-achitecturing of the plugins interface. The caller is now required to
pass in a 'sender' arg to the buildDefault(), buildDsym(), buildDwarf(), and
cleanup() functions. The sender arg will be the test instance itself (i.e.,
an instance of TestBase). This is so that the relevant command execution can be
recorded in the TestBase.session object if sender is available.
The lldbtest.system() command has been modified to pop the 'sender' arg out of
the keyword arguments dictionary and use it as the test instance to facilitate
seesion recordings. An example is in test/types/AbstractBase.py:
def generic_type_tester(self, atoms, quotedDisplay=False):
"""Test that variables with basic types are displayed correctly."""
# First, capture the golden output emitted by the oracle, i.e., the
# series of printf statements.
go = system("./a.out", sender=self)
There are cases when sender is None. This is the case when the @classmethod is
involved in the use of these APIs. When this happens, there is no recording
into a session object, but printing on the sys.stderr is still honored if the
trace flag is ON.
An example is in test/settings/TestSettings.py:
@classmethod
def classCleanup(cls):
system(["/bin/sh", "-c", "rm -f output.txt"])
system(["/bin/sh", "-c", "rm -f stdout.txt"])
llvm-svn: 116648
2010-10-16 07:55:05 +08:00
|
|
|
sender=sender)
|
2010-09-16 09:53:04 +08:00
|
|
|
|
2011-02-11 08:07:26 +08:00
|
|
|
# True signifies that we can handle cleanup.
|
2010-09-16 09:53:04 +08:00
|
|
|
return True
|