hanchenye-llvm-project/lldb/test/plugins/builder_base.py

126 lines
4.2 KiB
Python
Raw Normal View History

Extend the build mechanism to allow for specifying the compiler used to build the binaries. 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. -------------------------------------------------------------------------------- Example usage follows: o Via the keyword argument: class ArrayTypesTestCase(TestBase): mydir = "array_types" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test 'frame variable var_name' on some variables with array types.""" self.buildDsym(compiler='llvm-gcc') self.array_types() ... o Via LLDB_CC environment variable: $ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types ---------------------------------------------------------------------- Collected 4 tests test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']] output: rm -rf "a.out" "a.out.dSYM" main.o main.d llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c llvm-gcc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" /usr/bin/dsymutil -o "a.out.dSYM" "a.out" ... llvm-svn: 113781
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.
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
2010-09-21 08:09:27 +08:00
Same idea holds for LLDB_ARCH environment variable, which maps to the ARCH make
variable.
Extend the build mechanism to allow for specifying the compiler used to build the binaries. 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. -------------------------------------------------------------------------------- Example usage follows: o Via the keyword argument: class ArrayTypesTestCase(TestBase): mydir = "array_types" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test 'frame variable var_name' on some variables with array types.""" self.buildDsym(compiler='llvm-gcc') self.array_types() ... o Via LLDB_CC environment variable: $ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types ---------------------------------------------------------------------- Collected 4 tests test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']] output: rm -rf "a.out" "a.out.dSYM" main.o main.d llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c llvm-gcc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" /usr/bin/dsymutil -o "a.out.dSYM" "a.out" ... llvm-svn: 113781
2010-09-14 04:54:30 +08:00
"""
import os
import lldbtest
def getArchitecture():
2011-05-28 07:42:45 +08:00
"""Returns the architecture in effect the test suite is running with."""
return os.environ["ARCH"] if "ARCH" in os.environ else ""
def getCompiler():
2011-05-28 07:42:45 +08:00
"""Returns the compiler in effect the test suite is running with."""
return os.environ["CC"] if "CC" in os.environ else "clang"
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 ""
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 ""
Extend the build mechanism to allow for specifying the compiler used to build the binaries. 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. -------------------------------------------------------------------------------- Example usage follows: o Via the keyword argument: class ArrayTypesTestCase(TestBase): mydir = "array_types" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test 'frame variable var_name' on some variables with array types.""" self.buildDsym(compiler='llvm-gcc') self.array_types() ... o Via LLDB_CC environment variable: $ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types ---------------------------------------------------------------------- Collected 4 tests test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']] output: rm -rf "a.out" "a.out.dSYM" main.o main.d llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c llvm-gcc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" /usr/bin/dsymutil -o "a.out.dSYM" "a.out" ... llvm-svn: 113781
2010-09-14 04:54:30 +08:00
def getCCSpec(compiler):
"""
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
2010-09-21 08:09:27 +08:00
Helper function to return the key-value string to specify the compiler
Extend the build mechanism to allow for specifying the compiler used to build the binaries. 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. -------------------------------------------------------------------------------- Example usage follows: o Via the keyword argument: class ArrayTypesTestCase(TestBase): mydir = "array_types" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test 'frame variable var_name' on some variables with array types.""" self.buildDsym(compiler='llvm-gcc') self.array_types() ... o Via LLDB_CC environment variable: $ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types ---------------------------------------------------------------------- Collected 4 tests test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']] output: rm -rf "a.out" "a.out.dSYM" main.o main.d llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c llvm-gcc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" /usr/bin/dsymutil -o "a.out.dSYM" "a.out" ... llvm-svn: 113781
2010-09-14 04:54:30 +08:00
used for the make system.
"""
cc = compiler if compiler else None
if not cc and "CC" in os.environ:
cc = os.environ["CC"]
Extend the build mechanism to allow for specifying the compiler used to build the binaries. 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. -------------------------------------------------------------------------------- Example usage follows: o Via the keyword argument: class ArrayTypesTestCase(TestBase): mydir = "array_types" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test 'frame variable var_name' on some variables with array types.""" self.buildDsym(compiler='llvm-gcc') self.array_types() ... o Via LLDB_CC environment variable: $ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types ---------------------------------------------------------------------- Collected 4 tests test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']] output: rm -rf "a.out" "a.out.dSYM" main.o main.d llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c llvm-gcc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" /usr/bin/dsymutil -o "a.out.dSYM" "a.out" ... llvm-svn: 113781
2010-09-14 04:54:30 +08:00
# Note the leading space character.
return (" CC=" + cc) if cc else ""
def getCmdLine(d):
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
2010-09-21 08:09:27 +08:00
"""
Helper function to return a properly formatted command line argument(s)
string used for the make system.
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
2010-09-21 08:09:27 +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()])
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
2010-09-21 08:09:27 +08:00
# Note the leading space character.
return " " + cmdline
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
2010-09-21 08:09:27 +08:00
Extend the build mechanism to allow for specifying the compiler used to build the binaries. 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. -------------------------------------------------------------------------------- Example usage follows: o Via the keyword argument: class ArrayTypesTestCase(TestBase): mydir = "array_types" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test 'frame variable var_name' on some variables with array types.""" self.buildDsym(compiler='llvm-gcc') self.array_types() ... o Via LLDB_CC environment variable: $ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types ---------------------------------------------------------------------- Collected 4 tests test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']] output: rm -rf "a.out" "a.out.dSYM" main.o main.d llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c llvm-gcc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" /usr/bin/dsymutil -o "a.out.dSYM" "a.out" ... llvm-svn: 113781
2010-09-14 04:54:30 +08:00
def buildDefault(sender=None, architecture=None, compiler=None, dictionary=None, clean=True):
Extend the build mechanism to allow for specifying the compiler used to build the binaries. 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. -------------------------------------------------------------------------------- Example usage follows: o Via the keyword argument: class ArrayTypesTestCase(TestBase): mydir = "array_types" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test 'frame variable var_name' on some variables with array types.""" self.buildDsym(compiler='llvm-gcc') self.array_types() ... o Via LLDB_CC environment variable: $ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types ---------------------------------------------------------------------- Collected 4 tests test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']] output: rm -rf "a.out" "a.out.dSYM" main.o main.d llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c llvm-gcc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" /usr/bin/dsymutil -o "a.out.dSYM" "a.out" ... llvm-svn: 113781
2010-09-14 04:54:30 +08:00
"""Build the binaries the default way."""
if clean:
lldbtest.system(["/bin/sh", "-c",
"make clean" + getCmdLine(dictionary) + "; make"
+ getArchSpec(architecture) + getCCSpec(compiler)
+ getCmdLine(dictionary)],
sender=sender)
else:
lldbtest.system(["/bin/sh", "-c",
"make" + getArchSpec(architecture) + getCCSpec(compiler)
+ getCmdLine(dictionary)],
sender=sender)
# True signifies that we can handle building default.
return True
def buildDwarf(sender=None, architecture=None, compiler=None, dictionary=None, clean=True):
Extend the build mechanism to allow for specifying the compiler used to build the binaries. 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. -------------------------------------------------------------------------------- Example usage follows: o Via the keyword argument: class ArrayTypesTestCase(TestBase): mydir = "array_types" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test 'frame variable var_name' on some variables with array types.""" self.buildDsym(compiler='llvm-gcc') self.array_types() ... o Via LLDB_CC environment variable: $ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types ---------------------------------------------------------------------- Collected 4 tests test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']] output: rm -rf "a.out" "a.out.dSYM" main.o main.d llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c llvm-gcc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" /usr/bin/dsymutil -o "a.out.dSYM" "a.out" ... llvm-svn: 113781
2010-09-14 04:54:30 +08:00
"""Build the binaries with dwarf debug info."""
if clean:
lldbtest.system(["/bin/sh", "-c",
"make clean" + getCmdLine(dictionary)
+ "; make MAKE_DSYM=NO"
+ getArchSpec(architecture) + getCCSpec(compiler)
+ getCmdLine(dictionary)],
sender=sender)
else:
lldbtest.system(["/bin/sh", "-c",
"make MAKE_DSYM=NO"
+ getArchSpec(architecture) + getCCSpec(compiler)
+ getCmdLine(dictionary)],
sender=sender)
2011-02-11 08:06:48 +08:00
# True signifies that we can handle building dwarf.
return True
def cleanup(sender=None, dictionary=None):
"""Perform a platform-specific cleanup after the test."""
#import traceback
#traceback.print_stack()
if os.path.isfile("Makefile"):
lldbtest.system(["/bin/sh", "-c", "make clean"+getCmdLine(dictionary)],
sender=sender)
2011-02-11 08:07:26 +08:00
# True signifies that we can handle cleanup.
return True