2015-01-10 02:03:29 +08:00
|
|
|
# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
|
2010-09-15 11:57:04 +08:00
|
|
|
# Configuration file for the 'lit' test runner.
|
|
|
|
import os
|
2015-01-10 02:03:29 +08:00
|
|
|
import site
|
2014-08-22 01:30:44 +08:00
|
|
|
|
2017-02-10 07:18:11 +08:00
|
|
|
site.addsitedir(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'utils'))
|
2014-09-03 12:32:08 +08:00
|
|
|
|
2014-08-22 01:30:44 +08:00
|
|
|
|
2015-01-10 02:03:29 +08:00
|
|
|
# Tell pylint that we know config and lit_config exist somewhere.
|
|
|
|
if 'PYLINT_IMPORT' in os.environ:
|
|
|
|
config = object()
|
|
|
|
lit_config = object()
|
2014-08-22 01:30:44 +08:00
|
|
|
|
2010-09-15 11:57:04 +08:00
|
|
|
# name: The name of this test suite.
|
|
|
|
config.name = 'libc++'
|
|
|
|
|
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
2020-04-03 23:06:26 +08:00
|
|
|
config.suffixes = ['.pass.cpp', '.fail.cpp', '.sh.cpp', '.pass.mm']
|
2010-09-15 11:57:04 +08:00
|
|
|
|
|
|
|
# test_source_root: The root path where tests are located.
|
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
2020-04-04 00:49:09 +08:00
|
|
|
# Allow expanding substitutions that are based on other substitutions
|
|
|
|
config.recursiveExpansionLimit = 10
|
|
|
|
|
2016-10-12 08:00:37 +08:00
|
|
|
loaded_site_cfg = getattr(config, 'loaded_site_config', False)
|
|
|
|
if not loaded_site_cfg:
|
|
|
|
import libcxx.test.config
|
|
|
|
libcxx.test.config.loadSiteConfig(lit_config, config, 'libcxx_site_config',
|
|
|
|
'LIBCXX_SITE_CONFIG')
|
|
|
|
|
2014-12-20 11:16:55 +08:00
|
|
|
# Infer the test_exec_root from the libcxx_object root.
|
2015-01-23 02:05:58 +08:00
|
|
|
obj_root = getattr(config, 'libcxx_obj_root', None)
|
2014-12-20 11:16:55 +08:00
|
|
|
|
|
|
|
# Check that the test exec root is known.
|
2015-01-23 02:05:58 +08:00
|
|
|
if obj_root is None:
|
|
|
|
obj_root = getattr(config, 'libcxx_obj_root', None)
|
|
|
|
if obj_root is None:
|
|
|
|
import tempfile
|
|
|
|
obj_root = tempfile.mkdtemp(prefix='libcxx-testsuite-')
|
|
|
|
lit_config.warning('Creating temporary directory for object root: %s' %
|
|
|
|
obj_root)
|
|
|
|
|
2020-03-14 03:23:45 +08:00
|
|
|
if not config.test_exec_root:
|
|
|
|
config.test_exec_root = os.path.join(obj_root, 'test')
|
2014-12-20 11:16:55 +08:00
|
|
|
|
2015-01-10 02:03:29 +08:00
|
|
|
cfg_variant = getattr(config, 'configuration_variant', 'libcxx')
|
Add better support for custom test runners.
Summary:
I finally got around to merging the many, many changes to lit.cfg into
Android's libc++. This patch makes it simpler to actually use a custom
configuration and test format.
First, I've factored out _build, _run, and _clean methods from
_execute_test, since these are the likely parts that will need to be
overridden. This is likely a first step in the work jroelofs has been
doing with improving cross-compiling test execution.
Second, I've added a `configuration_variant` to the config. This
entry, if present, is a string that forms the prefix of the class that
is to be used to configure the test runner. For example, Android sets
`config.configuration_variant = 'Android'`, and this causes an object
of type `AndroidConfiguration` to be constructed.
As an example of how this will be used, see:
https://android-review.googlesource.com/#/c/116022/
Reviewers: jroelofs, mclow.lists, EricWF
Reviewed By: EricWF
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D6373
llvm-svn: 222698
2014-11-25 06:24:06 +08:00
|
|
|
if cfg_variant:
|
2015-01-17 05:59:07 +08:00
|
|
|
lit_config.note('Using configuration variant: %s' % cfg_variant)
|
Add better support for custom test runners.
Summary:
I finally got around to merging the many, many changes to lit.cfg into
Android's libc++. This patch makes it simpler to actually use a custom
configuration and test format.
First, I've factored out _build, _run, and _clean methods from
_execute_test, since these are the likely parts that will need to be
overridden. This is likely a first step in the work jroelofs has been
doing with improving cross-compiling test execution.
Second, I've added a `configuration_variant` to the config. This
entry, if present, is a string that forms the prefix of the class that
is to be used to configure the test runner. For example, Android sets
`config.configuration_variant = 'Android'`, and this causes an object
of type `AndroidConfiguration` to be constructed.
As an example of how this will be used, see:
https://android-review.googlesource.com/#/c/116022/
Reviewers: jroelofs, mclow.lists, EricWF
Reviewed By: EricWF
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D6373
llvm-svn: 222698
2014-11-25 06:24:06 +08:00
|
|
|
|
2015-01-10 02:03:29 +08:00
|
|
|
# Load the Configuration class from the module name <cfg_variant>.test.config.
|
|
|
|
config_module_name = '.'.join([cfg_variant, 'test', 'config'])
|
|
|
|
config_module = __import__(config_module_name, fromlist=['Configuration'])
|
|
|
|
|
|
|
|
configuration = config_module.Configuration(lit_config, config)
|
2014-08-22 01:30:44 +08:00
|
|
|
configuration.configure()
|
2015-01-21 00:26:48 +08:00
|
|
|
configuration.print_config_info()
|
2020-04-07 06:30:19 +08:00
|
|
|
if lit_config.params.get('use_old_format', False):
|
|
|
|
lit_config.note("Using the old libc++ testing format")
|
|
|
|
config.test_format = configuration.get_test_format()
|
|
|
|
else:
|
|
|
|
lit_config.note("Using the new libc++ testing format")
|
[libc++] Add an alternative Lit test format
This new test format is simpler and more flexible. It creates Lit ShTests
on the fly that reuse existing substitutions (like %{cxx}) instead of
having complex logic in Python to run the tests. This has the benefit
that virtually no coding is required to customize how the test suite is
run -- one can achieve pretty much anything by defining the appropriate
substitutions in a simple lit.cfg file.
For example, in order to run the tests on an embedded device after
building with a specific SDK, one can set the %{cxx} and %{compile_flags}
substitutions to use that SDK, and the %{exec} substitution to the ssh.py
script currently used for .sh.cpp tests with a remote executor. Dealing with
the SSHExecutor becomes unnecessary, since all tests are treated like ShTests.
As a side effect of this design, configuration files for the test
suite can be as simple as:
config.substitutions.append(('%{cxx}', '<path-to-compiler>'))
config.substitutions.append(('%{compile_flags}', '<flags>'))
config.substitutions.append(('%{link_flags}', '<flags>'))
config.substitutions.append(('%{exec}', '<script-to-execute>'))
This should allow storing lit.cfg files for various configurations
directly in the repository instead of relying on complicated logic
in config.py to set up the right flags. I've found numerous problems
in that logic in the past years, and it seems like having simple and
explicit configuration files for the configurations we support is
going to solve most of these problems. Specifically, I am hoping to
store configuration files for testing other Standard Libraries in
the repository.
Improving the interaction with the test suite configuration is still a
work in progress, so for now this test format reuses the substitutions and
available features that are set up by the current config.py.
This new test format should support pretty much everything that the current
test format supports, however it will not be enabled by default at first to
make sure we're satisfied with it. For a short period of time, the new format
will require `--param=use_new_format=True` to be enabled, however it is a very
short term goal to replace the current testing format entirely and to simplify
the configuration accordingly.
Differential Revision: https://reviews.llvm.org/D77338
2020-03-31 04:25:24 +08:00
|
|
|
import libcxx.test.newformat
|
|
|
|
config.test_format = libcxx.test.newformat.CxxStandardLibraryTest()
|