2010-06-26 05:14:08 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
A simple testing framework for lldb using python's unit testing framework.
|
|
|
|
|
|
|
|
Tests for lldb are written as python scripts which take advantage of the script
|
|
|
|
bridging provided by LLDB.framework to interact with lldb core.
|
|
|
|
|
|
|
|
A specific naming pattern is followed by the .py script to be recognized as
|
|
|
|
a module which implements a test scenario, namely, Test*.py.
|
|
|
|
|
|
|
|
To specify the directories where "Test*.py" python test scripts are located,
|
|
|
|
you need to pass in a list of directory names. By default, the current
|
|
|
|
working directory is searched if nothing is specified on the command line.
|
2010-09-16 23:44:23 +08:00
|
|
|
|
|
|
|
Type:
|
|
|
|
|
|
|
|
./dotest.py -h
|
|
|
|
|
|
|
|
for available options.
|
2010-06-26 05:14:08 +08:00
|
|
|
"""
|
|
|
|
|
2010-09-09 04:56:16 +08:00
|
|
|
import os, signal, sys, time
|
2011-09-16 09:04:26 +08:00
|
|
|
import subprocess
|
2010-08-06 07:42:46 +08:00
|
|
|
import unittest2
|
2010-06-26 05:14:08 +08:00
|
|
|
|
2011-03-12 03:47:23 +08:00
|
|
|
def is_exe(fpath):
|
2011-04-27 07:10:51 +08:00
|
|
|
"""Returns true if fpath is an executable."""
|
2011-03-12 03:47:23 +08:00
|
|
|
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
|
|
|
|
|
|
|
def which(program):
|
2011-04-27 07:10:51 +08:00
|
|
|
"""Returns the full path to a program; None otherwise."""
|
2011-03-12 03:47:23 +08:00
|
|
|
fpath, fname = os.path.split(program)
|
|
|
|
if fpath:
|
|
|
|
if is_exe(program):
|
|
|
|
return program
|
|
|
|
else:
|
|
|
|
for path in os.environ["PATH"].split(os.pathsep):
|
|
|
|
exe_file = os.path.join(path, program)
|
|
|
|
if is_exe(exe_file):
|
|
|
|
return exe_file
|
|
|
|
return None
|
|
|
|
|
2010-08-07 08:16:07 +08:00
|
|
|
class _WritelnDecorator(object):
|
|
|
|
"""Used to decorate file-like objects with a handy 'writeln' method"""
|
|
|
|
def __init__(self,stream):
|
|
|
|
self.stream = stream
|
|
|
|
|
|
|
|
def __getattr__(self, attr):
|
|
|
|
if attr in ('stream', '__getstate__'):
|
|
|
|
raise AttributeError(attr)
|
|
|
|
return getattr(self.stream,attr)
|
|
|
|
|
|
|
|
def writeln(self, arg=None):
|
|
|
|
if arg:
|
|
|
|
self.write(arg)
|
|
|
|
self.write('\n') # text-mode streams translate to \r\n if needed
|
|
|
|
|
2010-06-26 05:14:08 +08:00
|
|
|
#
|
|
|
|
# Global variables:
|
|
|
|
#
|
|
|
|
|
|
|
|
# The test suite.
|
2010-08-06 07:42:46 +08:00
|
|
|
suite = unittest2.TestSuite()
|
2010-06-26 05:14:08 +08:00
|
|
|
|
2010-12-10 08:51:23 +08:00
|
|
|
# By default, both command line and Python API tests are performed.
|
2010-12-11 02:52:10 +08:00
|
|
|
# Use @python_api_test decorator, defined in lldbtest.py, to mark a test as
|
|
|
|
# a Python API test.
|
2010-12-10 08:51:23 +08:00
|
|
|
dont_do_python_api_test = False
|
|
|
|
|
|
|
|
# By default, both command line and Python API tests are performed.
|
|
|
|
just_do_python_api_test = False
|
|
|
|
|
2011-07-30 09:39:58 +08:00
|
|
|
# By default, benchmarks tests are not run.
|
|
|
|
just_do_benchmarks_test = False
|
|
|
|
|
2010-12-02 06:47:54 +08:00
|
|
|
# The blacklist is optional (-b blacklistFile) and allows a central place to skip
|
|
|
|
# testclass's and/or testclass.testmethod's.
|
|
|
|
blacklist = None
|
|
|
|
|
|
|
|
# The dictionary as a result of sourcing blacklistFile.
|
|
|
|
blacklistConfig = {}
|
|
|
|
|
2010-09-18 08:16:47 +08:00
|
|
|
# The config file is optional.
|
|
|
|
configFile = None
|
|
|
|
|
2010-11-17 06:42:58 +08:00
|
|
|
# Test suite repeat count. Can be overwritten with '-# count'.
|
|
|
|
count = 1
|
|
|
|
|
2010-09-21 08:09:27 +08:00
|
|
|
# The dictionary as a result of sourcing configFile.
|
|
|
|
config = {}
|
|
|
|
|
2011-03-04 09:35:22 +08:00
|
|
|
# The 'archs' and 'compilers' can be specified via either command line or configFile,
|
|
|
|
# with the command line overriding the configFile. When specified, they should be
|
|
|
|
# of the list type. For example, "-A x86_64^i386" => archs=['x86_64', 'i386'] and
|
|
|
|
# "-C gcc^clang" => compilers=['gcc', 'clang'].
|
2012-03-13 02:54:10 +08:00
|
|
|
archs = ['x86_64']
|
2012-03-09 10:11:37 +08:00
|
|
|
compilers = ['clang']
|
2011-03-04 09:35:22 +08:00
|
|
|
|
2012-03-20 08:33:51 +08:00
|
|
|
# The arch might dictate some specific CFLAGS to be passed to the toolchain to build
|
|
|
|
# the inferior programs. The global variable cflags_extras provides a hook to do
|
|
|
|
# just that.
|
|
|
|
cflags_extras = ''
|
|
|
|
|
2010-09-09 04:56:16 +08:00
|
|
|
# Delay startup in order for the debugger to attach.
|
|
|
|
delay = False
|
|
|
|
|
2011-01-29 09:21:04 +08:00
|
|
|
# Dump the Python sys.path variable. Use '-D' to dump sys.path.
|
2011-01-29 09:16:52 +08:00
|
|
|
dumpSysPath = False
|
|
|
|
|
2011-10-11 06:03:44 +08:00
|
|
|
# Full path of the benchmark executable, as specified by the '-e' option.
|
|
|
|
bmExecutable = None
|
|
|
|
# The breakpoint specification of bmExecutable, as specified by the '-x' option.
|
|
|
|
bmBreakpointSpec = None
|
2011-10-21 02:43:28 +08:00
|
|
|
# The benchamrk iteration count, as specified by the '-y' option.
|
|
|
|
bmIterationCount = -1
|
2011-10-11 06:03:44 +08:00
|
|
|
|
2012-01-18 13:15:00 +08:00
|
|
|
# By default, don't exclude any directories. Use '-X' to add one excluded directory.
|
|
|
|
excluded = set(['.svn', '.git'])
|
|
|
|
|
2010-12-04 03:59:35 +08:00
|
|
|
# By default, failfast is False. Use '-F' to overwrite it.
|
|
|
|
failfast = False
|
|
|
|
|
2011-07-30 06:54:56 +08:00
|
|
|
# The filters (testclass.testmethod) used to admit tests into our test suite.
|
|
|
|
filters = []
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
|
2011-10-11 09:30:27 +08:00
|
|
|
# The runhooks is a list of lldb commands specifically for the debugger.
|
|
|
|
# Use '-k' to specify a runhook.
|
|
|
|
runHooks = []
|
|
|
|
|
2010-11-08 09:21:03 +08:00
|
|
|
# If '-g' is specified, the filterspec is not exclusive. If a test module does
|
|
|
|
# not contain testclass.testmethod which matches the filterspec, the whole test
|
|
|
|
# module is still admitted into our test suite. fs4all flag defaults to True.
|
|
|
|
fs4all = True
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
|
2010-09-17 01:11:30 +08:00
|
|
|
# Ignore the build search path relative to this script to locate the lldb.py module.
|
|
|
|
ignore = False
|
|
|
|
|
2011-11-18 03:57:27 +08:00
|
|
|
# By default, we do not skip build and cleanup. Use '-S' option to override.
|
|
|
|
skip_build_and_cleanup = False
|
|
|
|
|
2010-10-12 06:25:46 +08:00
|
|
|
# By default, we skip long running test case. Use '-l' option to override.
|
2011-11-18 03:57:27 +08:00
|
|
|
skip_long_running_test = True
|
2010-10-02 06:59:49 +08:00
|
|
|
|
2011-10-22 02:33:27 +08:00
|
|
|
# By default, we print the build dir, lldb version, and svn info. Use '-n' option to
|
|
|
|
# turn it off.
|
|
|
|
noHeaders = False
|
|
|
|
|
2010-09-28 07:29:54 +08:00
|
|
|
# The regular expression pattern to match against eligible filenames as our test cases.
|
|
|
|
regexp = None
|
|
|
|
|
2010-10-12 06:25:46 +08:00
|
|
|
# By default, tests are executed in place and cleanups are performed afterwards.
|
|
|
|
# Use '-r dir' option to relocate the tests and their intermediate files to a
|
|
|
|
# different directory and to forgo any cleanups. The directory specified must
|
|
|
|
# not exist yet.
|
|
|
|
rdir = None
|
|
|
|
|
Add an option '-s session-dir-name' to overwrite the default timestamp-named
directory used to dump the session info for test failures/errors.
Example:
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -s jason -v array_types
Session info for test errors or failures will go into directory jason
----------------------------------------------------------------------
Collected 4 tests
test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dsym_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dwarf_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... FAIL
======================================================================
FAIL: test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 27, in test_with_dwarf_and_run_command
self.array_types()
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 62, in array_types
'stop reason = breakpoint'])
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 594, in expect
self.runCmd(str, trace = (True if trace else False), check = not error)
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 564, in runCmd
msg if msg else CMD_MSG(cmd, True))
AssertionError: False is not True : Command 'thread list' returns successfully
----------------------------------------------------------------------
Ran 4 tests in 3.086s
FAILED (failures=1)
/Volumes/data/lldb/svn/trunk/test $ ls jason
TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
/Volumes/data/lldb/svn/trunk/test $ head -10 jason/TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
Session info generated @ Thu Oct 21 09:54:15 2010
os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=NO']]
stdout: rm -rf "a.out" "a.out.dSYM" main.o main.d
cc -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c
cc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out"
stderr: None
retcode: 0
/Volumes/data/lldb/svn/trunk/test $
llvm-svn: 117028
2010-10-22 00:55:35 +08:00
|
|
|
# By default, recorded session info for errored/failed test are dumped into its
|
|
|
|
# own file under a session directory named after the timestamp of the test suite
|
|
|
|
# run. Use '-s session-dir-name' to specify a specific dir name.
|
|
|
|
sdir_name = None
|
|
|
|
|
2010-10-30 06:20:36 +08:00
|
|
|
# Set this flag if there is any session info dumped during the test run.
|
|
|
|
sdir_has_content = False
|
|
|
|
|
2011-05-18 06:58:50 +08:00
|
|
|
# svn_info stores the output from 'svn info lldb.base.dir'.
|
|
|
|
svn_info = ''
|
|
|
|
|
2012-01-31 08:38:03 +08:00
|
|
|
# The environment variables to unset before running the test cases.
|
|
|
|
unsets = []
|
|
|
|
|
2010-06-26 05:14:08 +08:00
|
|
|
# Default verbosity is 0.
|
|
|
|
verbose = 0
|
|
|
|
|
2011-11-18 08:19:29 +08:00
|
|
|
# Set to True only if verbose is 0 and LLDB trace mode is off.
|
|
|
|
progress_bar = False
|
|
|
|
|
2011-06-21 03:06:29 +08:00
|
|
|
# By default, search from the script directory.
|
|
|
|
testdirs = [ sys.path[0] ]
|
2010-06-26 05:14:08 +08:00
|
|
|
|
2010-08-07 08:16:07 +08:00
|
|
|
# Separator string.
|
|
|
|
separator = '-' * 70
|
|
|
|
|
2010-06-26 05:14:08 +08:00
|
|
|
|
|
|
|
def usage():
|
|
|
|
print """
|
|
|
|
Usage: dotest.py [option] [args]
|
|
|
|
where options:
|
2011-04-14 05:11:41 +08:00
|
|
|
-h : print this help message and exit. Add '-v' for more detailed help.
|
2011-03-04 09:35:22 +08:00
|
|
|
-A : specify the architecture(s) to launch for the inferior process
|
|
|
|
-A i386 => launch inferior with i386 architecture
|
|
|
|
-A x86_64^i386 => launch inferior with x86_64 and i386 architectures
|
|
|
|
-C : specify the compiler(s) used to build the inferior executable
|
|
|
|
-C clang => build debuggee using clang compiler
|
2012-01-17 09:26:06 +08:00
|
|
|
-C /my/full/path/to/clang => specify a full path to the clang binary
|
2011-03-04 09:35:22 +08:00
|
|
|
-C clang^gcc => build debuggee using clang and gcc compilers
|
2011-01-29 09:16:52 +08:00
|
|
|
-D : dump the Python sys.path variable
|
2012-03-20 08:33:51 +08:00
|
|
|
-E : specify the extra flags to be passed to the toolchain when building the
|
|
|
|
inferior programs to be debugged
|
|
|
|
suggestions: do not lump the -A arch1^arch2 together such that the -E
|
|
|
|
option applies to only one of the architectures
|
2010-12-10 08:51:23 +08:00
|
|
|
-a : don't do lldb Python API tests
|
|
|
|
use @python_api_test to decorate a test case as lldb Python API test
|
2010-12-11 02:52:10 +08:00
|
|
|
+a : just do lldb Python API tests
|
2010-12-11 03:02:23 +08:00
|
|
|
do not specify both '-a' and '+a' at the same time
|
2011-07-30 09:39:58 +08:00
|
|
|
+b : just do benchmark tests
|
|
|
|
use @benchmark_test to decorate a test case as such
|
2010-12-02 06:47:54 +08:00
|
|
|
-b : read a blacklist file specified after this option
|
2010-09-18 08:16:47 +08:00
|
|
|
-c : read a config file specified after this option
|
2011-03-04 09:35:22 +08:00
|
|
|
the architectures and compilers (note the plurals) specified via '-A' and '-C'
|
|
|
|
will override those specified via a config file
|
2010-09-21 08:09:27 +08:00
|
|
|
(see also lldb-trunk/example/test/usage-config)
|
2010-09-09 04:56:16 +08:00
|
|
|
-d : delay startup for 10 seconds (in order for the debugger to attach)
|
2011-10-11 06:03:44 +08:00
|
|
|
-e : specify the full path of an executable used for benchmark purpose;
|
|
|
|
see also '-x', which provides the breakpoint sepcification
|
2010-12-04 03:59:35 +08:00
|
|
|
-F : failfast, stop the test suite on the first error/failure
|
2010-10-12 00:19:48 +08:00
|
|
|
-f : specify a filter, which consists of the test class name, a dot, followed by
|
2010-11-09 04:17:04 +08:00
|
|
|
the test method, to only admit such test into the test suite
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
e.g., -f 'ClassTypesTestCase.test_with_dwarf_and_python_api'
|
2010-11-08 09:21:03 +08:00
|
|
|
-g : if specified, the filterspec by -f is not exclusive, i.e., if a test module
|
|
|
|
does not match the filterspec (testclass.testmethod), the whole module is
|
|
|
|
still admitted to the test suite
|
2010-09-17 01:11:30 +08:00
|
|
|
-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
|
2011-10-11 09:30:27 +08:00
|
|
|
-k : specify a runhook, which is an lldb command to be executed by the debugger;
|
|
|
|
'-k' option can occur multiple times, the commands are executed one after the
|
|
|
|
other to bring the debugger to a desired state, so that, for example, further
|
|
|
|
benchmarking can be done
|
2010-10-02 06:59:49 +08:00
|
|
|
-l : don't skip long running test
|
2011-10-22 02:33:27 +08:00
|
|
|
-n : don't print the headers like build dir, lldb version, and svn info at all
|
2010-09-28 07:29:54 +08:00
|
|
|
-p : specify a regexp filename pattern for inclusion in the test suite
|
2010-10-12 06:25:46 +08:00
|
|
|
-r : specify a dir to relocate the tests and their intermediate files to;
|
|
|
|
the directory must not exist before running this test driver;
|
|
|
|
no cleanup of intermediate test files is performed in this case
|
2011-11-18 03:57:27 +08:00
|
|
|
-S : skip the build and cleanup while running the test
|
|
|
|
use this option with care as you would need to build the inferior(s) by hand
|
|
|
|
and build the executable(s) with the correct name(s)
|
|
|
|
this can be used with '-# n' to stress test certain test cases for n number of
|
|
|
|
times
|
Add an option '-s session-dir-name' to overwrite the default timestamp-named
directory used to dump the session info for test failures/errors.
Example:
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -s jason -v array_types
Session info for test errors or failures will go into directory jason
----------------------------------------------------------------------
Collected 4 tests
test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dsym_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dwarf_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... FAIL
======================================================================
FAIL: test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 27, in test_with_dwarf_and_run_command
self.array_types()
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 62, in array_types
'stop reason = breakpoint'])
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 594, in expect
self.runCmd(str, trace = (True if trace else False), check = not error)
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 564, in runCmd
msg if msg else CMD_MSG(cmd, True))
AssertionError: False is not True : Command 'thread list' returns successfully
----------------------------------------------------------------------
Ran 4 tests in 3.086s
FAILED (failures=1)
/Volumes/data/lldb/svn/trunk/test $ ls jason
TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
/Volumes/data/lldb/svn/trunk/test $ head -10 jason/TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
Session info generated @ Thu Oct 21 09:54:15 2010
os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=NO']]
stdout: rm -rf "a.out" "a.out.dSYM" main.o main.d
cc -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c
cc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out"
stderr: None
retcode: 0
/Volumes/data/lldb/svn/trunk/test $
llvm-svn: 117028
2010-10-22 00:55:35 +08:00
|
|
|
-s : specify the name of the dir created to store the session files of tests
|
|
|
|
with errored or failed status; if not specified, the test driver uses the
|
|
|
|
timestamp as the session dir name
|
2011-04-22 04:48:32 +08:00
|
|
|
-t : turn on tracing of lldb command and other detailed test executions
|
2012-01-31 08:38:03 +08:00
|
|
|
-u : specify an environment variable to unset before running the test cases
|
|
|
|
e.g., -u DYLD_INSERT_LIBRARIES -u MallocScribble'
|
2011-04-22 04:48:32 +08:00
|
|
|
-v : do verbose mode of unittest framework (print out each test case invocation)
|
2012-01-18 13:15:00 +08:00
|
|
|
-X : exclude a directory from consideration for test discovery
|
|
|
|
-X types => if 'types' appear in the pathname components of a potential testfile
|
|
|
|
it will be ignored
|
2011-10-11 06:03:44 +08:00
|
|
|
-x : specify the breakpoint specification for the benchmark executable;
|
|
|
|
see also '-e', which provides the full path of the executable
|
2011-10-21 02:43:28 +08:00
|
|
|
-y : specify the iteration count used to collect our benchmarks; an example is
|
|
|
|
the number of times to do 'thread step-over' to measure stepping speed
|
|
|
|
see also '-e' and '-x' options
|
2010-10-07 10:04:14 +08:00
|
|
|
-w : insert some wait time (currently 0.5 sec) between consecutive test cases
|
2010-11-17 06:42:58 +08:00
|
|
|
-# : Repeat the test suite for a specified number of times
|
2010-06-26 05:14:08 +08:00
|
|
|
|
|
|
|
and:
|
2010-10-23 03:00:18 +08:00
|
|
|
args : specify a list of directory names to search for test modules named after
|
|
|
|
Test*.py (test discovery)
|
2011-06-14 11:55:45 +08:00
|
|
|
if empty, search from the current working directory, instead
|
2011-04-14 05:11:41 +08:00
|
|
|
"""
|
2010-06-30 07:10:39 +08:00
|
|
|
|
2011-04-14 05:11:41 +08:00
|
|
|
if verbose > 0:
|
|
|
|
print """
|
2010-10-23 03:00:18 +08:00
|
|
|
Examples:
|
|
|
|
|
2010-11-08 09:21:03 +08:00
|
|
|
This is an example of using the -f option to pinpoint to a specfic test class
|
|
|
|
and test method to be run:
|
2010-10-21 08:47:52 +08:00
|
|
|
|
2010-11-08 09:21:03 +08:00
|
|
|
$ ./dotest.py -f ClassTypesTestCase.test_with_dsym_and_run_command
|
2010-10-21 08:47:52 +08:00
|
|
|
----------------------------------------------------------------------
|
|
|
|
Collected 1 test
|
|
|
|
|
|
|
|
test_with_dsym_and_run_command (TestClassTypes.ClassTypesTestCase)
|
|
|
|
Test 'frame variable this' when stopped on a class constructor. ... ok
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
Ran 1 test in 1.396s
|
|
|
|
|
|
|
|
OK
|
2010-10-23 03:00:18 +08:00
|
|
|
|
|
|
|
And this is an example of using the -p option to run a single file (the filename
|
|
|
|
matches the pattern 'ObjC' and it happens to be 'TestObjCMethods.py'):
|
|
|
|
|
|
|
|
$ ./dotest.py -v -p ObjC
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
Collected 4 tests
|
|
|
|
|
|
|
|
test_break_with_dsym (TestObjCMethods.FoundationTestCase)
|
2011-04-12 13:54:46 +08:00
|
|
|
Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'. ... ok
|
2010-10-23 03:00:18 +08:00
|
|
|
test_break_with_dwarf (TestObjCMethods.FoundationTestCase)
|
2011-04-12 13:54:46 +08:00
|
|
|
Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'. ... ok
|
2010-10-23 03:00:18 +08:00
|
|
|
test_data_type_and_expr_with_dsym (TestObjCMethods.FoundationTestCase)
|
|
|
|
Lookup objective-c data types and evaluate expressions. ... ok
|
|
|
|
test_data_type_and_expr_with_dwarf (TestObjCMethods.FoundationTestCase)
|
|
|
|
Lookup objective-c data types and evaluate expressions. ... ok
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
Ran 4 tests in 16.661s
|
|
|
|
|
|
|
|
OK
|
2010-10-21 08:47:52 +08:00
|
|
|
|
2010-06-30 07:10:39 +08:00
|
|
|
Running of this script also sets up the LLDB_TEST environment variable so that
|
2010-09-17 01:11:30 +08:00
|
|
|
individual test cases can locate their supporting files correctly. The script
|
|
|
|
tries to set up Python's search paths for modules by looking at the build tree
|
2010-11-12 06:14:56 +08:00
|
|
|
relative to this script. See also the '-i' option in the following example.
|
|
|
|
|
|
|
|
Finally, this is an example of using the lldb.py module distributed/installed by
|
|
|
|
Xcode4 to run against the tests under the 'forward' directory, and with the '-w'
|
|
|
|
option to add some delay between two tests. It uses ARCH=x86_64 to specify that
|
|
|
|
as the architecture and CC=clang to specify the compiler used for the test run:
|
|
|
|
|
|
|
|
$ PYTHONPATH=/Xcode4/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Python ARCH=x86_64 CC=clang ./dotest.py -v -w -i forward
|
|
|
|
|
|
|
|
Session logs for test failures/errors will go into directory '2010-11-11-13_56_16'
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
Collected 2 tests
|
|
|
|
|
|
|
|
test_with_dsym_and_run_command (TestForwardDeclaration.ForwardDeclarationTestCase)
|
|
|
|
Display *bar_ptr when stopped on a function with forward declaration of struct bar. ... ok
|
|
|
|
test_with_dwarf_and_run_command (TestForwardDeclaration.ForwardDeclarationTestCase)
|
|
|
|
Display *bar_ptr when stopped on a function with forward declaration of struct bar. ... ok
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
Ran 2 tests in 5.659s
|
|
|
|
|
|
|
|
OK
|
|
|
|
|
|
|
|
The 'Session ...' verbiage is recently introduced (see also the '-s' option) to
|
|
|
|
notify the directory containing the session logs for test failures or errors.
|
|
|
|
In case there is any test failure/error, a similar message is appended at the
|
|
|
|
end of the stderr output for your convenience.
|
2010-09-15 06:01:40 +08:00
|
|
|
|
|
|
|
Environment variables related to loggings:
|
|
|
|
|
|
|
|
o LLDB_LOG: if defined, specifies the log file pathname for the 'lldb' subsystem
|
|
|
|
with a default option of 'event process' if LLDB_LOG_OPTION is not defined.
|
|
|
|
|
|
|
|
o GDB_REMOTE_LOG: if defined, specifies the log file pathname for the
|
|
|
|
'process.gdb-remote' subsystem with a default option of 'packets' if
|
|
|
|
GDB_REMOTE_LOG_OPTION is not defined.
|
2010-06-26 05:14:08 +08:00
|
|
|
"""
|
2010-09-18 08:16:47 +08:00
|
|
|
sys.exit(0)
|
2010-06-26 05:14:08 +08:00
|
|
|
|
|
|
|
|
2010-09-17 01:11:30 +08:00
|
|
|
def parseOptionsAndInitTestdirs():
|
|
|
|
"""Initialize the list of directories containing our unittest scripts.
|
|
|
|
|
|
|
|
'-h/--help as the first option prints out usage info and exit the program.
|
|
|
|
"""
|
|
|
|
|
2010-12-10 08:51:23 +08:00
|
|
|
global dont_do_python_api_test
|
|
|
|
global just_do_python_api_test
|
2011-07-30 09:39:58 +08:00
|
|
|
global just_do_benchmarks_test
|
2010-12-02 06:47:54 +08:00
|
|
|
global blacklist
|
|
|
|
global blacklistConfig
|
2010-09-18 08:16:47 +08:00
|
|
|
global configFile
|
2011-03-04 09:35:22 +08:00
|
|
|
global archs
|
|
|
|
global compilers
|
2010-11-17 06:42:58 +08:00
|
|
|
global count
|
2010-09-17 01:11:30 +08:00
|
|
|
global delay
|
2011-01-29 09:16:52 +08:00
|
|
|
global dumpSysPath
|
2011-10-11 06:03:44 +08:00
|
|
|
global bmExecutable
|
|
|
|
global bmBreakpointSpec
|
2011-10-21 02:43:28 +08:00
|
|
|
global bmIterationCount
|
2010-12-04 03:59:35 +08:00
|
|
|
global failfast
|
2011-07-30 06:54:56 +08:00
|
|
|
global filters
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
global fs4all
|
2010-09-28 07:29:54 +08:00
|
|
|
global ignore
|
2011-11-18 08:19:29 +08:00
|
|
|
global progress_bar
|
2011-10-11 09:30:27 +08:00
|
|
|
global runHooks
|
2011-11-18 03:57:27 +08:00
|
|
|
global skip_build_and_cleanup
|
|
|
|
global skip_long_running_test
|
2011-10-22 02:33:27 +08:00
|
|
|
global noHeaders
|
2010-09-28 07:29:54 +08:00
|
|
|
global regexp
|
2010-10-12 06:25:46 +08:00
|
|
|
global rdir
|
Add an option '-s session-dir-name' to overwrite the default timestamp-named
directory used to dump the session info for test failures/errors.
Example:
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -s jason -v array_types
Session info for test errors or failures will go into directory jason
----------------------------------------------------------------------
Collected 4 tests
test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dsym_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dwarf_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... FAIL
======================================================================
FAIL: test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 27, in test_with_dwarf_and_run_command
self.array_types()
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 62, in array_types
'stop reason = breakpoint'])
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 594, in expect
self.runCmd(str, trace = (True if trace else False), check = not error)
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 564, in runCmd
msg if msg else CMD_MSG(cmd, True))
AssertionError: False is not True : Command 'thread list' returns successfully
----------------------------------------------------------------------
Ran 4 tests in 3.086s
FAILED (failures=1)
/Volumes/data/lldb/svn/trunk/test $ ls jason
TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
/Volumes/data/lldb/svn/trunk/test $ head -10 jason/TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
Session info generated @ Thu Oct 21 09:54:15 2010
os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=NO']]
stdout: rm -rf "a.out" "a.out.dSYM" main.o main.d
cc -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c
cc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out"
stderr: None
retcode: 0
/Volumes/data/lldb/svn/trunk/test $
llvm-svn: 117028
2010-10-22 00:55:35 +08:00
|
|
|
global sdir_name
|
2012-01-31 08:38:03 +08:00
|
|
|
global unsets
|
2010-09-17 01:11:30 +08:00
|
|
|
global verbose
|
|
|
|
global testdirs
|
|
|
|
|
2011-04-14 05:11:41 +08:00
|
|
|
do_help = False
|
|
|
|
|
2010-09-17 01:11:30 +08:00
|
|
|
if len(sys.argv) == 1:
|
|
|
|
return
|
|
|
|
|
|
|
|
# Process possible trace and/or verbose flag, among other things.
|
|
|
|
index = 1
|
2010-10-07 23:41:55 +08:00
|
|
|
while index < len(sys.argv):
|
2010-12-10 08:51:23 +08:00
|
|
|
if sys.argv[index].startswith('-') or sys.argv[index].startswith('+'):
|
|
|
|
# We should continue processing...
|
|
|
|
pass
|
|
|
|
else:
|
2010-09-17 01:11:30 +08:00
|
|
|
# End of option processing.
|
|
|
|
break
|
|
|
|
|
|
|
|
if sys.argv[index].find('-h') != -1:
|
2011-04-14 05:11:41 +08:00
|
|
|
index += 1
|
|
|
|
do_help = True
|
2011-01-27 03:07:42 +08:00
|
|
|
elif sys.argv[index].startswith('-A'):
|
|
|
|
# Increment by 1 to fetch the ARCH spec.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
2011-04-27 04:45:00 +08:00
|
|
|
archs = sys.argv[index].split('^')
|
2011-01-27 03:07:42 +08:00
|
|
|
index += 1
|
|
|
|
elif sys.argv[index].startswith('-C'):
|
|
|
|
# Increment by 1 to fetch the CC spec.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
2011-04-27 04:45:00 +08:00
|
|
|
compilers = sys.argv[index].split('^')
|
2011-01-27 03:07:42 +08:00
|
|
|
index += 1
|
2011-01-29 09:16:52 +08:00
|
|
|
elif sys.argv[index].startswith('-D'):
|
|
|
|
dumpSysPath = True
|
|
|
|
index += 1
|
2012-03-20 08:33:51 +08:00
|
|
|
elif sys.argv[index].startswith('-E'):
|
|
|
|
# Increment by 1 to fetch the CFLAGS_EXTRAS spec.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv):
|
|
|
|
usage()
|
|
|
|
cflags_extras = sys.argv[index]
|
|
|
|
os.environ["CFLAGS_EXTRAS"] = cflags_extras
|
|
|
|
index += 1
|
2010-12-10 08:51:23 +08:00
|
|
|
elif sys.argv[index].startswith('-a'):
|
|
|
|
dont_do_python_api_test = True
|
|
|
|
index += 1
|
|
|
|
elif sys.argv[index].startswith('+a'):
|
|
|
|
just_do_python_api_test = True
|
|
|
|
index += 1
|
2011-07-30 09:39:58 +08:00
|
|
|
elif sys.argv[index].startswith('+b'):
|
|
|
|
just_do_benchmarks_test = True
|
|
|
|
index += 1
|
2010-12-02 06:47:54 +08:00
|
|
|
elif sys.argv[index].startswith('-b'):
|
|
|
|
# Increment by 1 to fetch the blacklist file name option argument.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
|
|
|
blacklistFile = sys.argv[index]
|
|
|
|
if not os.path.isfile(blacklistFile):
|
|
|
|
print "Blacklist file:", blacklistFile, "does not exist!"
|
|
|
|
usage()
|
|
|
|
index += 1
|
|
|
|
# Now read the blacklist contents and assign it to blacklist.
|
|
|
|
execfile(blacklistFile, globals(), blacklistConfig)
|
|
|
|
blacklist = blacklistConfig.get('blacklist')
|
2010-09-18 08:16:47 +08:00
|
|
|
elif sys.argv[index].startswith('-c'):
|
|
|
|
# Increment by 1 to fetch the config file name option argument.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
|
|
|
configFile = sys.argv[index]
|
|
|
|
if not os.path.isfile(configFile):
|
|
|
|
print "Config file:", configFile, "does not exist!"
|
|
|
|
usage()
|
|
|
|
index += 1
|
2010-09-17 01:11:30 +08:00
|
|
|
elif sys.argv[index].startswith('-d'):
|
|
|
|
delay = True
|
|
|
|
index += 1
|
2011-10-11 06:03:44 +08:00
|
|
|
elif sys.argv[index].startswith('-e'):
|
|
|
|
# Increment by 1 to fetch the full path of the benchmark executable.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
|
|
|
bmExecutable = sys.argv[index]
|
|
|
|
if not is_exe(bmExecutable):
|
|
|
|
usage()
|
|
|
|
index += 1
|
2010-12-04 03:59:35 +08:00
|
|
|
elif sys.argv[index].startswith('-F'):
|
|
|
|
failfast = True
|
|
|
|
index += 1
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
elif sys.argv[index].startswith('-f'):
|
|
|
|
# Increment by 1 to fetch the filter spec.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
2011-07-30 06:54:56 +08:00
|
|
|
filters.append(sys.argv[index])
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
index += 1
|
|
|
|
elif sys.argv[index].startswith('-g'):
|
2010-11-08 09:21:03 +08:00
|
|
|
fs4all = False
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
index += 1
|
2010-09-17 01:11:30 +08:00
|
|
|
elif sys.argv[index].startswith('-i'):
|
|
|
|
ignore = True
|
|
|
|
index += 1
|
2011-10-11 09:30:27 +08:00
|
|
|
elif sys.argv[index].startswith('-k'):
|
|
|
|
# Increment by 1 to fetch the runhook lldb command.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
|
|
|
runHooks.append(sys.argv[index])
|
|
|
|
index += 1
|
2010-10-02 06:59:49 +08:00
|
|
|
elif sys.argv[index].startswith('-l'):
|
2011-11-18 03:57:27 +08:00
|
|
|
skip_long_running_test = False
|
2010-10-02 06:59:49 +08:00
|
|
|
index += 1
|
2011-10-22 02:33:27 +08:00
|
|
|
elif sys.argv[index].startswith('-n'):
|
|
|
|
noHeaders = True
|
|
|
|
index += 1
|
2010-09-28 07:29:54 +08:00
|
|
|
elif sys.argv[index].startswith('-p'):
|
|
|
|
# Increment by 1 to fetch the reg exp pattern argument.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
|
|
|
regexp = sys.argv[index]
|
|
|
|
index += 1
|
2010-10-12 06:25:46 +08:00
|
|
|
elif sys.argv[index].startswith('-r'):
|
|
|
|
# Increment by 1 to fetch the relocated directory argument.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
|
|
|
rdir = os.path.abspath(sys.argv[index])
|
|
|
|
if os.path.exists(rdir):
|
|
|
|
print "Relocated directory:", rdir, "must not exist!"
|
|
|
|
usage()
|
|
|
|
index += 1
|
2011-11-18 03:57:27 +08:00
|
|
|
elif sys.argv[index].startswith('-S'):
|
|
|
|
skip_build_and_cleanup = True
|
|
|
|
index += 1
|
Add an option '-s session-dir-name' to overwrite the default timestamp-named
directory used to dump the session info for test failures/errors.
Example:
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -s jason -v array_types
Session info for test errors or failures will go into directory jason
----------------------------------------------------------------------
Collected 4 tests
test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dsym_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dwarf_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... FAIL
======================================================================
FAIL: test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 27, in test_with_dwarf_and_run_command
self.array_types()
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 62, in array_types
'stop reason = breakpoint'])
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 594, in expect
self.runCmd(str, trace = (True if trace else False), check = not error)
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 564, in runCmd
msg if msg else CMD_MSG(cmd, True))
AssertionError: False is not True : Command 'thread list' returns successfully
----------------------------------------------------------------------
Ran 4 tests in 3.086s
FAILED (failures=1)
/Volumes/data/lldb/svn/trunk/test $ ls jason
TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
/Volumes/data/lldb/svn/trunk/test $ head -10 jason/TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
Session info generated @ Thu Oct 21 09:54:15 2010
os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=NO']]
stdout: rm -rf "a.out" "a.out.dSYM" main.o main.d
cc -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c
cc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out"
stderr: None
retcode: 0
/Volumes/data/lldb/svn/trunk/test $
llvm-svn: 117028
2010-10-22 00:55:35 +08:00
|
|
|
elif sys.argv[index].startswith('-s'):
|
|
|
|
# Increment by 1 to fetch the session dir name.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
|
|
|
sdir_name = sys.argv[index]
|
|
|
|
index += 1
|
2010-09-17 01:11:30 +08:00
|
|
|
elif sys.argv[index].startswith('-t'):
|
|
|
|
os.environ["LLDB_COMMAND_TRACE"] = "YES"
|
|
|
|
index += 1
|
2012-01-31 08:38:03 +08:00
|
|
|
elif sys.argv[index].startswith('-u'):
|
|
|
|
# Increment by 1 to fetch the environment variable to unset.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
|
|
|
unsets.append(sys.argv[index])
|
|
|
|
index += 1
|
2010-09-17 01:11:30 +08:00
|
|
|
elif sys.argv[index].startswith('-v'):
|
|
|
|
verbose = 2
|
|
|
|
index += 1
|
2010-10-07 10:04:14 +08:00
|
|
|
elif sys.argv[index].startswith('-w'):
|
|
|
|
os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] = 'YES'
|
|
|
|
index += 1
|
2012-01-18 13:15:00 +08:00
|
|
|
elif sys.argv[index].startswith('-X'):
|
|
|
|
# Increment by 1 to fetch an excluded directory.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv):
|
|
|
|
usage()
|
|
|
|
excluded.add(sys.argv[index])
|
|
|
|
index += 1
|
2011-10-11 06:03:44 +08:00
|
|
|
elif sys.argv[index].startswith('-x'):
|
|
|
|
# Increment by 1 to fetch the breakpoint specification of the benchmark executable.
|
|
|
|
index += 1
|
2011-10-21 06:16:24 +08:00
|
|
|
if index >= len(sys.argv):
|
2011-10-11 06:03:44 +08:00
|
|
|
usage()
|
|
|
|
bmBreakpointSpec = sys.argv[index]
|
|
|
|
index += 1
|
2011-10-21 02:43:28 +08:00
|
|
|
elif sys.argv[index].startswith('-y'):
|
|
|
|
# Increment by 1 to fetch the the benchmark iteration count.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
|
|
|
bmIterationCount = int(sys.argv[index])
|
|
|
|
index += 1
|
2010-11-17 06:42:58 +08:00
|
|
|
elif sys.argv[index].startswith('-#'):
|
|
|
|
# Increment by 1 to fetch the repeat count argument.
|
|
|
|
index += 1
|
|
|
|
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
|
|
|
|
usage()
|
|
|
|
count = int(sys.argv[index])
|
|
|
|
index += 1
|
2010-09-17 01:11:30 +08:00
|
|
|
else:
|
|
|
|
print "Unknown option: ", sys.argv[index]
|
|
|
|
usage()
|
|
|
|
|
2011-04-14 05:11:41 +08:00
|
|
|
if do_help == True:
|
|
|
|
usage()
|
|
|
|
|
2010-12-11 03:02:23 +08:00
|
|
|
# Do not specify both '-a' and '+a' at the same time.
|
|
|
|
if dont_do_python_api_test and just_do_python_api_test:
|
|
|
|
usage()
|
|
|
|
|
2011-11-18 08:19:29 +08:00
|
|
|
# The simple progress bar is turned on only if verbose == 0 and LLDB_COMMAND_TRACE is not 'YES'
|
|
|
|
if ("LLDB_COMMAND_TRACE" not in os.environ or os.environ["LLDB_COMMAND_TRACE"]!="YES") and verbose==0:
|
|
|
|
progress_bar = True
|
|
|
|
|
2010-09-17 01:11:30 +08:00
|
|
|
# Gather all the dirs passed on the command line.
|
|
|
|
if len(sys.argv) > index:
|
|
|
|
testdirs = map(os.path.abspath, sys.argv[index:])
|
|
|
|
|
2010-10-12 06:25:46 +08:00
|
|
|
# If '-r dir' is specified, the tests should be run under the relocated
|
|
|
|
# directory. Let's copy the testdirs over.
|
|
|
|
if rdir:
|
|
|
|
from shutil import copytree, ignore_patterns
|
|
|
|
|
|
|
|
tmpdirs = []
|
|
|
|
for srcdir in testdirs:
|
2012-03-20 08:33:51 +08:00
|
|
|
# For example, /Volumes/data/lldb/svn/ToT/test/functionalities/watchpoint/hello_watchpoint
|
|
|
|
# shall be split into ['/Volumes/data/lldb/svn/ToT/', 'functionalities/watchpoint/hello_watchpoint'].
|
|
|
|
# Utilize the relative path to the 'test' directory to make our destination dir path.
|
|
|
|
dstdir = os.path.join(rdir, srcdir.split("test"+os.sep)[1])
|
|
|
|
#print "(srcdir, dstdir)=(%s, %s)" % (srcdir, dstdir)
|
2010-10-12 06:25:46 +08:00
|
|
|
# Don't copy the *.pyc and .svn stuffs.
|
|
|
|
copytree(srcdir, dstdir, ignore=ignore_patterns('*.pyc', '.svn'))
|
|
|
|
tmpdirs.append(dstdir)
|
|
|
|
|
|
|
|
# This will be our modified testdirs.
|
|
|
|
testdirs = tmpdirs
|
|
|
|
|
|
|
|
# With '-r dir' specified, there's no cleanup of intermediate test files.
|
|
|
|
os.environ["LLDB_DO_CLEANUP"] = 'NO'
|
|
|
|
|
|
|
|
# If testdirs is ['test'], the make directory has already been copied
|
|
|
|
# recursively and is contained within the rdir/test dir. For anything
|
|
|
|
# else, we would need to copy over the make directory and its contents,
|
|
|
|
# so that, os.listdir(rdir) looks like, for example:
|
|
|
|
#
|
|
|
|
# array_types conditional_break make
|
|
|
|
#
|
|
|
|
# where the make directory contains the Makefile.rules file.
|
|
|
|
if len(testdirs) != 1 or os.path.basename(testdirs[0]) != 'test':
|
|
|
|
# Don't copy the .svn stuffs.
|
|
|
|
copytree('make', os.path.join(rdir, 'make'),
|
|
|
|
ignore=ignore_patterns('.svn'))
|
|
|
|
|
|
|
|
#print "testdirs:", testdirs
|
|
|
|
|
2010-09-21 08:09:27 +08:00
|
|
|
# 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
|
|
|
|
|
2010-09-17 01:11:30 +08:00
|
|
|
|
2010-06-26 05:14:08 +08:00
|
|
|
def setupSysPath():
|
2011-03-12 04:13:06 +08:00
|
|
|
"""
|
|
|
|
Add LLDB.framework/Resources/Python to the search paths for modules.
|
|
|
|
As a side effect, we also discover the 'lldb' executable and export it here.
|
|
|
|
"""
|
2010-06-26 05:14:08 +08:00
|
|
|
|
2010-10-12 06:25:46 +08:00
|
|
|
global rdir
|
|
|
|
global testdirs
|
2011-01-29 09:16:52 +08:00
|
|
|
global dumpSysPath
|
2011-10-22 02:33:27 +08:00
|
|
|
global noHeaders
|
2011-05-18 06:58:50 +08:00
|
|
|
global svn_info
|
2010-10-12 06:25:46 +08:00
|
|
|
|
2010-06-26 05:14:08 +08:00
|
|
|
# Get the directory containing the current script.
|
2011-08-13 02:54:11 +08:00
|
|
|
if ("DOTEST_PROFILE" in os.environ or "DOTEST_PDB" in os.environ) and "DOTEST_SCRIPT_DIR" in os.environ:
|
2011-01-19 10:10:40 +08:00
|
|
|
scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
|
|
|
|
else:
|
|
|
|
scriptPath = sys.path[0]
|
2010-07-03 11:41:59 +08:00
|
|
|
if not scriptPath.endswith('test'):
|
2010-06-26 05:14:08 +08:00
|
|
|
print "This script expects to reside in lldb's test directory."
|
|
|
|
sys.exit(-1)
|
|
|
|
|
2010-10-12 06:25:46 +08:00
|
|
|
if rdir:
|
|
|
|
# Set up the LLDB_TEST environment variable appropriately, so that the
|
|
|
|
# individual tests can be located relatively.
|
|
|
|
#
|
|
|
|
# See also lldbtest.TestBase.setUpClass(cls).
|
|
|
|
if len(testdirs) == 1 and os.path.basename(testdirs[0]) == 'test':
|
|
|
|
os.environ["LLDB_TEST"] = os.path.join(rdir, 'test')
|
|
|
|
else:
|
|
|
|
os.environ["LLDB_TEST"] = rdir
|
|
|
|
else:
|
|
|
|
os.environ["LLDB_TEST"] = scriptPath
|
2011-06-21 03:06:45 +08:00
|
|
|
|
|
|
|
# Set up the LLDB_SRC environment variable, so that the tests can locate
|
|
|
|
# the LLDB source code.
|
|
|
|
os.environ["LLDB_SRC"] = os.path.join(sys.path[0], os.pardir)
|
|
|
|
|
2010-09-01 01:42:54 +08:00
|
|
|
pluginPath = os.path.join(scriptPath, 'plugins')
|
2011-03-12 04:13:06 +08:00
|
|
|
pexpectPath = os.path.join(scriptPath, 'pexpect-2.4')
|
2010-06-30 07:10:39 +08:00
|
|
|
|
2011-03-12 04:13:06 +08:00
|
|
|
# Append script dir, plugin dir, and pexpect dir to the sys.path.
|
2010-09-17 01:11:30 +08:00
|
|
|
sys.path.append(scriptPath)
|
|
|
|
sys.path.append(pluginPath)
|
2011-03-12 04:13:06 +08:00
|
|
|
sys.path.append(pexpectPath)
|
2010-09-17 01:11:30 +08:00
|
|
|
|
2011-03-12 03:47:23 +08:00
|
|
|
# This is our base name component.
|
2010-07-03 11:41:59 +08:00
|
|
|
base = os.path.abspath(os.path.join(scriptPath, os.pardir))
|
2011-02-16 02:50:19 +08:00
|
|
|
|
2011-03-12 03:47:23 +08:00
|
|
|
# These are for xcode build directories.
|
2011-02-16 02:50:19 +08:00
|
|
|
xcode3_build_dir = ['build']
|
|
|
|
xcode4_build_dir = ['build', 'lldb', 'Build', 'Products']
|
|
|
|
dbg = ['Debug']
|
|
|
|
rel = ['Release']
|
|
|
|
bai = ['BuildAndIntegration']
|
|
|
|
python_resource_dir = ['LLDB.framework', 'Resources', 'Python']
|
2011-03-12 03:47:23 +08:00
|
|
|
|
|
|
|
# Some of the tests can invoke the 'lldb' command directly.
|
|
|
|
# We'll try to locate the appropriate executable right here.
|
|
|
|
|
2011-08-26 08:00:01 +08:00
|
|
|
# First, you can define an environment variable LLDB_EXEC specifying the
|
|
|
|
# full pathname of the lldb executable.
|
|
|
|
if "LLDB_EXEC" in os.environ and is_exe(os.environ["LLDB_EXEC"]):
|
|
|
|
lldbExec = os.environ["LLDB_EXEC"]
|
|
|
|
else:
|
|
|
|
lldbExec = None
|
|
|
|
|
2011-03-12 03:47:23 +08:00
|
|
|
executable = ['lldb']
|
|
|
|
dbgExec = os.path.join(base, *(xcode3_build_dir + dbg + executable))
|
|
|
|
dbgExec2 = os.path.join(base, *(xcode4_build_dir + dbg + executable))
|
|
|
|
relExec = os.path.join(base, *(xcode3_build_dir + rel + executable))
|
|
|
|
relExec2 = os.path.join(base, *(xcode4_build_dir + rel + executable))
|
|
|
|
baiExec = os.path.join(base, *(xcode3_build_dir + bai + executable))
|
|
|
|
baiExec2 = os.path.join(base, *(xcode4_build_dir + bai + executable))
|
|
|
|
|
2011-08-26 08:00:01 +08:00
|
|
|
# The 'lldb' executable built here in the source tree.
|
|
|
|
lldbHere = None
|
2011-03-12 03:47:23 +08:00
|
|
|
if is_exe(dbgExec):
|
2011-08-26 08:00:01 +08:00
|
|
|
lldbHere = dbgExec
|
2011-03-12 03:47:23 +08:00
|
|
|
elif is_exe(dbgExec2):
|
2011-08-26 08:00:01 +08:00
|
|
|
lldbHere = dbgExec2
|
2011-03-12 03:47:23 +08:00
|
|
|
elif is_exe(relExec):
|
2011-08-26 08:00:01 +08:00
|
|
|
lldbHere = relExec
|
2011-03-12 03:47:23 +08:00
|
|
|
elif is_exe(relExec2):
|
2011-08-26 08:00:01 +08:00
|
|
|
lldbHere = relExec2
|
2011-03-12 03:47:23 +08:00
|
|
|
elif is_exe(baiExec):
|
2011-08-26 08:00:01 +08:00
|
|
|
lldbHere = baiExec
|
2011-03-12 03:47:23 +08:00
|
|
|
elif is_exe(baiExec2):
|
2011-08-26 08:00:01 +08:00
|
|
|
lldbHere = baiExec2
|
2011-11-01 07:27:06 +08:00
|
|
|
elif lldbExec:
|
|
|
|
lldbHere = lldbExec
|
2011-03-12 03:47:23 +08:00
|
|
|
|
2011-08-26 08:00:01 +08:00
|
|
|
if lldbHere:
|
|
|
|
os.environ["LLDB_HERE"] = lldbHere
|
2011-10-26 04:08:03 +08:00
|
|
|
os.environ["LLDB_BUILD_DIR"] = os.path.split(lldbHere)[0]
|
2011-10-22 02:33:27 +08:00
|
|
|
if not noHeaders:
|
|
|
|
print "LLDB build dir:", os.environ["LLDB_BUILD_DIR"]
|
2011-10-29 01:56:02 +08:00
|
|
|
os.system('%s -v' % lldbHere)
|
2011-08-05 02:17:16 +08:00
|
|
|
|
2011-08-26 08:00:01 +08:00
|
|
|
# One last chance to locate the 'lldb' executable.
|
2011-03-12 03:47:23 +08:00
|
|
|
if not lldbExec:
|
2011-10-26 04:08:03 +08:00
|
|
|
lldbExec = which('lldb')
|
|
|
|
if lldbHere and not lldbExec:
|
2011-08-26 08:00:01 +08:00
|
|
|
lldbExec = lldbHere
|
2011-10-26 04:08:03 +08:00
|
|
|
|
2011-03-12 03:47:23 +08:00
|
|
|
|
|
|
|
if not lldbExec:
|
|
|
|
print "The 'lldb' executable cannot be located. Some of the tests may not be run as a result."
|
|
|
|
else:
|
|
|
|
os.environ["LLDB_EXEC"] = lldbExec
|
2011-10-28 08:59:00 +08:00
|
|
|
#print "The 'lldb' from PATH env variable", lldbExec
|
2011-03-17 08:38:22 +08:00
|
|
|
|
2011-06-25 06:52:05 +08:00
|
|
|
if os.path.isdir(os.path.join(base, '.svn')):
|
|
|
|
pipe = subprocess.Popen(["svn", "info", base], stdout = subprocess.PIPE)
|
|
|
|
svn_info = pipe.stdout.read()
|
|
|
|
elif os.path.isdir(os.path.join(base, '.git')):
|
|
|
|
pipe = subprocess.Popen(["git", "svn", "info", base], stdout = subprocess.PIPE)
|
|
|
|
svn_info = pipe.stdout.read()
|
2011-10-22 02:33:27 +08:00
|
|
|
if not noHeaders:
|
|
|
|
print svn_info
|
2011-03-12 03:47:23 +08:00
|
|
|
|
|
|
|
global ignore
|
|
|
|
|
|
|
|
# The '-i' option is used to skip looking for lldb.py in the build tree.
|
|
|
|
if ignore:
|
|
|
|
return
|
|
|
|
|
2011-02-16 02:50:19 +08:00
|
|
|
dbgPath = os.path.join(base, *(xcode3_build_dir + dbg + python_resource_dir))
|
|
|
|
dbgPath2 = os.path.join(base, *(xcode4_build_dir + dbg + python_resource_dir))
|
|
|
|
relPath = os.path.join(base, *(xcode3_build_dir + rel + python_resource_dir))
|
|
|
|
relPath2 = os.path.join(base, *(xcode4_build_dir + rel + python_resource_dir))
|
|
|
|
baiPath = os.path.join(base, *(xcode3_build_dir + bai + python_resource_dir))
|
|
|
|
baiPath2 = os.path.join(base, *(xcode4_build_dir + bai + python_resource_dir))
|
2010-06-26 05:14:08 +08:00
|
|
|
|
|
|
|
lldbPath = None
|
|
|
|
if os.path.isfile(os.path.join(dbgPath, 'lldb.py')):
|
|
|
|
lldbPath = dbgPath
|
2011-02-15 05:17:06 +08:00
|
|
|
elif os.path.isfile(os.path.join(dbgPath2, 'lldb.py')):
|
|
|
|
lldbPath = dbgPath2
|
2010-06-26 05:14:08 +08:00
|
|
|
elif os.path.isfile(os.path.join(relPath, 'lldb.py')):
|
|
|
|
lldbPath = relPath
|
2011-02-15 05:17:06 +08:00
|
|
|
elif os.path.isfile(os.path.join(relPath2, 'lldb.py')):
|
|
|
|
lldbPath = relPath2
|
2010-09-16 02:11:19 +08:00
|
|
|
elif os.path.isfile(os.path.join(baiPath, 'lldb.py')):
|
|
|
|
lldbPath = baiPath
|
2011-02-15 05:17:06 +08:00
|
|
|
elif os.path.isfile(os.path.join(baiPath2, 'lldb.py')):
|
|
|
|
lldbPath = baiPath2
|
2010-06-26 05:14:08 +08:00
|
|
|
|
|
|
|
if not lldbPath:
|
2010-09-16 02:11:19 +08:00
|
|
|
print 'This script requires lldb.py to be in either ' + dbgPath + ',',
|
|
|
|
print relPath + ', or ' + baiPath
|
2010-06-26 05:14:08 +08:00
|
|
|
sys.exit(-1)
|
|
|
|
|
2010-09-17 01:11:30 +08:00
|
|
|
# This is to locate the lldb.py module. Insert it right after sys.path[0].
|
|
|
|
sys.path[1:1] = [lldbPath]
|
2011-01-29 09:16:52 +08:00
|
|
|
if dumpSysPath:
|
|
|
|
print "sys.path:", sys.path
|
2010-06-26 05:14:08 +08:00
|
|
|
|
|
|
|
|
2010-09-21 02:07:50 +08:00
|
|
|
def doDelay(delta):
|
|
|
|
"""Delaying startup for delta-seconds to facilitate debugger attachment."""
|
|
|
|
def alarm_handler(*args):
|
|
|
|
raise Exception("timeout")
|
|
|
|
|
|
|
|
signal.signal(signal.SIGALRM, alarm_handler)
|
|
|
|
signal.alarm(delta)
|
|
|
|
sys.stdout.write("pid=%d\n" % os.getpid())
|
|
|
|
sys.stdout.write("Enter RET to proceed (or timeout after %d seconds):" %
|
|
|
|
delta)
|
|
|
|
sys.stdout.flush()
|
|
|
|
try:
|
|
|
|
text = sys.stdin.readline()
|
|
|
|
except:
|
|
|
|
text = ""
|
|
|
|
signal.alarm(0)
|
|
|
|
sys.stdout.write("proceeding...\n")
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2010-06-26 05:14:08 +08:00
|
|
|
def visit(prefix, dir, names):
|
|
|
|
"""Visitor function for os.path.walk(path, visit, arg)."""
|
|
|
|
|
|
|
|
global suite
|
2010-09-28 07:29:54 +08:00
|
|
|
global regexp
|
2011-07-30 06:54:56 +08:00
|
|
|
global filters
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
global fs4all
|
2012-01-18 13:15:00 +08:00
|
|
|
global excluded
|
|
|
|
|
|
|
|
if set(dir.split(os.sep)).intersection(excluded):
|
|
|
|
#print "Detected an excluded dir component: %s" % dir
|
|
|
|
return
|
2010-06-26 05:14:08 +08:00
|
|
|
|
|
|
|
for name in names:
|
|
|
|
if os.path.isdir(os.path.join(dir, name)):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if '.py' == os.path.splitext(name)[1] and name.startswith(prefix):
|
2010-09-28 07:29:54 +08:00
|
|
|
# Try to match the regexp pattern, if specified.
|
|
|
|
if regexp:
|
|
|
|
import re
|
|
|
|
if re.search(regexp, name):
|
|
|
|
#print "Filename: '%s' matches pattern: '%s'" % (name, regexp)
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
#print "Filename: '%s' does not match pattern: '%s'" % (name, regexp)
|
|
|
|
continue
|
|
|
|
|
2010-10-13 05:35:54 +08:00
|
|
|
# We found a match for our test. Add it to the suite.
|
2010-10-12 23:53:22 +08:00
|
|
|
|
|
|
|
# Update the sys.path first.
|
2010-06-26 08:19:32 +08:00
|
|
|
if not sys.path.count(dir):
|
2010-10-12 06:25:46 +08:00
|
|
|
sys.path.insert(0, dir)
|
2010-06-26 05:14:08 +08:00
|
|
|
base = os.path.splitext(name)[0]
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
|
|
|
|
# Thoroughly check the filterspec against the base module and admit
|
|
|
|
# the (base, filterspec) combination only when it makes sense.
|
2011-07-30 06:54:56 +08:00
|
|
|
filterspec = None
|
|
|
|
for filterspec in filters:
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
# Optimistically set the flag to True.
|
|
|
|
filtered = True
|
|
|
|
module = __import__(base)
|
|
|
|
parts = filterspec.split('.')
|
|
|
|
obj = module
|
|
|
|
for part in parts:
|
|
|
|
try:
|
|
|
|
parent, obj = obj, getattr(obj, part)
|
|
|
|
except AttributeError:
|
|
|
|
# The filterspec has failed.
|
|
|
|
filtered = False
|
|
|
|
break
|
2011-07-30 06:54:56 +08:00
|
|
|
|
2011-08-13 07:55:07 +08:00
|
|
|
# If filtered, we have a good filterspec. Add it.
|
2011-07-30 06:54:56 +08:00
|
|
|
if filtered:
|
2011-08-13 07:55:07 +08:00
|
|
|
#print "adding filter spec %s to module %s" % (filterspec, module)
|
|
|
|
suite.addTests(
|
|
|
|
unittest2.defaultTestLoader.loadTestsFromName(filterspec, module))
|
|
|
|
continue
|
2011-07-30 06:54:56 +08:00
|
|
|
|
|
|
|
# Forgo this module if the (base, filterspec) combo is invalid
|
|
|
|
# and no '-g' option is specified
|
|
|
|
if filters and fs4all and not filtered:
|
|
|
|
continue
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
|
2011-08-13 07:55:07 +08:00
|
|
|
# Add either the filtered test case(s) (which is done before) or the entire test class.
|
|
|
|
if not filterspec or not filtered:
|
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
llvm-svn: 115832
2010-10-07 04:40:56 +08:00
|
|
|
# A simple case of just the module name. Also the failover case
|
|
|
|
# from the filterspec branch when the (base, filterspec) combo
|
|
|
|
# doesn't make sense.
|
|
|
|
suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))
|
2010-06-26 05:14:08 +08:00
|
|
|
|
|
|
|
|
2010-09-21 02:07:50 +08:00
|
|
|
def lldbLoggings():
|
|
|
|
"""Check and do lldb loggings if necessary."""
|
|
|
|
|
|
|
|
# Turn on logging for debugging purposes if ${LLDB_LOG} environment variable is
|
|
|
|
# defined. Use ${LLDB_LOG} to specify the log file.
|
|
|
|
ci = lldb.DBG.GetCommandInterpreter()
|
|
|
|
res = lldb.SBCommandReturnObject()
|
|
|
|
if ("LLDB_LOG" in os.environ):
|
|
|
|
if ("LLDB_LOG_OPTION" in os.environ):
|
|
|
|
lldb_log_option = os.environ["LLDB_LOG_OPTION"]
|
|
|
|
else:
|
2010-12-08 09:25:21 +08:00
|
|
|
lldb_log_option = "event process expr state api"
|
2010-09-21 02:07:50 +08:00
|
|
|
ci.HandleCommand(
|
2011-02-23 08:35:02 +08:00
|
|
|
"log enable -n -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option,
|
2010-09-21 02:07:50 +08:00
|
|
|
res)
|
|
|
|
if not res.Succeeded():
|
|
|
|
raise Exception('log enable failed (check LLDB_LOG env variable.')
|
|
|
|
# Ditto for gdb-remote logging if ${GDB_REMOTE_LOG} environment variable is defined.
|
|
|
|
# Use ${GDB_REMOTE_LOG} to specify the log file.
|
|
|
|
if ("GDB_REMOTE_LOG" in os.environ):
|
|
|
|
if ("GDB_REMOTE_LOG_OPTION" in os.environ):
|
|
|
|
gdb_remote_log_option = os.environ["GDB_REMOTE_LOG_OPTION"]
|
|
|
|
else:
|
2010-12-03 02:35:13 +08:00
|
|
|
gdb_remote_log_option = "packets process"
|
2010-09-21 02:07:50 +08:00
|
|
|
ci.HandleCommand(
|
2011-06-22 03:25:45 +08:00
|
|
|
"log enable -n -f " + os.environ["GDB_REMOTE_LOG"] + " gdb-remote "
|
2010-09-21 02:07:50 +08:00
|
|
|
+ gdb_remote_log_option,
|
|
|
|
res)
|
|
|
|
if not res.Succeeded():
|
|
|
|
raise Exception('log enable failed (check GDB_REMOTE_LOG env variable.')
|
|
|
|
|
2011-01-20 03:31:46 +08:00
|
|
|
def getMyCommandLine():
|
|
|
|
ps = subprocess.Popen(['ps', '-o', "command=CMD", str(os.getpid())], stdout=subprocess.PIPE).communicate()[0]
|
|
|
|
lines = ps.split('\n')
|
|
|
|
cmd_line = lines[1]
|
|
|
|
return cmd_line
|
2010-09-21 02:07:50 +08:00
|
|
|
|
2010-11-06 01:30:53 +08:00
|
|
|
# ======================================== #
|
2010-09-21 02:07:50 +08:00
|
|
|
# #
|
|
|
|
# Execution of the test driver starts here #
|
|
|
|
# #
|
2010-11-06 01:30:53 +08:00
|
|
|
# ======================================== #
|
2010-09-21 02:07:50 +08:00
|
|
|
|
2011-09-16 09:04:26 +08:00
|
|
|
def checkDsymForUUIDIsNotOn():
|
2011-09-17 01:50:44 +08:00
|
|
|
cmd = ["defaults", "read", "com.apple.DebugSymbols"]
|
|
|
|
pipe = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
|
|
|
cmd_output = pipe.stdout.read()
|
2011-09-17 02:03:19 +08:00
|
|
|
if cmd_output and "DBGFileMappedPaths = " in cmd_output:
|
2011-09-17 02:09:45 +08:00
|
|
|
print "%s =>" % ' '.join(cmd)
|
2011-09-17 01:50:44 +08:00
|
|
|
print cmd_output
|
2011-09-16 09:04:26 +08:00
|
|
|
print "Disable automatic lookup and caching of dSYMs before running the test suite!"
|
|
|
|
print "Exiting..."
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
# On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults
|
|
|
|
# does not exist before proceeding to running the test suite.
|
|
|
|
if sys.platform.startswith("darwin"):
|
|
|
|
checkDsymForUUIDIsNotOn()
|
|
|
|
|
2010-06-26 05:14:08 +08:00
|
|
|
#
|
2010-09-17 01:11:30 +08:00
|
|
|
# Start the actions by first parsing the options while setting up the test
|
|
|
|
# directories, followed by setting up the search paths for lldb utilities;
|
|
|
|
# then, we walk the directory trees and collect the tests into our test suite.
|
2010-06-26 05:14:08 +08:00
|
|
|
#
|
2010-09-17 01:11:30 +08:00
|
|
|
parseOptionsAndInitTestdirs()
|
2010-06-26 05:14:08 +08:00
|
|
|
setupSysPath()
|
2010-09-09 04:56:16 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# If '-d' is specified, do a delay of 10 seconds for the debugger to attach.
|
|
|
|
#
|
|
|
|
if delay:
|
2010-09-21 02:07:50 +08:00
|
|
|
doDelay(10)
|
2010-09-09 04:56:16 +08:00
|
|
|
|
2010-10-02 06:59:49 +08:00
|
|
|
#
|
|
|
|
# If '-l' is specified, do not skip the long running tests.
|
2011-11-18 03:57:27 +08:00
|
|
|
if not skip_long_running_test:
|
2010-10-02 06:59:49 +08:00
|
|
|
os.environ["LLDB_SKIP_LONG_RUNNING_TEST"] = "NO"
|
|
|
|
|
2010-09-21 01:25:45 +08:00
|
|
|
#
|
2010-10-12 23:53:22 +08:00
|
|
|
# Walk through the testdirs while collecting tests.
|
2010-09-21 01:25:45 +08:00
|
|
|
#
|
2010-06-26 05:14:08 +08:00
|
|
|
for testdir in testdirs:
|
|
|
|
os.path.walk(testdir, visit, 'Test')
|
|
|
|
|
2010-09-21 08:09:27 +08:00
|
|
|
#
|
2010-06-26 05:14:08 +08:00
|
|
|
# Now that we have loaded all the test cases, run the whole test suite.
|
2010-09-21 08:09:27 +08:00
|
|
|
#
|
2010-09-21 02:07:50 +08:00
|
|
|
|
2010-06-30 03:44:16 +08:00
|
|
|
# For the time being, let's bracket the test runner within the
|
|
|
|
# lldb.SBDebugger.Initialize()/Terminate() pair.
|
2010-08-11 04:23:55 +08:00
|
|
|
import lldb, atexit
|
2010-10-15 00:36:49 +08:00
|
|
|
# Update: the act of importing lldb now executes lldb.SBDebugger.Initialize(),
|
|
|
|
# there's no need to call it a second time.
|
|
|
|
#lldb.SBDebugger.Initialize()
|
2010-08-11 04:23:55 +08:00
|
|
|
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
2010-06-30 03:44:16 +08:00
|
|
|
|
2010-07-02 06:52:57 +08:00
|
|
|
# Create a singleton SBDebugger in the lldb namespace.
|
|
|
|
lldb.DBG = lldb.SBDebugger.Create()
|
|
|
|
|
2010-12-10 08:51:23 +08:00
|
|
|
# Put the blacklist in the lldb namespace, to be used by lldb.TestBase.
|
2010-12-02 06:47:54 +08:00
|
|
|
lldb.blacklist = blacklist
|
|
|
|
|
2011-10-11 06:03:44 +08:00
|
|
|
# Put dont/just_do_python_api_test in the lldb namespace.
|
2010-12-10 08:51:23 +08:00
|
|
|
lldb.dont_do_python_api_test = dont_do_python_api_test
|
|
|
|
lldb.just_do_python_api_test = just_do_python_api_test
|
2011-07-30 09:39:58 +08:00
|
|
|
lldb.just_do_benchmarks_test = just_do_benchmarks_test
|
2010-12-10 08:51:23 +08:00
|
|
|
|
2011-11-18 03:57:27 +08:00
|
|
|
# Do we need to skip build and cleanup?
|
|
|
|
lldb.skip_build_and_cleanup = skip_build_and_cleanup
|
|
|
|
|
2011-10-21 02:43:28 +08:00
|
|
|
# Put bmExecutable, bmBreakpointSpec, and bmIterationCount into the lldb namespace, too.
|
2011-10-11 06:03:44 +08:00
|
|
|
lldb.bmExecutable = bmExecutable
|
|
|
|
lldb.bmBreakpointSpec = bmBreakpointSpec
|
2011-10-21 02:43:28 +08:00
|
|
|
lldb.bmIterationCount = bmIterationCount
|
2011-10-11 06:03:44 +08:00
|
|
|
|
2011-10-11 09:30:27 +08:00
|
|
|
# And don't forget the runHooks!
|
|
|
|
lldb.runHooks = runHooks
|
|
|
|
|
2010-09-21 02:07:50 +08:00
|
|
|
# Turn on lldb loggings if necessary.
|
|
|
|
lldbLoggings()
|
2010-07-02 06:52:57 +08:00
|
|
|
|
2010-08-10 04:40:52 +08:00
|
|
|
# Install the control-c handler.
|
|
|
|
unittest2.signals.installHandler()
|
|
|
|
|
Add an option '-s session-dir-name' to overwrite the default timestamp-named
directory used to dump the session info for test failures/errors.
Example:
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -s jason -v array_types
Session info for test errors or failures will go into directory jason
----------------------------------------------------------------------
Collected 4 tests
test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dsym_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dwarf_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... FAIL
======================================================================
FAIL: test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 27, in test_with_dwarf_and_run_command
self.array_types()
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 62, in array_types
'stop reason = breakpoint'])
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 594, in expect
self.runCmd(str, trace = (True if trace else False), check = not error)
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 564, in runCmd
msg if msg else CMD_MSG(cmd, True))
AssertionError: False is not True : Command 'thread list' returns successfully
----------------------------------------------------------------------
Ran 4 tests in 3.086s
FAILED (failures=1)
/Volumes/data/lldb/svn/trunk/test $ ls jason
TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
/Volumes/data/lldb/svn/trunk/test $ head -10 jason/TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
Session info generated @ Thu Oct 21 09:54:15 2010
os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=NO']]
stdout: rm -rf "a.out" "a.out.dSYM" main.o main.d
cc -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c
cc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out"
stderr: None
retcode: 0
/Volumes/data/lldb/svn/trunk/test $
llvm-svn: 117028
2010-10-22 00:55:35 +08:00
|
|
|
# If sdir_name is not specified through the '-s sdir_name' option, get a
|
|
|
|
# timestamp string and export it as LLDB_SESSION_DIR environment var. This will
|
|
|
|
# be used when/if we want to dump the session info of individual test cases
|
|
|
|
# later on.
|
2010-10-19 08:25:01 +08:00
|
|
|
#
|
|
|
|
# See also TestBase.dumpSessionInfo() in lldbtest.py.
|
Add an option '-s session-dir-name' to overwrite the default timestamp-named
directory used to dump the session info for test failures/errors.
Example:
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -s jason -v array_types
Session info for test errors or failures will go into directory jason
----------------------------------------------------------------------
Collected 4 tests
test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dsym_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dwarf_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... FAIL
======================================================================
FAIL: test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 27, in test_with_dwarf_and_run_command
self.array_types()
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 62, in array_types
'stop reason = breakpoint'])
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 594, in expect
self.runCmd(str, trace = (True if trace else False), check = not error)
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 564, in runCmd
msg if msg else CMD_MSG(cmd, True))
AssertionError: False is not True : Command 'thread list' returns successfully
----------------------------------------------------------------------
Ran 4 tests in 3.086s
FAILED (failures=1)
/Volumes/data/lldb/svn/trunk/test $ ls jason
TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
/Volumes/data/lldb/svn/trunk/test $ head -10 jason/TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
Session info generated @ Thu Oct 21 09:54:15 2010
os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=NO']]
stdout: rm -rf "a.out" "a.out.dSYM" main.o main.d
cc -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c
cc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out"
stderr: None
retcode: 0
/Volumes/data/lldb/svn/trunk/test $
llvm-svn: 117028
2010-10-22 00:55:35 +08:00
|
|
|
if not sdir_name:
|
|
|
|
import datetime
|
2010-10-30 06:26:38 +08:00
|
|
|
# The windows platforms don't like ':' in the pathname.
|
2010-10-29 00:32:13 +08:00
|
|
|
timestamp = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S")
|
Add an option '-s session-dir-name' to overwrite the default timestamp-named
directory used to dump the session info for test failures/errors.
Example:
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -s jason -v array_types
Session info for test errors or failures will go into directory jason
----------------------------------------------------------------------
Collected 4 tests
test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dsym_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dwarf_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... ok
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... FAIL
======================================================================
FAIL: test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 27, in test_with_dwarf_and_run_command
self.array_types()
File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 62, in array_types
'stop reason = breakpoint'])
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 594, in expect
self.runCmd(str, trace = (True if trace else False), check = not error)
File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 564, in runCmd
msg if msg else CMD_MSG(cmd, True))
AssertionError: False is not True : Command 'thread list' returns successfully
----------------------------------------------------------------------
Ran 4 tests in 3.086s
FAILED (failures=1)
/Volumes/data/lldb/svn/trunk/test $ ls jason
TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
/Volumes/data/lldb/svn/trunk/test $ head -10 jason/TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log
Session info generated @ Thu Oct 21 09:54:15 2010
os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=NO']]
stdout: rm -rf "a.out" "a.out.dSYM" main.o main.d
cc -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c
cc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out"
stderr: None
retcode: 0
/Volumes/data/lldb/svn/trunk/test $
llvm-svn: 117028
2010-10-22 00:55:35 +08:00
|
|
|
sdir_name = timestamp
|
2011-06-21 07:55:53 +08:00
|
|
|
os.environ["LLDB_SESSION_DIRNAME"] = os.path.join(os.getcwd(), sdir_name)
|
2011-01-20 03:31:46 +08:00
|
|
|
|
2011-10-22 02:33:27 +08:00
|
|
|
if not noHeaders:
|
|
|
|
sys.stderr.write("\nSession logs for test failures/errors/unexpected successes"
|
|
|
|
" will go into directory '%s'\n" % sdir_name)
|
|
|
|
sys.stderr.write("Command invoked: %s\n" % getMyCommandLine())
|
2010-10-19 08:25:01 +08:00
|
|
|
|
2011-05-18 06:58:50 +08:00
|
|
|
if not os.path.isdir(sdir_name):
|
|
|
|
os.mkdir(sdir_name)
|
|
|
|
fname = os.path.join(sdir_name, "svn-info")
|
|
|
|
with open(fname, "w") as f:
|
|
|
|
print >> f, svn_info
|
|
|
|
print >> f, "Command invoked: %s\n" % getMyCommandLine()
|
|
|
|
|
2012-01-31 08:38:03 +08:00
|
|
|
#
|
|
|
|
# If we have environment variables to unset, do it here before we invoke the test runner.
|
|
|
|
#
|
|
|
|
for env_var in unsets :
|
|
|
|
if env_var in os.environ:
|
|
|
|
# From Python Doc: When unsetenv() is supported, deletion of items in os.environ
|
2012-01-31 08:48:02 +08:00
|
|
|
# is automatically translated into a corresponding call to unsetenv().
|
2012-01-31 08:38:03 +08:00
|
|
|
del os.environ[env_var]
|
|
|
|
#os.unsetenv(env_var)
|
|
|
|
|
2010-09-21 08:09:27 +08:00
|
|
|
#
|
|
|
|
# Invoke the default TextTestRunner to run the test suite, possibly iterating
|
|
|
|
# over different configurations.
|
|
|
|
#
|
|
|
|
|
|
|
|
iterArchs = False
|
2010-09-21 08:16:09 +08:00
|
|
|
iterCompilers = False
|
2010-09-21 08:09:27 +08:00
|
|
|
|
2011-03-04 09:35:22 +08:00
|
|
|
if not archs and "archs" in config:
|
2010-09-21 08:09:27 +08:00
|
|
|
archs = config["archs"]
|
2011-03-04 09:35:22 +08:00
|
|
|
|
|
|
|
if isinstance(archs, list) and len(archs) >= 1:
|
|
|
|
iterArchs = True
|
|
|
|
|
|
|
|
if not compilers and "compilers" in config:
|
2010-09-21 08:09:27 +08:00
|
|
|
compilers = config["compilers"]
|
2011-03-04 09:35:22 +08:00
|
|
|
|
2012-03-09 10:11:37 +08:00
|
|
|
#
|
|
|
|
# Add some intervention here to sanity check that the compilers requested are sane.
|
|
|
|
# If found not to be an executable program, the invalid one is dropped from the list.
|
|
|
|
for i in range(len(compilers)):
|
|
|
|
c = compilers[i]
|
|
|
|
if which(c):
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
if sys.platform.startswith("darwin"):
|
|
|
|
pipe = subprocess.Popen(['xcrun', '-find', c], stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
|
|
|
cmd_output = pipe.stdout.read()
|
|
|
|
if cmd_output:
|
|
|
|
if "not found" in cmd_output:
|
|
|
|
print "dropping %s from the compilers used" % c
|
|
|
|
compilers.remove(i)
|
|
|
|
else:
|
|
|
|
compilers[i] = cmd_output.split('\n')[0]
|
|
|
|
print "'xcrun -find %s' returning %s" % (c, compilers[i])
|
|
|
|
|
|
|
|
print "compilers=%s" % str(compilers)
|
|
|
|
|
|
|
|
if not compilers or len(compilers) == 0:
|
|
|
|
print "No eligible compiler found, exiting."
|
|
|
|
sys.exit(1)
|
|
|
|
|
2011-03-04 09:35:22 +08:00
|
|
|
if isinstance(compilers, list) and len(compilers) >= 1:
|
|
|
|
iterCompilers = True
|
2010-09-21 08:09:27 +08:00
|
|
|
|
2010-10-13 05:35:54 +08:00
|
|
|
# Make a shallow copy of sys.path, we need to manipulate the search paths later.
|
|
|
|
# This is only necessary if we are relocated and with different configurations.
|
2011-03-04 09:35:22 +08:00
|
|
|
if rdir:
|
2010-10-13 05:35:54 +08:00
|
|
|
old_sys_path = sys.path[:]
|
2011-03-04 09:35:22 +08:00
|
|
|
# If we iterate on archs or compilers, there is a chance we want to split stderr/stdout.
|
|
|
|
if iterArchs or iterCompilers:
|
2010-10-13 05:35:54 +08:00
|
|
|
old_stderr = sys.stderr
|
|
|
|
old_stdout = sys.stdout
|
|
|
|
new_stderr = None
|
|
|
|
new_stdout = None
|
|
|
|
|
2010-11-06 01:30:53 +08:00
|
|
|
# Iterating over all possible architecture and compiler combinations.
|
2010-09-21 08:09:27 +08:00
|
|
|
for ia in range(len(archs) if iterArchs else 1):
|
|
|
|
archConfig = ""
|
|
|
|
if iterArchs:
|
2010-10-01 01:11:58 +08:00
|
|
|
os.environ["ARCH"] = archs[ia]
|
2010-09-21 08:09:27 +08:00
|
|
|
archConfig = "arch=%s" % archs[ia]
|
|
|
|
for ic in range(len(compilers) if iterCompilers else 1):
|
|
|
|
if iterCompilers:
|
2010-10-01 01:11:58 +08:00
|
|
|
os.environ["CC"] = compilers[ic]
|
2010-09-21 08:09:27 +08:00
|
|
|
configString = "%s compiler=%s" % (archConfig, compilers[ic])
|
|
|
|
else:
|
|
|
|
configString = archConfig
|
|
|
|
|
|
|
|
if iterArchs or iterCompilers:
|
2011-03-04 09:35:22 +08:00
|
|
|
# Translate ' ' to '-' for pathname component.
|
|
|
|
from string import maketrans
|
|
|
|
tbl = maketrans(' ', '-')
|
|
|
|
configPostfix = configString.translate(tbl)
|
|
|
|
|
|
|
|
# Check whether we need to split stderr/stdout into configuration
|
|
|
|
# specific files.
|
|
|
|
if old_stderr.name != '<stderr>' and config.get('split_stderr'):
|
|
|
|
if new_stderr:
|
|
|
|
new_stderr.close()
|
|
|
|
new_stderr = open("%s.%s" % (old_stderr.name, configPostfix), "w")
|
|
|
|
sys.stderr = new_stderr
|
|
|
|
if old_stdout.name != '<stdout>' and config.get('split_stdout'):
|
|
|
|
if new_stdout:
|
|
|
|
new_stdout.close()
|
|
|
|
new_stdout = open("%s.%s" % (old_stdout.name, configPostfix), "w")
|
|
|
|
sys.stdout = new_stdout
|
|
|
|
|
2010-10-13 05:35:54 +08:00
|
|
|
# If we specified a relocated directory to run the test suite, do
|
|
|
|
# the extra housekeeping to copy the testdirs to a configStringified
|
|
|
|
# directory and to update sys.path before invoking the test runner.
|
|
|
|
# The purpose is to separate the configuration-specific directories
|
|
|
|
# from each other.
|
|
|
|
if rdir:
|
|
|
|
from shutil import copytree, ignore_patterns
|
|
|
|
|
|
|
|
newrdir = "%s.%s" % (rdir, configPostfix)
|
|
|
|
|
|
|
|
# Copy the tree to a new directory with postfix name configPostfix.
|
|
|
|
copytree(rdir, newrdir, ignore=ignore_patterns('*.pyc', '*.o', '*.d'))
|
|
|
|
|
2011-03-04 09:35:22 +08:00
|
|
|
# Update the LLDB_TEST environment variable to reflect new top
|
2010-10-13 05:35:54 +08:00
|
|
|
# level test directory.
|
|
|
|
#
|
|
|
|
# See also lldbtest.TestBase.setUpClass(cls).
|
|
|
|
if len(testdirs) == 1 and os.path.basename(testdirs[0]) == 'test':
|
|
|
|
os.environ["LLDB_TEST"] = os.path.join(newrdir, 'test')
|
|
|
|
else:
|
|
|
|
os.environ["LLDB_TEST"] = newrdir
|
|
|
|
|
|
|
|
# And update the Python search paths for modules.
|
|
|
|
sys.path = [x.replace(rdir, newrdir, 1) for x in old_sys_path]
|
|
|
|
|
|
|
|
# Output the configuration.
|
2010-09-21 08:09:27 +08:00
|
|
|
sys.stderr.write("\nConfiguration: " + configString + "\n")
|
2010-10-13 05:35:54 +08:00
|
|
|
|
|
|
|
#print "sys.stderr name is", sys.stderr.name
|
|
|
|
#print "sys.stdout name is", sys.stdout.name
|
|
|
|
|
|
|
|
# First, write out the number of collected test cases.
|
2011-11-18 08:19:29 +08:00
|
|
|
sys.stderr.write(separator + "\n")
|
|
|
|
sys.stderr.write("Collected %d test%s\n\n"
|
|
|
|
% (suite.countTestCases(),
|
|
|
|
suite.countTestCases() != 1 and "s" or ""))
|
2010-10-13 05:35:54 +08:00
|
|
|
|
2010-10-15 09:18:29 +08:00
|
|
|
class LLDBTestResult(unittest2.TextTestResult):
|
|
|
|
"""
|
2010-11-10 07:56:14 +08:00
|
|
|
Enforce a singleton pattern to allow introspection of test progress.
|
|
|
|
|
|
|
|
Overwrite addError(), addFailure(), and addExpectedFailure() methods
|
|
|
|
to enable each test instance to track its failure/error status. It
|
|
|
|
is used in the LLDB test framework to emit detailed trace messages
|
|
|
|
to a log file for easier human inspection of test failres/errors.
|
2010-10-15 09:18:29 +08:00
|
|
|
"""
|
|
|
|
__singleton__ = None
|
2010-11-30 01:50:10 +08:00
|
|
|
__ignore_singleton__ = False
|
2010-10-15 09:18:29 +08:00
|
|
|
|
|
|
|
def __init__(self, *args):
|
2010-11-30 01:50:10 +08:00
|
|
|
if not LLDBTestResult.__ignore_singleton__ and LLDBTestResult.__singleton__:
|
2010-11-17 06:42:58 +08:00
|
|
|
raise Exception("LLDBTestResult instantiated more than once")
|
2010-10-15 09:18:29 +08:00
|
|
|
super(LLDBTestResult, self).__init__(*args)
|
|
|
|
LLDBTestResult.__singleton__ = self
|
|
|
|
# Now put this singleton into the lldb module namespace.
|
|
|
|
lldb.test_result = self
|
2011-01-06 04:24:11 +08:00
|
|
|
# Computes the format string for displaying the counter.
|
|
|
|
global suite
|
|
|
|
counterWidth = len(str(suite.countTestCases()))
|
|
|
|
self.fmt = "%" + str(counterWidth) + "d: "
|
2011-01-06 06:50:11 +08:00
|
|
|
self.indentation = ' ' * (counterWidth + 2)
|
2011-01-06 04:24:11 +08:00
|
|
|
# This counts from 1 .. suite.countTestCases().
|
|
|
|
self.counter = 0
|
|
|
|
|
2011-01-06 06:50:11 +08:00
|
|
|
def getDescription(self, test):
|
|
|
|
doc_first_line = test.shortDescription()
|
|
|
|
if self.descriptions and doc_first_line:
|
|
|
|
return '\n'.join((str(test), self.indentation + doc_first_line))
|
|
|
|
else:
|
|
|
|
return str(test)
|
|
|
|
|
2011-01-06 04:24:11 +08:00
|
|
|
def startTest(self, test):
|
|
|
|
self.counter += 1
|
|
|
|
if self.showAll:
|
|
|
|
self.stream.write(self.fmt % self.counter)
|
|
|
|
super(LLDBTestResult, self).startTest(test)
|
2010-10-15 09:18:29 +08:00
|
|
|
|
2011-11-18 08:19:29 +08:00
|
|
|
def stopTest(self, test):
|
|
|
|
"""Called when the given test has been run"""
|
|
|
|
if progress_bar:
|
|
|
|
sys.__stdout__.write('.')
|
|
|
|
sys.__stdout__.flush()
|
|
|
|
if self.counter == suite.countTestCases():
|
|
|
|
sys.__stdout__.write('\n')
|
|
|
|
|
|
|
|
super(LLDBTestResult, self).stopTest(test)
|
|
|
|
|
2010-10-19 08:25:01 +08:00
|
|
|
def addError(self, test, err):
|
2010-10-30 06:20:36 +08:00
|
|
|
global sdir_has_content
|
|
|
|
sdir_has_content = True
|
2010-10-19 08:25:01 +08:00
|
|
|
super(LLDBTestResult, self).addError(test, err)
|
|
|
|
method = getattr(test, "markError", None)
|
|
|
|
if method:
|
|
|
|
method()
|
|
|
|
|
2010-10-15 09:18:29 +08:00
|
|
|
def addFailure(self, test, err):
|
2010-10-30 06:20:36 +08:00
|
|
|
global sdir_has_content
|
|
|
|
sdir_has_content = True
|
2010-10-15 09:18:29 +08:00
|
|
|
super(LLDBTestResult, self).addFailure(test, err)
|
|
|
|
method = getattr(test, "markFailure", None)
|
|
|
|
if method:
|
|
|
|
method()
|
|
|
|
|
2010-11-04 02:17:03 +08:00
|
|
|
def addExpectedFailure(self, test, err):
|
|
|
|
global sdir_has_content
|
|
|
|
sdir_has_content = True
|
|
|
|
super(LLDBTestResult, self).addExpectedFailure(test, err)
|
|
|
|
method = getattr(test, "markExpectedFailure", None)
|
|
|
|
if method:
|
|
|
|
method()
|
|
|
|
|
2011-08-16 07:09:08 +08:00
|
|
|
def addSkip(self, test, reason):
|
|
|
|
global sdir_has_content
|
|
|
|
sdir_has_content = True
|
|
|
|
super(LLDBTestResult, self).addSkip(test, reason)
|
|
|
|
method = getattr(test, "markSkippedTest", None)
|
|
|
|
if method:
|
|
|
|
method()
|
|
|
|
|
2011-05-07 04:30:22 +08:00
|
|
|
def addUnexpectedSuccess(self, test):
|
|
|
|
global sdir_has_content
|
|
|
|
sdir_has_content = True
|
|
|
|
super(LLDBTestResult, self).addUnexpectedSuccess(test)
|
|
|
|
method = getattr(test, "markUnexpectedSuccess", None)
|
|
|
|
if method:
|
|
|
|
method()
|
|
|
|
|
2010-11-10 07:56:14 +08:00
|
|
|
# Invoke the test runner.
|
2010-11-17 06:42:58 +08:00
|
|
|
if count == 1:
|
2010-12-04 03:59:35 +08:00
|
|
|
result = unittest2.TextTestRunner(stream=sys.stderr,
|
|
|
|
verbosity=verbose,
|
|
|
|
failfast=failfast,
|
2010-11-17 06:42:58 +08:00
|
|
|
resultclass=LLDBTestResult).run(suite)
|
|
|
|
else:
|
2010-11-30 01:52:43 +08:00
|
|
|
# We are invoking the same test suite more than once. In this case,
|
|
|
|
# mark __ignore_singleton__ flag as True so the signleton pattern is
|
|
|
|
# not enforced.
|
2010-11-30 01:50:10 +08:00
|
|
|
LLDBTestResult.__ignore_singleton__ = True
|
2010-11-17 06:42:58 +08:00
|
|
|
for i in range(count):
|
2010-12-04 03:59:35 +08:00
|
|
|
result = unittest2.TextTestRunner(stream=sys.stderr,
|
|
|
|
verbosity=verbose,
|
|
|
|
failfast=failfast,
|
2010-11-30 01:50:10 +08:00
|
|
|
resultclass=LLDBTestResult).run(suite)
|
2010-09-21 08:09:27 +08:00
|
|
|
|
2010-06-30 03:44:16 +08:00
|
|
|
|
2010-10-30 06:20:36 +08:00
|
|
|
if sdir_has_content:
|
2011-05-07 04:30:22 +08:00
|
|
|
sys.stderr.write("Session logs for test failures/errors/unexpected successes"
|
|
|
|
" can be found in directory '%s'\n" % sdir_name)
|
2010-10-30 06:20:36 +08:00
|
|
|
|
2010-09-21 02:07:50 +08:00
|
|
|
# Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined.
|
|
|
|
# This should not be necessary now.
|
2010-08-14 06:58:44 +08:00
|
|
|
if ("LLDB_TESTSUITE_FORCE_FINISH" in os.environ):
|
|
|
|
print "Terminating Test suite..."
|
|
|
|
subprocess.Popen(["/bin/sh", "-c", "kill %s; exit 0" % (os.getpid())])
|
|
|
|
|
2010-08-11 04:23:55 +08:00
|
|
|
# Exiting.
|
|
|
|
sys.exit(not result.wasSuccessful)
|