2015-10-29 01:43:26 +08:00
|
|
|
"""
|
|
|
|
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.
|
|
|
|
|
|
|
|
Type:
|
|
|
|
|
|
|
|
./dotest.py -h
|
|
|
|
|
|
|
|
for available options.
|
|
|
|
"""
|
|
|
|
|
Python 3 - Turn on absolute imports, and fix existing imports.
Absolute imports were introduced in Python 2.5 as a feature
(e.g. from __future__ import absolute_import), and made default
in Python 3.
When absolute imports are enabled, the import system changes in
a couple of ways:
1) The `import foo` syntax will *only* search sys.path. If `foo`
isn't in sys.path, it won't be found. Period. Without absolute
imports, the import system will also search the same directory
that the importing file resides in, so that you can easily
import from the same folder.
2) From inside a package, you can use a dot syntax to refer to higher
levels of the current package. For example, if you are in the
package lldbsuite.test.utility, then ..foo refers to
lldbsuite.test.foo. You can use this notation with the
`from X import Y` syntax to write intra-package references. For
example, using the previous locationa s a starting point, writing
`from ..support import seven` would import lldbsuite.support.seven
Since this is now the default behavior in Python 3, this means that
importing from the same directory with `import foo` *no longer works*.
As a result, the only way to have portable code is to force absolute
imports for all versions of Python.
See PEP 0328 [https://www.python.org/dev/peps/pep-0328/] for more
information about absolute and relative imports.
Differential Revision: http://reviews.llvm.org/D14342
Reviewed By: Todd Fiala
llvm-svn: 252191
2015-11-06 03:22:28 +08:00
|
|
|
from __future__ import absolute_import
|
2015-10-29 01:43:26 +08:00
|
|
|
from __future__ import print_function
|
2015-11-03 03:38:58 +08:00
|
|
|
|
Python 3 - Turn on absolute imports, and fix existing imports.
Absolute imports were introduced in Python 2.5 as a feature
(e.g. from __future__ import absolute_import), and made default
in Python 3.
When absolute imports are enabled, the import system changes in
a couple of ways:
1) The `import foo` syntax will *only* search sys.path. If `foo`
isn't in sys.path, it won't be found. Period. Without absolute
imports, the import system will also search the same directory
that the importing file resides in, so that you can easily
import from the same folder.
2) From inside a package, you can use a dot syntax to refer to higher
levels of the current package. For example, if you are in the
package lldbsuite.test.utility, then ..foo refers to
lldbsuite.test.foo. You can use this notation with the
`from X import Y` syntax to write intra-package references. For
example, using the previous locationa s a starting point, writing
`from ..support import seven` would import lldbsuite.support.seven
Since this is now the default behavior in Python 3, this means that
importing from the same directory with `import foo` *no longer works*.
As a result, the only way to have portable code is to force absolute
imports for all versions of Python.
See PEP 0328 [https://www.python.org/dev/peps/pep-0328/] for more
information about absolute and relative imports.
Differential Revision: http://reviews.llvm.org/D14342
Reviewed By: Todd Fiala
llvm-svn: 252191
2015-11-06 03:22:28 +08:00
|
|
|
# System modules
|
2015-10-29 01:43:26 +08:00
|
|
|
import atexit
|
|
|
|
import os
|
|
|
|
import errno
|
2017-03-18 02:10:58 +08:00
|
|
|
import logging
|
2015-10-29 01:43:26 +08:00
|
|
|
import platform
|
2016-09-24 05:32:47 +08:00
|
|
|
import re
|
2015-10-29 01:43:26 +08:00
|
|
|
import signal
|
|
|
|
import socket
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
Python 3 - Turn on absolute imports, and fix existing imports.
Absolute imports were introduced in Python 2.5 as a feature
(e.g. from __future__ import absolute_import), and made default
in Python 3.
When absolute imports are enabled, the import system changes in
a couple of ways:
1) The `import foo` syntax will *only* search sys.path. If `foo`
isn't in sys.path, it won't be found. Period. Without absolute
imports, the import system will also search the same directory
that the importing file resides in, so that you can easily
import from the same folder.
2) From inside a package, you can use a dot syntax to refer to higher
levels of the current package. For example, if you are in the
package lldbsuite.test.utility, then ..foo refers to
lldbsuite.test.foo. You can use this notation with the
`from X import Y` syntax to write intra-package references. For
example, using the previous locationa s a starting point, writing
`from ..support import seven` would import lldbsuite.support.seven
Since this is now the default behavior in Python 3, this means that
importing from the same directory with `import foo` *no longer works*.
As a result, the only way to have portable code is to force absolute
imports for all versions of Python.
See PEP 0328 [https://www.python.org/dev/peps/pep-0328/] for more
information about absolute and relative imports.
Differential Revision: http://reviews.llvm.org/D14342
Reviewed By: Todd Fiala
llvm-svn: 252191
2015-11-06 03:22:28 +08:00
|
|
|
# Third-party modules
|
2015-10-29 01:43:26 +08:00
|
|
|
import six
|
Python 3 - Turn on absolute imports, and fix existing imports.
Absolute imports were introduced in Python 2.5 as a feature
(e.g. from __future__ import absolute_import), and made default
in Python 3.
When absolute imports are enabled, the import system changes in
a couple of ways:
1) The `import foo` syntax will *only* search sys.path. If `foo`
isn't in sys.path, it won't be found. Period. Without absolute
imports, the import system will also search the same directory
that the importing file resides in, so that you can easily
import from the same folder.
2) From inside a package, you can use a dot syntax to refer to higher
levels of the current package. For example, if you are in the
package lldbsuite.test.utility, then ..foo refers to
lldbsuite.test.foo. You can use this notation with the
`from X import Y` syntax to write intra-package references. For
example, using the previous locationa s a starting point, writing
`from ..support import seven` would import lldbsuite.support.seven
Since this is now the default behavior in Python 3, this means that
importing from the same directory with `import foo` *no longer works*.
As a result, the only way to have portable code is to force absolute
imports for all versions of Python.
See PEP 0328 [https://www.python.org/dev/peps/pep-0328/] for more
information about absolute and relative imports.
Differential Revision: http://reviews.llvm.org/D14342
Reviewed By: Todd Fiala
llvm-svn: 252191
2015-11-06 03:22:28 +08:00
|
|
|
import unittest2
|
|
|
|
|
|
|
|
# LLDB Modules
|
|
|
|
import lldbsuite
|
2015-12-08 09:15:30 +08:00
|
|
|
from . import configuration
|
Python 3 - Turn on absolute imports, and fix existing imports.
Absolute imports were introduced in Python 2.5 as a feature
(e.g. from __future__ import absolute_import), and made default
in Python 3.
When absolute imports are enabled, the import system changes in
a couple of ways:
1) The `import foo` syntax will *only* search sys.path. If `foo`
isn't in sys.path, it won't be found. Period. Without absolute
imports, the import system will also search the same directory
that the importing file resides in, so that you can easily
import from the same folder.
2) From inside a package, you can use a dot syntax to refer to higher
levels of the current package. For example, if you are in the
package lldbsuite.test.utility, then ..foo refers to
lldbsuite.test.foo. You can use this notation with the
`from X import Y` syntax to write intra-package references. For
example, using the previous locationa s a starting point, writing
`from ..support import seven` would import lldbsuite.support.seven
Since this is now the default behavior in Python 3, this means that
importing from the same directory with `import foo` *no longer works*.
As a result, the only way to have portable code is to force absolute
imports for all versions of Python.
See PEP 0328 [https://www.python.org/dev/peps/pep-0328/] for more
information about absolute and relative imports.
Differential Revision: http://reviews.llvm.org/D14342
Reviewed By: Todd Fiala
llvm-svn: 252191
2015-11-06 03:22:28 +08:00
|
|
|
from . import dotest_args
|
|
|
|
from . import lldbtest_config
|
|
|
|
from . import test_categories
|
2016-04-21 00:27:27 +08:00
|
|
|
from lldbsuite.test_event import formatter
|
2015-12-08 09:15:44 +08:00
|
|
|
from . import test_result
|
2016-04-21 00:27:27 +08:00
|
|
|
from lldbsuite.test_event.event_builder import EventBuilder
|
Python 3 - Turn on absolute imports, and fix existing imports.
Absolute imports were introduced in Python 2.5 as a feature
(e.g. from __future__ import absolute_import), and made default
in Python 3.
When absolute imports are enabled, the import system changes in
a couple of ways:
1) The `import foo` syntax will *only* search sys.path. If `foo`
isn't in sys.path, it won't be found. Period. Without absolute
imports, the import system will also search the same directory
that the importing file resides in, so that you can easily
import from the same folder.
2) From inside a package, you can use a dot syntax to refer to higher
levels of the current package. For example, if you are in the
package lldbsuite.test.utility, then ..foo refers to
lldbsuite.test.foo. You can use this notation with the
`from X import Y` syntax to write intra-package references. For
example, using the previous locationa s a starting point, writing
`from ..support import seven` would import lldbsuite.support.seven
Since this is now the default behavior in Python 3, this means that
importing from the same directory with `import foo` *no longer works*.
As a result, the only way to have portable code is to force absolute
imports for all versions of Python.
See PEP 0328 [https://www.python.org/dev/peps/pep-0328/] for more
information about absolute and relative imports.
Differential Revision: http://reviews.llvm.org/D14342
Reviewed By: Todd Fiala
llvm-svn: 252191
2015-11-06 03:22:28 +08:00
|
|
|
from ..support import seven
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
def is_exe(fpath):
|
2017-10-24 07:17:53 +08:00
|
|
|
"""Returns true if fpath is an executable.
|
|
|
|
Exits with an error code if the specified path is invalid"""
|
|
|
|
if not os.path.exists(fpath):
|
|
|
|
print(fpath + " is not a valid path, exiting")
|
|
|
|
sys.exit(-1)
|
2015-10-29 01:43:26 +08:00
|
|
|
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
def which(program):
|
|
|
|
"""Returns the full path to a program; None otherwise."""
|
|
|
|
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
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
class _WritelnDecorator(object):
|
|
|
|
"""Used to decorate file-like objects with a handy 'writeln' method"""
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
def __init__(self, stream):
|
2015-10-29 01:43:26 +08:00
|
|
|
self.stream = stream
|
|
|
|
|
|
|
|
def __getattr__(self, attr):
|
|
|
|
if attr in ('stream', '__getstate__'):
|
|
|
|
raise AttributeError(attr)
|
2016-09-07 04:57:50 +08:00
|
|
|
return getattr(self.stream, attr)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
def writeln(self, arg=None):
|
|
|
|
if arg:
|
|
|
|
self.write(arg)
|
2016-09-07 04:57:50 +08:00
|
|
|
self.write('\n') # text-mode streams translate to \r\n if needed
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Global variables:
|
|
|
|
#
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
def usage(parser):
|
|
|
|
parser.print_help()
|
2015-12-08 09:15:30 +08:00
|
|
|
if configuration.verbose > 0:
|
2015-10-29 01:43:26 +08:00
|
|
|
print("""
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
This is an example of using the -f option to pinpoint to a specific test class
|
|
|
|
and test method to be run:
|
|
|
|
|
|
|
|
$ ./dotest.py -f ClassTypesTestCase.test_with_dsym_and_run_command
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
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
|
|
|
|
|
|
|
|
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)
|
|
|
|
Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'. ... ok
|
|
|
|
test_break_with_dwarf (TestObjCMethods.FoundationTestCase)
|
|
|
|
Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'. ... ok
|
|
|
|
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
|
|
|
|
|
|
|
|
Running of this script also sets up the LLDB_TEST environment variable so that
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
|
|
ENABLING LOGS FROM TESTS
|
|
|
|
|
|
|
|
Option 1:
|
|
|
|
|
|
|
|
Writing logs into different files per test case::
|
|
|
|
|
|
|
|
This option is particularly useful when multiple dotest instances are created
|
|
|
|
by dosep.py
|
|
|
|
|
|
|
|
$ ./dotest.py --channel "lldb all"
|
|
|
|
|
|
|
|
$ ./dotest.py --channel "lldb all" --channel "gdb-remote packets"
|
|
|
|
|
|
|
|
These log files are written to:
|
|
|
|
|
|
|
|
<session-dir>/<test-id>-host.log (logs from lldb host process)
|
|
|
|
<session-dir>/<test-id>-server.log (logs from debugserver/lldb-server)
|
|
|
|
<session-dir>/<test-id>-<test-result>.log (console logs)
|
|
|
|
|
|
|
|
By default, logs from successful runs are deleted. Use the --log-success flag
|
|
|
|
to create reference logs for debugging.
|
|
|
|
|
|
|
|
$ ./dotest.py --log-success
|
|
|
|
|
|
|
|
Option 2: (DEPRECATED)
|
|
|
|
|
|
|
|
The following options can only enable logs from the host lldb process.
|
|
|
|
Only categories from the "lldb" or "gdb-remote" channels can be enabled
|
|
|
|
They also do not automatically enable logs in locally running debug servers.
|
|
|
|
Also, logs from all test case are written into each log file
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
""")
|
|
|
|
sys.exit(0)
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-09-24 05:32:47 +08:00
|
|
|
def parseExclusion(exclusion_file):
|
|
|
|
"""Parse an exclusion file, of the following format, where
|
|
|
|
'skip files', 'skip methods', 'xfail files', and 'xfail methods'
|
|
|
|
are the possible list heading values:
|
|
|
|
|
|
|
|
skip files
|
|
|
|
<file name>
|
|
|
|
<file name>
|
|
|
|
|
|
|
|
xfail methods
|
|
|
|
<method name>
|
|
|
|
"""
|
|
|
|
excl_type = None
|
|
|
|
|
|
|
|
with open(exclusion_file) as f:
|
|
|
|
for line in f:
|
2016-10-05 02:48:00 +08:00
|
|
|
line = line.strip()
|
2016-09-24 05:32:47 +08:00
|
|
|
if not excl_type:
|
2016-10-05 02:48:00 +08:00
|
|
|
excl_type = line
|
2016-09-24 05:32:47 +08:00
|
|
|
continue
|
|
|
|
|
|
|
|
if not line:
|
|
|
|
excl_type = None
|
2016-10-05 02:48:00 +08:00
|
|
|
elif excl_type == 'skip':
|
|
|
|
if not configuration.skip_tests:
|
|
|
|
configuration.skip_tests = []
|
|
|
|
configuration.skip_tests.append(line)
|
|
|
|
elif excl_type == 'xfail':
|
|
|
|
if not configuration.xfail_tests:
|
|
|
|
configuration.xfail_tests = []
|
|
|
|
configuration.xfail_tests.append(line)
|
2016-09-24 05:32:47 +08:00
|
|
|
|
|
|
|
|
2015-10-29 01:43:26 +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.
|
|
|
|
"""
|
|
|
|
|
|
|
|
do_help = False
|
|
|
|
|
|
|
|
platform_system = platform.system()
|
|
|
|
platform_machine = platform.machine()
|
|
|
|
|
|
|
|
parser = dotest_args.create_parser()
|
|
|
|
args = dotest_args.parse_args(parser, sys.argv[1:])
|
|
|
|
|
|
|
|
if args.unset_env_varnames:
|
|
|
|
for env_var in args.unset_env_varnames:
|
|
|
|
if env_var in os.environ:
|
|
|
|
# From Python Doc: When unsetenv() is supported, deletion of items in os.environ
|
2016-09-07 04:57:50 +08:00
|
|
|
# is automatically translated into a corresponding call to
|
|
|
|
# unsetenv().
|
2015-10-29 01:43:26 +08:00
|
|
|
del os.environ[env_var]
|
2016-09-07 04:57:50 +08:00
|
|
|
# os.unsetenv(env_var)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.set_env_vars:
|
|
|
|
for env_var in args.set_env_vars:
|
|
|
|
parts = env_var.split('=', 1)
|
|
|
|
if len(parts) == 1:
|
|
|
|
os.environ[parts[0]] = ""
|
|
|
|
else:
|
|
|
|
os.environ[parts[0]] = parts[1]
|
|
|
|
|
|
|
|
# only print the args if being verbose (and parsable is off)
|
|
|
|
if args.v and not args.q:
|
|
|
|
print(sys.argv)
|
|
|
|
|
|
|
|
if args.h:
|
|
|
|
do_help = True
|
|
|
|
|
2017-03-15 16:51:59 +08:00
|
|
|
if args.compiler:
|
2017-03-18 02:10:58 +08:00
|
|
|
configuration.compiler = os.path.realpath(args.compiler)
|
2017-03-18 05:00:35 +08:00
|
|
|
if not is_exe(configuration.compiler):
|
|
|
|
configuration.compiler = which(args.compiler)
|
2017-03-18 02:10:58 +08:00
|
|
|
if not is_exe(configuration.compiler):
|
|
|
|
logging.error(
|
|
|
|
'%s is not a valid compiler executable; aborting...',
|
|
|
|
args.compiler)
|
|
|
|
sys.exit(-1)
|
2015-10-29 01:43:26 +08:00
|
|
|
else:
|
2016-09-07 04:57:50 +08:00
|
|
|
# Use a compiler appropriate appropriate for the Apple SDK if one was
|
|
|
|
# specified
|
2015-10-29 01:43:26 +08:00
|
|
|
if platform_system == 'Darwin' and args.apple_sdk:
|
2017-03-15 16:51:59 +08:00
|
|
|
configuration.compiler = seven.get_command_output(
|
|
|
|
'xcrun -sdk "%s" -find clang 2> /dev/null' %
|
|
|
|
(args.apple_sdk))
|
2015-10-29 01:43:26 +08:00
|
|
|
else:
|
|
|
|
# 'clang' on ubuntu 14.04 is 3.4 so we try clang-3.5 first
|
|
|
|
candidateCompilers = ['clang-3.5', 'clang', 'gcc']
|
|
|
|
for candidate in candidateCompilers:
|
|
|
|
if which(candidate):
|
2017-03-15 16:51:59 +08:00
|
|
|
configuration.compiler = candidate
|
2015-10-29 01:43:26 +08:00
|
|
|
break
|
|
|
|
|
|
|
|
if args.channels:
|
|
|
|
lldbtest_config.channels = args.channels
|
|
|
|
|
|
|
|
if args.log_success:
|
|
|
|
lldbtest_config.log_success = args.log_success
|
|
|
|
|
|
|
|
# Set SDKROOT if we are using an Apple SDK
|
|
|
|
if platform_system == 'Darwin' and args.apple_sdk:
|
2016-09-07 04:57:50 +08:00
|
|
|
os.environ['SDKROOT'] = seven.get_command_output(
|
|
|
|
'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' %
|
|
|
|
(args.apple_sdk))
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2017-03-15 16:51:59 +08:00
|
|
|
if args.arch:
|
|
|
|
configuration.arch = args.arch
|
|
|
|
if configuration.arch.startswith(
|
|
|
|
'arm') and platform_system == 'Darwin' and not args.apple_sdk:
|
|
|
|
os.environ['SDKROOT'] = seven.get_command_output(
|
|
|
|
'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
|
|
|
|
if not os.path.exists(os.environ['SDKROOT']):
|
2016-09-07 04:57:50 +08:00
|
|
|
os.environ['SDKROOT'] = seven.get_command_output(
|
2017-03-15 16:51:59 +08:00
|
|
|
'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
|
2015-10-29 01:43:26 +08:00
|
|
|
else:
|
2017-03-15 16:51:59 +08:00
|
|
|
configuration.arch = platform_machine
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.categoriesList:
|
2016-09-07 04:57:50 +08:00
|
|
|
configuration.categoriesList = set(
|
|
|
|
test_categories.validate(
|
|
|
|
args.categoriesList, False))
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.useCategories = True
|
2015-10-29 01:43:26 +08:00
|
|
|
else:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.categoriesList = []
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.skipCategories:
|
2016-09-07 04:57:50 +08:00
|
|
|
configuration.skipCategories = test_categories.validate(
|
|
|
|
args.skipCategories, False)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.E:
|
|
|
|
cflags_extras = args.E
|
|
|
|
os.environ['CFLAGS_EXTRAS'] = cflags_extras
|
|
|
|
|
|
|
|
if args.d:
|
2016-09-07 04:57:50 +08:00
|
|
|
sys.stdout.write(
|
|
|
|
"Suspending the process %d to wait for debugger to attach...\n" %
|
|
|
|
os.getpid())
|
2015-10-29 01:43:26 +08:00
|
|
|
sys.stdout.flush()
|
|
|
|
os.kill(os.getpid(), signal.SIGSTOP)
|
|
|
|
|
|
|
|
if args.f:
|
|
|
|
if any([x.startswith('-') for x in args.f]):
|
|
|
|
usage(parser)
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.filters.extend(args.f)
|
2015-10-29 01:43:26 +08:00
|
|
|
# Shut off multiprocessing mode when additional filters are specified.
|
|
|
|
# The rational is that the user is probably going after a very specific
|
|
|
|
# test and doesn't need a bunch of parallel test runners all looking for
|
|
|
|
# it in a frenzy. Also, '-v' now spits out all test run output even
|
|
|
|
# on success, so the standard recipe for redoing a failing test (with -v
|
|
|
|
# and a -f to filter to the specific test) now causes all test scanning
|
|
|
|
# (in parallel) to print results for do-nothing runs in a very distracting
|
|
|
|
# manner. If we really need filtered parallel runs in the future, consider
|
|
|
|
# adding a --no-output-on-success that prevents -v from setting
|
|
|
|
# output-on-success.
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.no_multiprocess_test_runner = True
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.l:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.skip_long_running_test = False
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.framework:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.lldbFrameworkPath = args.framework
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.executable:
|
2017-03-18 02:10:58 +08:00
|
|
|
# lldb executable is passed explicitly
|
2016-04-26 04:36:22 +08:00
|
|
|
lldbtest_config.lldbExec = os.path.realpath(args.executable)
|
2017-03-18 05:00:35 +08:00
|
|
|
if not is_exe(lldbtest_config.lldbExec):
|
|
|
|
lldbtest_config.lldbExec = which(args.executable)
|
2017-03-18 02:10:58 +08:00
|
|
|
if not is_exe(lldbtest_config.lldbExec):
|
|
|
|
logging.error(
|
|
|
|
'%s is not a valid executable to test; aborting...',
|
|
|
|
args.executable)
|
|
|
|
sys.exit(-1)
|
|
|
|
|
2017-03-15 04:04:46 +08:00
|
|
|
if args.server:
|
|
|
|
os.environ['LLDB_DEBUGSERVER_PATH'] = args.server
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2016-09-24 05:32:47 +08:00
|
|
|
if args.excluded:
|
2016-10-05 02:48:00 +08:00
|
|
|
for excl_file in args.excluded:
|
|
|
|
parseExclusion(excl_file)
|
2016-09-24 05:32:47 +08:00
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
if args.p:
|
|
|
|
if args.p.startswith('-'):
|
|
|
|
usage(parser)
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.regexp = args.p
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.q:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.parsable = True
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.s:
|
|
|
|
if args.s.startswith('-'):
|
|
|
|
usage(parser)
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.sdir_name = args.s
|
2016-05-18 02:02:34 +08:00
|
|
|
configuration.session_file_format = args.session_file_format
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.t:
|
|
|
|
os.environ['LLDB_COMMAND_TRACE'] = 'YES'
|
|
|
|
|
|
|
|
if args.v:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.verbose = 2
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
# argparse makes sure we have a number
|
|
|
|
if args.sharp:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.count = args.sharp
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if sys.platform.startswith('win32'):
|
2016-09-07 04:57:50 +08:00
|
|
|
os.environ['LLDB_DISABLE_CRASH_DIALOG'] = str(
|
|
|
|
args.disable_crash_dialog)
|
2015-12-11 02:51:02 +08:00
|
|
|
os.environ['LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE'] = str(True)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if do_help:
|
2015-10-29 01:43:26 +08:00
|
|
|
usage(parser)
|
|
|
|
|
|
|
|
if args.no_multiprocess:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.no_multiprocess_test_runner = True
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.inferior:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.is_inferior_test_runner = True
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.num_threads:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.num_threads = args.num_threads
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.test_subdir:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.multiprocess_test_subdir = args.test_subdir
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.test_runner_name:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.test_runner_name = args.test_runner_name
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
# Capture test results-related args.
|
2015-11-10 02:51:04 +08:00
|
|
|
if args.curses and not args.inferior:
|
|
|
|
# Act as if the following args were set.
|
2016-04-21 00:27:27 +08:00
|
|
|
args.results_formatter = "lldbsuite.test_event.formatter.curses.Curses"
|
2015-11-10 02:51:04 +08:00
|
|
|
args.results_file = "stdout"
|
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
if args.results_file:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.results_filename = args.results_file
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.results_port:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.results_port = args.results_port
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.results_file and args.results_port:
|
|
|
|
sys.stderr.write(
|
|
|
|
"only one of --results-file and --results-port should "
|
|
|
|
"be specified\n")
|
|
|
|
usage(args)
|
|
|
|
|
|
|
|
if args.results_formatter:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.results_formatter_name = args.results_formatter
|
2015-10-29 01:43:26 +08:00
|
|
|
if args.results_formatter_options:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.results_formatter_options = args.results_formatter_options
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2015-12-12 06:29:34 +08:00
|
|
|
# Default to using the BasicResultsFormatter if no formatter is specified
|
|
|
|
# and we're not a test inferior.
|
|
|
|
if not args.inferior and configuration.results_formatter_name is None:
|
|
|
|
configuration.results_formatter_name = (
|
2016-04-21 00:27:27 +08:00
|
|
|
"lldbsuite.test_event.formatter.results_formatter.ResultsFormatter")
|
2015-12-12 06:29:34 +08:00
|
|
|
|
2015-12-13 03:26:56 +08:00
|
|
|
# rerun-related arguments
|
|
|
|
configuration.rerun_all_issues = args.rerun_all_issues
|
2015-12-15 05:28:46 +08:00
|
|
|
configuration.rerun_max_file_threshold = args.rerun_max_file_threshold
|
2015-12-13 03:26:56 +08:00
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
if args.lldb_platform_name:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.lldb_platform_name = args.lldb_platform_name
|
2015-10-29 01:43:26 +08:00
|
|
|
if args.lldb_platform_url:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.lldb_platform_url = args.lldb_platform_url
|
2015-10-29 01:43:26 +08:00
|
|
|
if args.lldb_platform_working_dir:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.lldb_platform_working_dir = args.lldb_platform_working_dir
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if args.event_add_entries and len(args.event_add_entries) > 0:
|
|
|
|
entries = {}
|
|
|
|
# Parse out key=val pairs, separated by comma
|
|
|
|
for keyval in args.event_add_entries.split(","):
|
|
|
|
key_val_entry = keyval.split("=")
|
|
|
|
if len(key_val_entry) == 2:
|
|
|
|
(key, val) = key_val_entry
|
|
|
|
val_parts = val.split(':')
|
|
|
|
if len(val_parts) > 1:
|
|
|
|
(val, val_type) = val_parts
|
|
|
|
if val_type == 'int':
|
|
|
|
val = int(val)
|
|
|
|
entries[key] = val
|
|
|
|
# Tell the event builder to create all events with these
|
|
|
|
# key/val pairs in them.
|
|
|
|
if len(entries) > 0:
|
2016-04-21 00:27:27 +08:00
|
|
|
EventBuilder.add_entries_to_all_events(entries)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
# Gather all the dirs passed on the command line.
|
|
|
|
if len(args.args) > 0:
|
2016-09-07 04:57:50 +08:00
|
|
|
configuration.testdirs = list(
|
|
|
|
map(lambda x: os.path.realpath(os.path.abspath(x)), args.args))
|
2015-10-29 01:43:26 +08:00
|
|
|
# Shut off multiprocessing mode when test directories are specified.
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.no_multiprocess_test_runner = True
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2016-10-22 06:13:55 +08:00
|
|
|
lldbtest_config.codesign_identity = args.codesign_identity
|
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
#print("testdirs:", testdirs)
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
def getXcodeOutputPaths(lldbRootDirectory):
|
|
|
|
result = []
|
|
|
|
|
|
|
|
# These are for xcode build directories.
|
|
|
|
xcode3_build_dir = ['build']
|
|
|
|
xcode4_build_dir = ['build', 'lldb', 'Build', 'Products']
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
configurations = [
|
|
|
|
['Debug'],
|
|
|
|
['DebugClang'],
|
|
|
|
['Release'],
|
|
|
|
['BuildAndIntegration']]
|
2015-10-29 01:43:26 +08:00
|
|
|
xcode_build_dirs = [xcode3_build_dir, xcode4_build_dir]
|
|
|
|
for configuration in configurations:
|
|
|
|
for xcode_build_dir in xcode_build_dirs:
|
2016-09-07 04:57:50 +08:00
|
|
|
outputPath = os.path.join(
|
|
|
|
lldbRootDirectory, *(xcode_build_dir + configuration))
|
2015-10-29 01:43:26 +08:00
|
|
|
result.append(outputPath)
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def createSocketToLocalPort(port):
|
|
|
|
def socket_closer(s):
|
|
|
|
"""Close down an opened socket properly."""
|
|
|
|
s.shutdown(socket.SHUT_RDWR)
|
|
|
|
s.close()
|
|
|
|
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
sock.connect(("localhost", port))
|
|
|
|
return (sock, lambda: socket_closer(sock))
|
|
|
|
|
|
|
|
|
|
|
|
def setupTestResults():
|
|
|
|
"""Sets up test results-related objects based on arg settings."""
|
2015-12-09 14:45:43 +08:00
|
|
|
# Setup the results formatter configuration.
|
2016-04-21 00:27:27 +08:00
|
|
|
formatter_config = formatter.FormatterConfig()
|
2015-12-09 14:45:43 +08:00
|
|
|
formatter_config.filename = configuration.results_filename
|
|
|
|
formatter_config.formatter_name = configuration.results_formatter_name
|
|
|
|
formatter_config.formatter_options = (
|
|
|
|
configuration.results_formatter_options)
|
|
|
|
formatter_config.port = configuration.results_port
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2015-12-08 08:53:56 +08:00
|
|
|
# Create the results formatter.
|
2016-04-21 00:27:27 +08:00
|
|
|
formatter_spec = formatter.create_results_formatter(
|
2015-12-09 14:45:43 +08:00
|
|
|
formatter_config)
|
2015-12-08 08:53:56 +08:00
|
|
|
if formatter_spec is not None and formatter_spec.formatter is not None:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.results_formatter_object = formatter_spec.formatter
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2016-04-21 00:27:27 +08:00
|
|
|
# Send an initialize message to the formatter.
|
2015-10-29 01:43:26 +08:00
|
|
|
initialize_event = EventBuilder.bare_event("initialize")
|
|
|
|
if isMultiprocessTestRunner():
|
2015-12-09 14:45:43 +08:00
|
|
|
if (configuration.test_runner_name is not None and
|
|
|
|
configuration.test_runner_name == "serial"):
|
2015-10-29 01:43:26 +08:00
|
|
|
# Only one worker queue here.
|
|
|
|
worker_count = 1
|
|
|
|
else:
|
|
|
|
# Workers will be the number of threads specified.
|
2015-12-08 09:15:30 +08:00
|
|
|
worker_count = configuration.num_threads
|
2015-10-29 01:43:26 +08:00
|
|
|
else:
|
|
|
|
worker_count = 1
|
|
|
|
initialize_event["worker_count"] = worker_count
|
|
|
|
|
2015-12-08 08:53:56 +08:00
|
|
|
formatter_spec.formatter.handle_event(initialize_event)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2015-12-08 08:53:56 +08:00
|
|
|
# Make sure we clean up the formatter on shutdown.
|
|
|
|
if formatter_spec.cleanup_func is not None:
|
|
|
|
atexit.register(formatter_spec.cleanup_func)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
def getOutputPaths(lldbRootDirectory):
|
|
|
|
"""
|
|
|
|
Returns typical build output paths for the lldb executable
|
|
|
|
|
|
|
|
lldbDirectory - path to the root of the lldb svn/git repo
|
|
|
|
"""
|
|
|
|
result = []
|
|
|
|
|
|
|
|
if sys.platform == 'darwin':
|
|
|
|
result.extend(getXcodeOutputPaths(lldbRootDirectory))
|
|
|
|
|
|
|
|
# cmake builds? look for build or build/host folder next to llvm directory
|
|
|
|
# lldb is located in llvm/tools/lldb so we need to go up three levels
|
2016-09-07 04:57:50 +08:00
|
|
|
llvmParentDir = os.path.abspath(
|
|
|
|
os.path.join(
|
|
|
|
lldbRootDirectory,
|
|
|
|
os.pardir,
|
|
|
|
os.pardir,
|
|
|
|
os.pardir))
|
2015-10-29 01:43:26 +08:00
|
|
|
result.append(os.path.join(llvmParentDir, 'build', 'bin'))
|
|
|
|
result.append(os.path.join(llvmParentDir, 'build', 'host', 'bin'))
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
# some cmake developers keep their build directory beside their lldb
|
|
|
|
# directory
|
2015-10-29 01:43:26 +08:00
|
|
|
lldbParentDir = os.path.abspath(os.path.join(lldbRootDirectory, os.pardir))
|
|
|
|
result.append(os.path.join(lldbParentDir, 'build', 'bin'))
|
|
|
|
result.append(os.path.join(lldbParentDir, 'build', 'host', 'bin'))
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
def setupSysPath():
|
|
|
|
"""
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Get the directory containing the current script.
|
|
|
|
if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
|
|
|
|
scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
|
|
|
|
else:
|
|
|
|
scriptPath = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
if not scriptPath.endswith('test'):
|
|
|
|
print("This script expects to reside in lldb's test directory.")
|
|
|
|
sys.exit(-1)
|
|
|
|
|
2015-12-12 03:21:34 +08:00
|
|
|
os.environ["LLDB_TEST"] = scriptPath
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
# Set up the LLDB_SRC environment variable, so that the tests can locate
|
|
|
|
# the LLDB source code.
|
|
|
|
os.environ["LLDB_SRC"] = lldbsuite.lldb_root
|
|
|
|
|
|
|
|
pluginPath = os.path.join(scriptPath, 'plugins')
|
|
|
|
toolsLLDBMIPath = os.path.join(scriptPath, 'tools', 'lldb-mi')
|
|
|
|
toolsLLDBServerPath = os.path.join(scriptPath, 'tools', 'lldb-server')
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
# Insert script dir, plugin dir, lldb-mi dir and lldb-server dir to the
|
|
|
|
# sys.path.
|
2015-10-29 01:43:26 +08:00
|
|
|
sys.path.insert(0, pluginPath)
|
2016-09-07 04:57:50 +08:00
|
|
|
# Adding test/tools/lldb-mi to the path makes it easy
|
|
|
|
sys.path.insert(0, toolsLLDBMIPath)
|
|
|
|
# to "import lldbmi_testcase" from the MI tests
|
|
|
|
# Adding test/tools/lldb-server to the path makes it easy
|
|
|
|
sys.path.insert(0, toolsLLDBServerPath)
|
|
|
|
# to "import lldbgdbserverutils" from the lldb-server tests
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
# This is the root of the lldb git/svn checkout
|
|
|
|
# When this changes over to a package instead of a standalone script, this
|
|
|
|
# will be `lldbsuite.lldb_root`
|
|
|
|
lldbRootDirectory = lldbsuite.lldb_root
|
|
|
|
|
|
|
|
# Some of the tests can invoke the 'lldb' command directly.
|
|
|
|
# We'll try to locate the appropriate executable right here.
|
|
|
|
|
|
|
|
# The lldb executable can be set from the command line
|
|
|
|
# if it's not set, we try to find it now
|
|
|
|
# first, we try the environment
|
|
|
|
if not lldbtest_config.lldbExec:
|
|
|
|
# First, you can define an environment variable LLDB_EXEC specifying the
|
|
|
|
# full pathname of the lldb executable.
|
|
|
|
if "LLDB_EXEC" in os.environ:
|
|
|
|
lldbtest_config.lldbExec = os.environ["LLDB_EXEC"]
|
|
|
|
|
|
|
|
if not lldbtest_config.lldbExec:
|
|
|
|
outputPaths = getOutputPaths(lldbRootDirectory)
|
|
|
|
for outputPath in outputPaths:
|
|
|
|
candidatePath = os.path.join(outputPath, 'lldb')
|
|
|
|
if is_exe(candidatePath):
|
|
|
|
lldbtest_config.lldbExec = candidatePath
|
|
|
|
break
|
|
|
|
|
|
|
|
if not lldbtest_config.lldbExec:
|
|
|
|
# Last, check the path
|
|
|
|
lldbtest_config.lldbExec = which('lldb')
|
|
|
|
|
|
|
|
if lldbtest_config.lldbExec and not is_exe(lldbtest_config.lldbExec):
|
2016-09-07 04:57:50 +08:00
|
|
|
print(
|
|
|
|
"'{}' is not a path to a valid executable".format(
|
|
|
|
lldbtest_config.lldbExec))
|
2015-10-29 01:43:26 +08:00
|
|
|
lldbtest_config.lldbExec = None
|
|
|
|
|
|
|
|
if not lldbtest_config.lldbExec:
|
|
|
|
print("The 'lldb' executable cannot be located. Some of the tests may not be run as a result.")
|
|
|
|
sys.exit(-1)
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
# confusingly, this is the "bin" directory
|
|
|
|
lldbLibDir = os.path.dirname(lldbtest_config.lldbExec)
|
2015-10-29 01:43:26 +08:00
|
|
|
os.environ["LLDB_LIB_DIR"] = lldbLibDir
|
2016-09-07 04:57:50 +08:00
|
|
|
lldbImpLibDir = os.path.join(
|
|
|
|
lldbLibDir,
|
|
|
|
'..',
|
|
|
|
'lib') if sys.platform.startswith('win32') else lldbLibDir
|
2015-10-29 01:43:26 +08:00
|
|
|
os.environ["LLDB_IMPLIB_DIR"] = lldbImpLibDir
|
2015-12-10 04:48:42 +08:00
|
|
|
print("LLDB library dir:", os.environ["LLDB_LIB_DIR"])
|
|
|
|
print("LLDB import library dir:", os.environ["LLDB_IMPLIB_DIR"])
|
|
|
|
os.system('%s -v' % lldbtest_config.lldbExec)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
# Assume lldb-mi is in same place as lldb
|
|
|
|
# If not found, disable the lldb-mi tests
|
2016-10-13 04:15:46 +08:00
|
|
|
# TODO: Append .exe on Windows
|
|
|
|
# - this will be in a separate commit in case the mi tests fail horribly
|
|
|
|
lldbDir = os.path.dirname(lldbtest_config.lldbExec)
|
|
|
|
lldbMiExec = os.path.join(lldbDir, "lldb-mi")
|
|
|
|
if is_exe(lldbMiExec):
|
|
|
|
os.environ["LLDBMI_EXEC"] = lldbMiExec
|
|
|
|
else:
|
2015-12-08 09:15:44 +08:00
|
|
|
if not configuration.shouldSkipBecauseOfCategories(["lldb-mi"]):
|
2016-09-07 04:57:50 +08:00
|
|
|
print(
|
|
|
|
"The 'lldb-mi' executable cannot be located. The lldb-mi tests can not be run as a result.")
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.skipCategories.append("lldb-mi")
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldbPythonDir = None # The directory that contains 'lldb/__init__.py'
|
2016-11-01 06:06:52 +08:00
|
|
|
if not configuration.lldbFrameworkPath and os.path.exists(os.path.join(lldbLibDir, "LLDB.framework")):
|
|
|
|
configuration.lldbFrameworkPath = os.path.join(lldbLibDir, "LLDB.framework")
|
2015-12-08 09:15:30 +08:00
|
|
|
if configuration.lldbFrameworkPath:
|
2016-10-31 12:48:10 +08:00
|
|
|
lldbtest_config.lldbFrameworkPath = configuration.lldbFrameworkPath
|
2016-09-07 04:57:50 +08:00
|
|
|
candidatePath = os.path.join(
|
|
|
|
configuration.lldbFrameworkPath, 'Resources', 'Python')
|
2015-10-29 01:43:26 +08:00
|
|
|
if os.path.isfile(os.path.join(candidatePath, 'lldb/__init__.py')):
|
|
|
|
lldbPythonDir = candidatePath
|
|
|
|
if not lldbPythonDir:
|
2016-09-07 04:57:50 +08:00
|
|
|
print(
|
|
|
|
'Resources/Python/lldb/__init__.py was not found in ' +
|
|
|
|
configuration.lldbFrameworkPath)
|
2015-10-29 01:43:26 +08:00
|
|
|
sys.exit(-1)
|
|
|
|
else:
|
|
|
|
# If our lldb supports the -P option, use it to find the python path:
|
|
|
|
init_in_python_dir = os.path.join('lldb', '__init__.py')
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb_dash_p_result = subprocess.check_output(
|
|
|
|
[lldbtest_config.lldbExec, "-P"], stderr=subprocess.STDOUT, universal_newlines=True)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if lldb_dash_p_result and not lldb_dash_p_result.startswith(
|
|
|
|
("<", "lldb: invalid option:")) and not lldb_dash_p_result.startswith("Traceback"):
|
2015-10-29 01:43:26 +08:00
|
|
|
lines = lldb_dash_p_result.splitlines()
|
|
|
|
|
|
|
|
# Workaround for readline vs libedit issue on FreeBSD. If stdout
|
|
|
|
# is not a terminal Python executes
|
|
|
|
# rl_variable_bind ("enable-meta-key", "off");
|
|
|
|
# This produces a warning with FreeBSD's libedit because the
|
|
|
|
# enable-meta-key variable is unknown. Not an issue on Apple
|
|
|
|
# because cpython commit f0ab6f9f0603 added a #ifndef __APPLE__
|
|
|
|
# around the call. See http://bugs.python.org/issue19884 for more
|
|
|
|
# information. For now we just discard the warning output.
|
2016-09-07 04:57:50 +08:00
|
|
|
if len(lines) >= 1 and lines[0].startswith(
|
|
|
|
"bind: Invalid command"):
|
2015-10-29 01:43:26 +08:00
|
|
|
lines.pop(0)
|
|
|
|
|
|
|
|
# Taking the last line because lldb outputs
|
|
|
|
# 'Cannot read termcap database;\nusing dumb terminal settings.\n'
|
|
|
|
# before the path
|
2016-09-07 04:57:50 +08:00
|
|
|
if len(lines) >= 1 and os.path.isfile(
|
|
|
|
os.path.join(lines[-1], init_in_python_dir)):
|
2015-10-29 01:43:26 +08:00
|
|
|
lldbPythonDir = lines[-1]
|
|
|
|
if "freebsd" in sys.platform or "linux" in sys.platform:
|
2016-09-07 04:57:50 +08:00
|
|
|
os.environ['LLDB_LIB_DIR'] = os.path.join(
|
|
|
|
lldbPythonDir, '..', '..')
|
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
if not lldbPythonDir:
|
|
|
|
if platform.system() == "Darwin":
|
|
|
|
python_resource_dir = ['LLDB.framework', 'Resources', 'Python']
|
2016-05-16 11:13:05 +08:00
|
|
|
outputPaths = getXcodeOutputPaths(lldbRootDirectory)
|
2015-10-29 01:43:26 +08:00
|
|
|
for outputPath in outputPaths:
|
2016-09-07 04:57:50 +08:00
|
|
|
candidatePath = os.path.join(
|
|
|
|
outputPath, *python_resource_dir)
|
|
|
|
if os.path.isfile(
|
|
|
|
os.path.join(
|
|
|
|
candidatePath,
|
|
|
|
init_in_python_dir)):
|
2015-10-29 01:43:26 +08:00
|
|
|
lldbPythonDir = candidatePath
|
|
|
|
break
|
|
|
|
|
|
|
|
if not lldbPythonDir:
|
2016-05-16 11:13:12 +08:00
|
|
|
print("lldb.py is not found, some tests may fail.")
|
2015-10-29 01:43:26 +08:00
|
|
|
else:
|
2016-09-07 04:57:50 +08:00
|
|
|
print(
|
|
|
|
"Unable to load lldb extension module. Possible reasons for this include:")
|
2015-10-29 01:43:26 +08:00
|
|
|
print(" 1) LLDB was built with LLDB_DISABLE_PYTHON=1")
|
2016-09-07 04:57:50 +08:00
|
|
|
print(
|
|
|
|
" 2) PYTHONPATH and PYTHONHOME are not set correctly. PYTHONHOME should refer to")
|
|
|
|
print(
|
|
|
|
" the version of Python that LLDB built and linked against, and PYTHONPATH")
|
|
|
|
print(
|
|
|
|
" should contain the Lib directory for the same python distro, as well as the")
|
2015-10-29 01:43:26 +08:00
|
|
|
print(" location of LLDB\'s site-packages folder.")
|
2016-09-07 04:57:50 +08:00
|
|
|
print(
|
|
|
|
" 3) A different version of Python than that which was built against is exported in")
|
2015-10-29 01:43:26 +08:00
|
|
|
print(" the system\'s PATH environment variable, causing conflicts.")
|
2016-09-07 04:57:50 +08:00
|
|
|
print(
|
|
|
|
" 4) The executable '%s' could not be found. Please check " %
|
|
|
|
lldbtest_config.lldbExec)
|
2015-10-29 01:43:26 +08:00
|
|
|
print(" that it exists and is executable.")
|
|
|
|
|
|
|
|
if lldbPythonDir:
|
|
|
|
lldbPythonDir = os.path.normpath(lldbPythonDir)
|
2016-09-07 04:57:50 +08:00
|
|
|
# Some of the code that uses this path assumes it hasn't resolved the Versions... link.
|
|
|
|
# If the path we've constructed looks like that, then we'll strip out
|
|
|
|
# the Versions/A part.
|
|
|
|
(before, frameWithVersion, after) = lldbPythonDir.rpartition(
|
|
|
|
"LLDB.framework/Versions/A")
|
|
|
|
if frameWithVersion != "":
|
2015-10-29 01:43:26 +08:00
|
|
|
lldbPythonDir = before + "LLDB.framework" + after
|
|
|
|
|
|
|
|
lldbPythonDir = os.path.abspath(lldbPythonDir)
|
|
|
|
|
|
|
|
# If tests need to find LLDB_FRAMEWORK, now they can do it
|
2016-09-07 04:57:50 +08:00
|
|
|
os.environ["LLDB_FRAMEWORK"] = os.path.dirname(
|
|
|
|
os.path.dirname(lldbPythonDir))
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
# This is to locate the lldb.py module. Insert it right after
|
|
|
|
# sys.path[0].
|
2015-10-29 01:43:26 +08:00
|
|
|
sys.path[1:1] = [lldbPythonDir]
|
|
|
|
|
test infra: catch bad decorators and import-time errors
Summary:
This change enhances the LLDB test infrastructure to convert
load-time exceptions in a given Python test module into errors.
Before this change, specifying a non-existent test decorator,
or otherwise having some load-time error in a python test module,
would not get flagged as an error.
With this change, typos and other load-time errors in a python
test file get converted to errors and reported by the
test runner.
This change also includes test infrastructure tests that include
covering the new work here. I'm going to wait until we have
these infrastructure tests runnable on the main platforms before
I try to work that into all the normal testing workflows.
The test infrastructure tests can be run by using the standard python module testing practice of doing the following:
cd packages/Python/lldbsuite/test_event
python -m unittest discover -s test/src -p 'Test*.py'
Those tests run the dotest inferior with a known broken test and verify that the errors are caught. These tests did not pass until I modified dotest.py to capture them properly.
@zturner, if you have the chance, if you could try those steps above (the python -m unittest ... line) on Windows, that would be great if we can address any python2/3/Windows bits there. I don't think there's anything fancy, but I didn't want to hook it into test flow until I know it works there.
I'll be slowly adding more tests that cover some of the other breakage I've occasionally seen that didn't get collected as part of the summarization. This is the biggest one I'm aware of.
Reviewers: zturner, labath
Subscribers: zturner, lldb-commits
Differential Revision: http://reviews.llvm.org/D20193
llvm-svn: 269489
2016-05-14 05:36:26 +08:00
|
|
|
|
|
|
|
def visit_file(dir, name):
|
|
|
|
# Try to match the regexp pattern, if specified.
|
|
|
|
if configuration.regexp:
|
|
|
|
if not re.search(configuration.regexp, name):
|
|
|
|
# We didn't match the regex, we're done.
|
|
|
|
return
|
|
|
|
|
2016-10-05 02:48:00 +08:00
|
|
|
if configuration.skip_tests:
|
|
|
|
for file_regexp in configuration.skip_tests:
|
2016-09-24 05:32:47 +08:00
|
|
|
if re.search(file_regexp, name):
|
|
|
|
return
|
|
|
|
|
test infra: catch bad decorators and import-time errors
Summary:
This change enhances the LLDB test infrastructure to convert
load-time exceptions in a given Python test module into errors.
Before this change, specifying a non-existent test decorator,
or otherwise having some load-time error in a python test module,
would not get flagged as an error.
With this change, typos and other load-time errors in a python
test file get converted to errors and reported by the
test runner.
This change also includes test infrastructure tests that include
covering the new work here. I'm going to wait until we have
these infrastructure tests runnable on the main platforms before
I try to work that into all the normal testing workflows.
The test infrastructure tests can be run by using the standard python module testing practice of doing the following:
cd packages/Python/lldbsuite/test_event
python -m unittest discover -s test/src -p 'Test*.py'
Those tests run the dotest inferior with a known broken test and verify that the errors are caught. These tests did not pass until I modified dotest.py to capture them properly.
@zturner, if you have the chance, if you could try those steps above (the python -m unittest ... line) on Windows, that would be great if we can address any python2/3/Windows bits there. I don't think there's anything fancy, but I didn't want to hook it into test flow until I know it works there.
I'll be slowly adding more tests that cover some of the other breakage I've occasionally seen that didn't get collected as part of the summarization. This is the biggest one I'm aware of.
Reviewers: zturner, labath
Subscribers: zturner, lldb-commits
Differential Revision: http://reviews.llvm.org/D20193
llvm-svn: 269489
2016-05-14 05:36:26 +08:00
|
|
|
# We found a match for our test. Add it to the suite.
|
|
|
|
|
|
|
|
# Update the sys.path first.
|
|
|
|
if not sys.path.count(dir):
|
|
|
|
sys.path.insert(0, dir)
|
|
|
|
base = os.path.splitext(name)[0]
|
|
|
|
|
|
|
|
# Thoroughly check the filterspec against the base module and admit
|
|
|
|
# the (base, filterspec) combination only when it makes sense.
|
|
|
|
filterspec = None
|
|
|
|
for filterspec in configuration.filters:
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# If filtered, we have a good filterspec. Add it.
|
|
|
|
if filtered:
|
|
|
|
# print("adding filter spec %s to module %s" % (filterspec, module))
|
|
|
|
configuration.suite.addTests(
|
2016-09-07 04:57:50 +08:00
|
|
|
unittest2.defaultTestLoader.loadTestsFromName(
|
|
|
|
filterspec, module))
|
test infra: catch bad decorators and import-time errors
Summary:
This change enhances the LLDB test infrastructure to convert
load-time exceptions in a given Python test module into errors.
Before this change, specifying a non-existent test decorator,
or otherwise having some load-time error in a python test module,
would not get flagged as an error.
With this change, typos and other load-time errors in a python
test file get converted to errors and reported by the
test runner.
This change also includes test infrastructure tests that include
covering the new work here. I'm going to wait until we have
these infrastructure tests runnable on the main platforms before
I try to work that into all the normal testing workflows.
The test infrastructure tests can be run by using the standard python module testing practice of doing the following:
cd packages/Python/lldbsuite/test_event
python -m unittest discover -s test/src -p 'Test*.py'
Those tests run the dotest inferior with a known broken test and verify that the errors are caught. These tests did not pass until I modified dotest.py to capture them properly.
@zturner, if you have the chance, if you could try those steps above (the python -m unittest ... line) on Windows, that would be great if we can address any python2/3/Windows bits there. I don't think there's anything fancy, but I didn't want to hook it into test flow until I know it works there.
I'll be slowly adding more tests that cover some of the other breakage I've occasionally seen that didn't get collected as part of the summarization. This is the biggest one I'm aware of.
Reviewers: zturner, labath
Subscribers: zturner, lldb-commits
Differential Revision: http://reviews.llvm.org/D20193
llvm-svn: 269489
2016-05-14 05:36:26 +08:00
|
|
|
continue
|
|
|
|
|
|
|
|
# Forgo this module if the (base, filterspec) combo is invalid
|
|
|
|
if configuration.filters and not filtered:
|
|
|
|
return
|
|
|
|
|
|
|
|
if not filterspec or not filtered:
|
|
|
|
# Add the entire file's worth of tests since we're not filtered.
|
|
|
|
# Also the fail-over case when the filterspec branch
|
|
|
|
# (base, filterspec) combo doesn't make sense.
|
2016-09-07 04:57:50 +08:00
|
|
|
configuration.suite.addTests(
|
|
|
|
unittest2.defaultTestLoader.loadTestsFromName(base))
|
test infra: catch bad decorators and import-time errors
Summary:
This change enhances the LLDB test infrastructure to convert
load-time exceptions in a given Python test module into errors.
Before this change, specifying a non-existent test decorator,
or otherwise having some load-time error in a python test module,
would not get flagged as an error.
With this change, typos and other load-time errors in a python
test file get converted to errors and reported by the
test runner.
This change also includes test infrastructure tests that include
covering the new work here. I'm going to wait until we have
these infrastructure tests runnable on the main platforms before
I try to work that into all the normal testing workflows.
The test infrastructure tests can be run by using the standard python module testing practice of doing the following:
cd packages/Python/lldbsuite/test_event
python -m unittest discover -s test/src -p 'Test*.py'
Those tests run the dotest inferior with a known broken test and verify that the errors are caught. These tests did not pass until I modified dotest.py to capture them properly.
@zturner, if you have the chance, if you could try those steps above (the python -m unittest ... line) on Windows, that would be great if we can address any python2/3/Windows bits there. I don't think there's anything fancy, but I didn't want to hook it into test flow until I know it works there.
I'll be slowly adding more tests that cover some of the other breakage I've occasionally seen that didn't get collected as part of the summarization. This is the biggest one I'm aware of.
Reviewers: zturner, labath
Subscribers: zturner, lldb-commits
Differential Revision: http://reviews.llvm.org/D20193
llvm-svn: 269489
2016-05-14 05:36:26 +08:00
|
|
|
|
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
def visit(prefix, dir, names):
|
|
|
|
"""Visitor function for os.path.walk(path, visit, arg)."""
|
|
|
|
|
2015-12-09 04:36:22 +08:00
|
|
|
dir_components = set(dir.split(os.sep))
|
|
|
|
excluded_components = set(['.svn', '.git'])
|
|
|
|
if dir_components.intersection(excluded_components):
|
2015-10-29 01:43:26 +08:00
|
|
|
return
|
|
|
|
|
test infra: catch bad decorators and import-time errors
Summary:
This change enhances the LLDB test infrastructure to convert
load-time exceptions in a given Python test module into errors.
Before this change, specifying a non-existent test decorator,
or otherwise having some load-time error in a python test module,
would not get flagged as an error.
With this change, typos and other load-time errors in a python
test file get converted to errors and reported by the
test runner.
This change also includes test infrastructure tests that include
covering the new work here. I'm going to wait until we have
these infrastructure tests runnable on the main platforms before
I try to work that into all the normal testing workflows.
The test infrastructure tests can be run by using the standard python module testing practice of doing the following:
cd packages/Python/lldbsuite/test_event
python -m unittest discover -s test/src -p 'Test*.py'
Those tests run the dotest inferior with a known broken test and verify that the errors are caught. These tests did not pass until I modified dotest.py to capture them properly.
@zturner, if you have the chance, if you could try those steps above (the python -m unittest ... line) on Windows, that would be great if we can address any python2/3/Windows bits there. I don't think there's anything fancy, but I didn't want to hook it into test flow until I know it works there.
I'll be slowly adding more tests that cover some of the other breakage I've occasionally seen that didn't get collected as part of the summarization. This is the biggest one I'm aware of.
Reviewers: zturner, labath
Subscribers: zturner, lldb-commits
Differential Revision: http://reviews.llvm.org/D20193
llvm-svn: 269489
2016-05-14 05:36:26 +08:00
|
|
|
# Gather all the Python test file names that follow the Test*.py pattern.
|
|
|
|
python_test_files = [
|
|
|
|
name
|
|
|
|
for name in names
|
|
|
|
if name.endswith('.py') and name.startswith(prefix)]
|
|
|
|
|
|
|
|
# Visit all the python test files.
|
|
|
|
for name in python_test_files:
|
|
|
|
try:
|
|
|
|
# Ensure we error out if we have multiple tests with the same
|
|
|
|
# base name.
|
|
|
|
# Future improvement: find all the places where we work with base
|
|
|
|
# names and convert to full paths. We have directory structure
|
|
|
|
# to disambiguate these, so we shouldn't need this constraint.
|
2015-12-08 09:15:30 +08:00
|
|
|
if name in configuration.all_tests:
|
2015-10-29 01:43:26 +08:00
|
|
|
raise Exception("Found multiple tests with the name %s" % name)
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.all_tests.add(name)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
test infra: catch bad decorators and import-time errors
Summary:
This change enhances the LLDB test infrastructure to convert
load-time exceptions in a given Python test module into errors.
Before this change, specifying a non-existent test decorator,
or otherwise having some load-time error in a python test module,
would not get flagged as an error.
With this change, typos and other load-time errors in a python
test file get converted to errors and reported by the
test runner.
This change also includes test infrastructure tests that include
covering the new work here. I'm going to wait until we have
these infrastructure tests runnable on the main platforms before
I try to work that into all the normal testing workflows.
The test infrastructure tests can be run by using the standard python module testing practice of doing the following:
cd packages/Python/lldbsuite/test_event
python -m unittest discover -s test/src -p 'Test*.py'
Those tests run the dotest inferior with a known broken test and verify that the errors are caught. These tests did not pass until I modified dotest.py to capture them properly.
@zturner, if you have the chance, if you could try those steps above (the python -m unittest ... line) on Windows, that would be great if we can address any python2/3/Windows bits there. I don't think there's anything fancy, but I didn't want to hook it into test flow until I know it works there.
I'll be slowly adding more tests that cover some of the other breakage I've occasionally seen that didn't get collected as part of the summarization. This is the biggest one I'm aware of.
Reviewers: zturner, labath
Subscribers: zturner, lldb-commits
Differential Revision: http://reviews.llvm.org/D20193
llvm-svn: 269489
2016-05-14 05:36:26 +08:00
|
|
|
# Run the relevant tests in the python file.
|
|
|
|
visit_file(dir, name)
|
|
|
|
except Exception as ex:
|
|
|
|
# Convert this exception to a test event error for the file.
|
|
|
|
test_filename = os.path.abspath(os.path.join(dir, name))
|
|
|
|
if configuration.results_formatter_object is not None:
|
|
|
|
# Grab the backtrace for the exception.
|
|
|
|
import traceback
|
|
|
|
backtrace = traceback.format_exc()
|
|
|
|
|
|
|
|
# Generate the test event.
|
|
|
|
configuration.results_formatter_object.handle_event(
|
|
|
|
EventBuilder.event_for_job_test_add_error(
|
|
|
|
test_filename, ex, backtrace))
|
|
|
|
raise
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
def disabledynamics():
|
|
|
|
import lldb
|
|
|
|
ci = lldb.DBG.GetCommandInterpreter()
|
|
|
|
res = lldb.SBCommandReturnObject()
|
2016-09-07 04:57:50 +08:00
|
|
|
ci.HandleCommand(
|
|
|
|
"setting set target.prefer-dynamic-value no-dynamic-values",
|
|
|
|
res,
|
|
|
|
False)
|
2015-10-29 01:43:26 +08:00
|
|
|
if not res.Succeeded():
|
|
|
|
raise Exception('disabling dynamic type support failed')
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
def lldbLoggings():
|
|
|
|
import lldb
|
|
|
|
"""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):
|
|
|
|
open(os.environ["LLDB_LOG"], 'w').close()
|
|
|
|
if ("LLDB_LOG_OPTION" in os.environ):
|
|
|
|
lldb_log_option = os.environ["LLDB_LOG_OPTION"]
|
|
|
|
else:
|
|
|
|
lldb_log_option = "event process expr state api"
|
|
|
|
ci.HandleCommand(
|
2016-09-07 04:57:50 +08:00
|
|
|
"log enable -n -f " +
|
|
|
|
os.environ["LLDB_LOG"] +
|
|
|
|
" lldb " +
|
|
|
|
lldb_log_option,
|
2015-10-29 01:43:26 +08:00
|
|
|
res)
|
|
|
|
if not res.Succeeded():
|
|
|
|
raise Exception('log enable failed (check LLDB_LOG env variable)')
|
|
|
|
|
|
|
|
if ("LLDB_LINUX_LOG" in os.environ):
|
|
|
|
open(os.environ["LLDB_LINUX_LOG"], 'w').close()
|
|
|
|
if ("LLDB_LINUX_LOG_OPTION" in os.environ):
|
|
|
|
lldb_log_option = os.environ["LLDB_LINUX_LOG_OPTION"]
|
|
|
|
else:
|
|
|
|
lldb_log_option = "event process expr state api"
|
|
|
|
ci.HandleCommand(
|
2016-09-07 04:57:50 +08:00
|
|
|
"log enable -n -f " +
|
|
|
|
os.environ["LLDB_LINUX_LOG"] +
|
|
|
|
" linux " +
|
|
|
|
lldb_log_option,
|
2015-10-29 01:43:26 +08:00
|
|
|
res)
|
|
|
|
if not res.Succeeded():
|
2016-09-07 04:57:50 +08:00
|
|
|
raise Exception(
|
|
|
|
'log enable failed (check LLDB_LINUX_LOG env variable)')
|
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
# 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:
|
|
|
|
gdb_remote_log_option = "packets process"
|
|
|
|
ci.HandleCommand(
|
|
|
|
"log enable -n -f " + os.environ["GDB_REMOTE_LOG"] + " gdb-remote "
|
|
|
|
+ gdb_remote_log_option,
|
|
|
|
res)
|
|
|
|
if not res.Succeeded():
|
2016-09-07 04:57:50 +08:00
|
|
|
raise Exception(
|
|
|
|
'log enable failed (check GDB_REMOTE_LOG env variable)')
|
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
def getMyCommandLine():
|
|
|
|
return ' '.join(sys.argv)
|
|
|
|
|
|
|
|
# ======================================== #
|
|
|
|
# #
|
|
|
|
# Execution of the test driver starts here #
|
|
|
|
# #
|
|
|
|
# ======================================== #
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
def checkDsymForUUIDIsNotOn():
|
|
|
|
cmd = ["defaults", "read", "com.apple.DebugSymbols"]
|
2016-09-07 04:57:50 +08:00
|
|
|
pipe = subprocess.Popen(
|
|
|
|
cmd,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT)
|
2015-10-29 01:43:26 +08:00
|
|
|
cmd_output = pipe.stdout.read()
|
|
|
|
if cmd_output and "DBGFileMappedPaths = " in cmd_output:
|
|
|
|
print("%s =>" % ' '.join(cmd))
|
|
|
|
print(cmd_output)
|
2016-09-07 04:57:50 +08:00
|
|
|
print(
|
|
|
|
"Disable automatic lookup and caching of dSYMs before running the test suite!")
|
2015-10-29 01:43:26 +08:00
|
|
|
print("Exiting...")
|
|
|
|
sys.exit(0)
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
def exitTestSuite(exitCode=None):
|
2015-10-29 01:43:26 +08:00
|
|
|
import lldb
|
|
|
|
lldb.SBDebugger.Terminate()
|
|
|
|
if exitCode:
|
|
|
|
sys.exit(exitCode)
|
|
|
|
|
|
|
|
|
|
|
|
def isMultiprocessTestRunner():
|
|
|
|
# We're not multiprocess when we're either explicitly
|
|
|
|
# the inferior (as specified by the multiprocess test
|
|
|
|
# runner) OR we've been told to skip using the multiprocess
|
|
|
|
# test runner
|
2016-09-07 04:57:50 +08:00
|
|
|
return not (
|
|
|
|
configuration.is_inferior_test_runner or configuration.no_multiprocess_test_runner)
|
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2015-11-05 08:46:25 +08:00
|
|
|
def getVersionForSDK(sdk):
|
|
|
|
sdk = str.lower(sdk)
|
|
|
|
full_path = seven.get_command_output('xcrun -sdk %s --show-sdk-path' % sdk)
|
|
|
|
basename = os.path.basename(full_path)
|
|
|
|
basename = os.path.splitext(basename)[0]
|
|
|
|
basename = str.lower(basename)
|
|
|
|
ver = basename.replace(sdk, '')
|
|
|
|
return ver
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-11-05 08:46:25 +08:00
|
|
|
def getPathForSDK(sdk):
|
|
|
|
sdk = str.lower(sdk)
|
|
|
|
full_path = seven.get_command_output('xcrun -sdk %s --show-sdk-path' % sdk)
|
2016-09-07 04:57:50 +08:00
|
|
|
if os.path.exists(full_path):
|
|
|
|
return full_path
|
2015-11-05 08:46:25 +08:00
|
|
|
return None
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-11-05 08:46:25 +08:00
|
|
|
def setDefaultTripleForPlatform():
|
2015-12-08 09:15:30 +08:00
|
|
|
if configuration.lldb_platform_name == 'ios-simulator':
|
2016-09-07 04:57:50 +08:00
|
|
|
triple_str = 'x86_64-apple-ios%s' % (
|
|
|
|
getVersionForSDK('iphonesimulator'))
|
2015-11-05 08:46:25 +08:00
|
|
|
os.environ['TRIPLE'] = triple_str
|
2016-09-07 04:57:50 +08:00
|
|
|
return {'TRIPLE': triple_str}
|
2015-11-05 08:46:25 +08:00
|
|
|
return {}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-03-15 16:51:59 +08:00
|
|
|
def checkCompiler():
|
|
|
|
# Add some intervention here to sanity check that the compiler requested is sane.
|
|
|
|
# If found not to be an executable program, we abort.
|
|
|
|
c = configuration.compiler
|
|
|
|
if which(c):
|
|
|
|
return
|
|
|
|
|
|
|
|
if not sys.platform.startswith("darwin"):
|
|
|
|
raise Exception(c + " is not a valid compiler")
|
|
|
|
|
|
|
|
pipe = subprocess.Popen(
|
|
|
|
['xcrun', '-find', c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
|
|
cmd_output = pipe.stdout.read()
|
|
|
|
if not cmd_output or "not found" in cmd_output:
|
|
|
|
raise Exception(c + " is not a valid compiler")
|
|
|
|
|
|
|
|
configuration.compiler = cmd_output.split('\n')[0]
|
|
|
|
print("'xcrun -find %s' returning %s" % (c, configuration.compiler))
|
|
|
|
|
Centralize libc++ test skipping logic
Summary:
This aims to replace the different decorators we've had on each libc++
test with a single solution. Each libc++ will be assigned to the
"libc++" category and a single central piece of code will decide whether
we are actually able to run libc++ test in the given configuration by
enabling or disabling the category (while giving the user the
opportunity to override this).
I started this effort because I wanted to get libc++ tests running on
android, and none of the existing decorators worked for this use case:
- skipIfGcc - incorrect, we can build libc++ executables on android
with gcc (in fact, after this, we can now do it on linux as well)
- lldbutil.skip_if_library_missing - this checks whether libc++.so is
loaded in the proces, which fails in case of a statically linked
libc++ (this makes copying executables to the remote target easier to
manage).
To make this work I needed to split out the pseudo_barrier code from the
force-included file, as libc++'s atomic does not play well with gcc on
linux, and this made every test fail, even though we need the code only
in the threading tests.
So far, I am only annotating one of the tests with this category. If
this does not break anything, I'll proceed to update the rest.
Reviewers: jingham, zturner, EricWF
Subscribers: srhines, lldb-commits
Differential Revision: https://reviews.llvm.org/D30984
llvm-svn: 299028
2017-03-30 05:01:14 +08:00
|
|
|
def canRunLibcxxTests():
|
|
|
|
from lldbsuite.test import lldbplatformutil
|
|
|
|
|
|
|
|
platform = lldbplatformutil.getPlatform()
|
|
|
|
|
|
|
|
if lldbplatformutil.target_is_android() or lldbplatformutil.platformIsDarwin():
|
|
|
|
return True, "libc++ always present"
|
|
|
|
|
|
|
|
if platform == "linux":
|
|
|
|
if not os.path.isdir("/usr/include/c++/v1"):
|
|
|
|
return False, "Unable to find libc++ installation"
|
|
|
|
return True, "Headers found, let's hope they work"
|
|
|
|
|
|
|
|
return False, "Don't know how to build with libc++ on %s" % platform
|
|
|
|
|
|
|
|
def checkLibcxxSupport():
|
|
|
|
result, reason = canRunLibcxxTests()
|
|
|
|
if result:
|
|
|
|
return # libc++ supported
|
|
|
|
if "libc++" in configuration.categoriesList:
|
|
|
|
return # libc++ category explicitly requested, let it run.
|
|
|
|
print("Libc++ tests will not be run because: " + reason)
|
|
|
|
configuration.skipCategories.append("libc++")
|
2017-03-15 16:51:59 +08:00
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
def run_suite():
|
|
|
|
# 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()
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
parseOptionsAndInitTestdirs()
|
|
|
|
|
|
|
|
# Setup test results (test results formatter and output handling).
|
|
|
|
setupTestResults()
|
|
|
|
|
|
|
|
# If we are running as the multiprocess test runner, kick off the
|
|
|
|
# multiprocess test runner here.
|
|
|
|
if isMultiprocessTestRunner():
|
Python 3 - Turn on absolute imports, and fix existing imports.
Absolute imports were introduced in Python 2.5 as a feature
(e.g. from __future__ import absolute_import), and made default
in Python 3.
When absolute imports are enabled, the import system changes in
a couple of ways:
1) The `import foo` syntax will *only* search sys.path. If `foo`
isn't in sys.path, it won't be found. Period. Without absolute
imports, the import system will also search the same directory
that the importing file resides in, so that you can easily
import from the same folder.
2) From inside a package, you can use a dot syntax to refer to higher
levels of the current package. For example, if you are in the
package lldbsuite.test.utility, then ..foo refers to
lldbsuite.test.foo. You can use this notation with the
`from X import Y` syntax to write intra-package references. For
example, using the previous locationa s a starting point, writing
`from ..support import seven` would import lldbsuite.support.seven
Since this is now the default behavior in Python 3, this means that
importing from the same directory with `import foo` *no longer works*.
As a result, the only way to have portable code is to force absolute
imports for all versions of Python.
See PEP 0328 [https://www.python.org/dev/peps/pep-0328/] for more
information about absolute and relative imports.
Differential Revision: http://reviews.llvm.org/D14342
Reviewed By: Todd Fiala
llvm-svn: 252191
2015-11-06 03:22:28 +08:00
|
|
|
from . import dosep
|
2016-09-07 04:57:50 +08:00
|
|
|
dosep.main(
|
|
|
|
configuration.num_threads,
|
|
|
|
configuration.multiprocess_test_subdir,
|
|
|
|
configuration.test_runner_name,
|
|
|
|
configuration.results_formatter_object)
|
2015-10-29 01:43:26 +08:00
|
|
|
raise Exception("should never get here")
|
2015-12-08 09:15:30 +08:00
|
|
|
elif configuration.is_inferior_test_runner:
|
2015-10-29 01:43:26 +08:00
|
|
|
# Shut off Ctrl-C processing in inferiors. The parallel
|
|
|
|
# test runner handles this more holistically.
|
|
|
|
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
|
|
|
|
|
|
|
setupSysPath()
|
2015-12-08 21:32:07 +08:00
|
|
|
configuration.setupCrashInfoHook()
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# If '-l' is specified, do not skip the long running tests.
|
2015-12-08 09:15:30 +08:00
|
|
|
if not configuration.skip_long_running_test:
|
2015-10-29 01:43:26 +08:00
|
|
|
os.environ["LLDB_SKIP_LONG_RUNNING_TEST"] = "NO"
|
|
|
|
|
|
|
|
# For the time being, let's bracket the test runner within the
|
|
|
|
# lldb.SBDebugger.Initialize()/Terminate() pair.
|
|
|
|
import lldb
|
|
|
|
|
|
|
|
# Create a singleton SBDebugger in the lldb namespace.
|
|
|
|
lldb.DBG = lldb.SBDebugger.Create()
|
|
|
|
|
2015-12-08 09:15:30 +08:00
|
|
|
if configuration.lldb_platform_name:
|
2016-09-07 04:57:50 +08:00
|
|
|
print("Setting up remote platform '%s'" %
|
|
|
|
(configuration.lldb_platform_name))
|
|
|
|
lldb.remote_platform = lldb.SBPlatform(
|
|
|
|
configuration.lldb_platform_name)
|
2015-10-29 01:43:26 +08:00
|
|
|
if not lldb.remote_platform.IsValid():
|
2016-09-07 04:57:50 +08:00
|
|
|
print(
|
|
|
|
"error: unable to create the LLDB platform named '%s'." %
|
|
|
|
(configuration.lldb_platform_name))
|
2015-10-29 01:43:26 +08:00
|
|
|
exitTestSuite(1)
|
2015-12-08 09:15:30 +08:00
|
|
|
if configuration.lldb_platform_url:
|
2016-09-07 04:57:50 +08:00
|
|
|
# We must connect to a remote platform if a LLDB platform URL was
|
|
|
|
# specified
|
|
|
|
print(
|
|
|
|
"Connecting to remote platform '%s' at '%s'..." %
|
|
|
|
(configuration.lldb_platform_name, configuration.lldb_platform_url))
|
|
|
|
platform_connect_options = lldb.SBPlatformConnectOptions(
|
|
|
|
configuration.lldb_platform_url)
|
2015-10-29 01:43:26 +08:00
|
|
|
err = lldb.remote_platform.ConnectRemote(platform_connect_options)
|
|
|
|
if err.Success():
|
|
|
|
print("Connected.")
|
|
|
|
else:
|
2016-09-07 04:57:50 +08:00
|
|
|
print("error: failed to connect to remote platform using URL '%s': %s" % (
|
|
|
|
configuration.lldb_platform_url, err))
|
2015-10-29 01:43:26 +08:00
|
|
|
exitTestSuite(1)
|
|
|
|
else:
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.lldb_platform_url = None
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2015-11-05 08:46:25 +08:00
|
|
|
platform_changes = setDefaultTripleForPlatform()
|
|
|
|
first = True
|
|
|
|
for key in platform_changes:
|
|
|
|
if first:
|
|
|
|
print("Environment variables setup for platform support:")
|
|
|
|
first = False
|
2016-09-07 04:57:50 +08:00
|
|
|
print("%s = %s" % (key, platform_changes[key]))
|
2015-11-05 08:46:25 +08:00
|
|
|
|
2015-12-08 09:15:30 +08:00
|
|
|
if configuration.lldb_platform_working_dir:
|
2016-09-07 04:57:50 +08:00
|
|
|
print("Setting remote platform working directory to '%s'..." %
|
|
|
|
(configuration.lldb_platform_working_dir))
|
2017-03-21 00:07:17 +08:00
|
|
|
error = lldb.remote_platform.MakeDirectory(
|
|
|
|
configuration.lldb_platform_working_dir, 448) # 448 = 0o700
|
|
|
|
if error.Fail():
|
|
|
|
raise Exception("making remote directory '%s': %s" % (
|
|
|
|
remote_test_dir, error))
|
|
|
|
|
|
|
|
if not lldb.remote_platform.SetWorkingDirectory(
|
|
|
|
configuration.lldb_platform_working_dir):
|
|
|
|
raise Exception("failed to set working directory '%s'" % remote_test_dir)
|
2015-10-29 01:43:26 +08:00
|
|
|
lldb.DBG.SetSelectedPlatform(lldb.remote_platform)
|
|
|
|
else:
|
|
|
|
lldb.remote_platform = None
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.lldb_platform_working_dir = None
|
|
|
|
configuration.lldb_platform_url = None
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
|
|
|
|
|
Centralize libc++ test skipping logic
Summary:
This aims to replace the different decorators we've had on each libc++
test with a single solution. Each libc++ will be assigned to the
"libc++" category and a single central piece of code will decide whether
we are actually able to run libc++ test in the given configuration by
enabling or disabling the category (while giving the user the
opportunity to override this).
I started this effort because I wanted to get libc++ tests running on
android, and none of the existing decorators worked for this use case:
- skipIfGcc - incorrect, we can build libc++ executables on android
with gcc (in fact, after this, we can now do it on linux as well)
- lldbutil.skip_if_library_missing - this checks whether libc++.so is
loaded in the proces, which fails in case of a statically linked
libc++ (this makes copying executables to the remote target easier to
manage).
To make this work I needed to split out the pseudo_barrier code from the
force-included file, as libc++'s atomic does not play well with gcc on
linux, and this made every test fail, even though we need the code only
in the threading tests.
So far, I am only annotating one of the tests with this category. If
this does not break anything, I'll proceed to update the rest.
Reviewers: jingham, zturner, EricWF
Subscribers: srhines, lldb-commits
Differential Revision: https://reviews.llvm.org/D30984
llvm-svn: 299028
2017-03-30 05:01:14 +08:00
|
|
|
checkLibcxxSupport()
|
|
|
|
|
2015-10-29 01:43:26 +08:00
|
|
|
# Don't do debugserver tests on everything except OS X.
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.dont_do_debugserver_test = "linux" in target_platform or "freebsd" in target_platform or "windows" in target_platform
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
# Don't do lldb-server (llgs) tests on anything except Linux.
|
2015-12-08 09:15:30 +08:00
|
|
|
configuration.dont_do_llgs_test = not ("linux" in target_platform)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Walk through the testdirs while collecting tests.
|
|
|
|
#
|
2015-12-08 09:15:30 +08:00
|
|
|
for testdir in configuration.testdirs:
|
2015-11-05 09:33:54 +08:00
|
|
|
for (dirpath, dirnames, filenames) in os.walk(testdir):
|
|
|
|
visit('Test', dirpath, filenames)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Now that we have loaded all the test cases, run the whole test suite.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Turn on lldb loggings if necessary.
|
|
|
|
lldbLoggings()
|
|
|
|
|
|
|
|
# Disable default dynamic types for testing purposes
|
|
|
|
disabledynamics()
|
|
|
|
|
|
|
|
# Install the control-c handler.
|
|
|
|
unittest2.signals.installHandler()
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# See also TestBase.dumpSessionInfo() in lldbtest.py.
|
|
|
|
import datetime
|
|
|
|
# The windows platforms don't like ':' in the pathname.
|
|
|
|
timestamp_started = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S")
|
2015-12-08 09:15:30 +08:00
|
|
|
if not configuration.sdir_name:
|
|
|
|
configuration.sdir_name = timestamp_started
|
2016-09-07 04:57:50 +08:00
|
|
|
os.environ["LLDB_SESSION_DIRNAME"] = os.path.join(
|
|
|
|
os.getcwd(), configuration.sdir_name)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
sys.stderr.write(
|
|
|
|
"\nSession logs for test failures/errors/unexpected successes"
|
|
|
|
" will go into directory '%s'\n" %
|
|
|
|
configuration.sdir_name)
|
2015-12-10 04:48:42 +08:00
|
|
|
sys.stderr.write("Command invoked: %s\n" % getMyCommandLine())
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2015-12-08 09:15:30 +08:00
|
|
|
if not os.path.isdir(configuration.sdir_name):
|
2015-10-29 01:43:26 +08:00
|
|
|
try:
|
2015-12-08 09:15:30 +08:00
|
|
|
os.mkdir(configuration.sdir_name)
|
2015-10-29 01:43:26 +08:00
|
|
|
except OSError as exception:
|
|
|
|
if exception.errno != errno.EEXIST:
|
|
|
|
raise
|
|
|
|
|
|
|
|
#
|
2017-03-15 16:51:59 +08:00
|
|
|
# Invoke the default TextTestRunner to run the test suite
|
2015-10-29 01:43:26 +08:00
|
|
|
#
|
2017-03-15 16:51:59 +08:00
|
|
|
checkCompiler()
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2017-03-15 16:51:59 +08:00
|
|
|
if not configuration.parsable:
|
|
|
|
print("compiler=%s" % configuration.compiler)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2017-03-15 16:51:59 +08:00
|
|
|
# Iterating over all possible architecture and compiler combinations.
|
|
|
|
os.environ["ARCH"] = configuration.arch
|
|
|
|
os.environ["CC"] = configuration.compiler
|
|
|
|
configString = "arch=%s compiler=%s" % (configuration.arch,
|
|
|
|
configuration.compiler)
|
|
|
|
|
|
|
|
# Translate ' ' to '-' for pathname component.
|
|
|
|
if six.PY2:
|
|
|
|
import string
|
|
|
|
tbl = string.maketrans(' ', '-')
|
|
|
|
else:
|
|
|
|
tbl = str.maketrans(' ', '-')
|
|
|
|
configPostfix = configString.translate(tbl)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2017-03-15 16:51:59 +08:00
|
|
|
# Output the configuration.
|
|
|
|
if not configuration.parsable:
|
|
|
|
sys.stderr.write("\nConfiguration: " + configString + "\n")
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2017-03-15 16:51:59 +08:00
|
|
|
# First, write out the number of collected test cases.
|
2015-12-08 09:15:30 +08:00
|
|
|
if not configuration.parsable:
|
2017-03-15 16:51:59 +08:00
|
|
|
sys.stderr.write(configuration.separator + "\n")
|
|
|
|
sys.stderr.write(
|
|
|
|
"Collected %d test%s\n\n" %
|
|
|
|
(configuration.suite.countTestCases(),
|
|
|
|
configuration.suite.countTestCases() != 1 and "s" or ""))
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2017-03-15 16:51:59 +08:00
|
|
|
if configuration.parsable:
|
|
|
|
v = 0
|
|
|
|
else:
|
|
|
|
v = configuration.verbose
|
|
|
|
|
|
|
|
# Invoke the test runner.
|
|
|
|
if configuration.count == 1:
|
|
|
|
result = unittest2.TextTestRunner(
|
|
|
|
stream=sys.stderr,
|
|
|
|
verbosity=v,
|
|
|
|
resultclass=test_result.LLDBTestResult).run(
|
|
|
|
configuration.suite)
|
|
|
|
else:
|
|
|
|
# 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.
|
|
|
|
test_result.LLDBTestResult.__ignore_singleton__ = True
|
|
|
|
for i in range(configuration.count):
|
|
|
|
|
|
|
|
result = unittest2.TextTestRunner(
|
|
|
|
stream=sys.stderr,
|
|
|
|
verbosity=v,
|
|
|
|
resultclass=test_result.LLDBTestResult).run(
|
|
|
|
configuration.suite)
|
|
|
|
|
|
|
|
configuration.failed = not result.wasSuccessful()
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2015-12-08 09:15:30 +08:00
|
|
|
if configuration.sdir_has_content and not configuration.parsable:
|
2016-09-07 04:57:50 +08:00
|
|
|
sys.stderr.write(
|
|
|
|
"Session logs for test failures/errors/unexpected successes"
|
|
|
|
" can be found in directory '%s'\n" %
|
|
|
|
configuration.sdir_name)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if configuration.useCategories and len(
|
|
|
|
configuration.failuresPerCategory) > 0:
|
2015-10-29 01:43:26 +08:00
|
|
|
sys.stderr.write("Failures per category:\n")
|
2015-12-08 09:15:30 +08:00
|
|
|
for category in configuration.failuresPerCategory:
|
2016-09-07 04:57:50 +08:00
|
|
|
sys.stderr.write(
|
|
|
|
"%s - %d\n" %
|
|
|
|
(category, configuration.failuresPerCategory[category]))
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
# Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined.
|
|
|
|
# This should not be necessary now.
|
|
|
|
if ("LLDB_TESTSUITE_FORCE_FINISH" in os.environ):
|
|
|
|
print("Terminating Test suite...")
|
|
|
|
subprocess.Popen(["/bin/sh", "-c", "kill %s; exit 0" % (os.getpid())])
|
|
|
|
|
|
|
|
# Exiting.
|
2015-12-08 09:15:30 +08:00
|
|
|
exitTestSuite(configuration.failed)
|
2015-10-29 01:43:26 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2016-09-07 04:57:50 +08:00
|
|
|
print(
|
|
|
|
__file__ +
|
|
|
|
" is for use as a module only. It should not be run as a standalone script.")
|
2015-11-03 03:19:49 +08:00
|
|
|
sys.exit(-1)
|