Run the tests using the given sanitizer. If LLVM_USE_SANITIZER was given when
building libc++ then that sanitizer will be used by default.
-.. option:: color_diagnostics
-
- Enable the use of colorized compile diagnostics. If the color_diagnostics
- option is specified or the environment variable LIBCXX_COLOR_DIAGNOSTICS is
- present then color diagnostics will be enabled.
-
.. option:: llvm_unwinder
Enable the use of LLVM unwinder instead of libgcc.
Specify the site configuration to use when running the tests.
Also see `libcxx_site_config`.
-.. envvar:: LIBCXX_COLOR_DIAGNOSTICS
-
- If ``LIBCXX_COLOR_DIAGNOSTICS`` is defined then the test suite will attempt
- to use color diagnostic outputs from the compiler.
- Also see `color_diagnostics`.
-
Writing Tests
-------------
self.configure_obj_root()
self.configure_cxx_stdlib_under_test()
self.configure_cxx_library_root()
- self.configure_ccache()
self.configure_compile_flags()
self.configure_link_flags()
self.configure_env()
- self.configure_color_diagnostics()
self.configure_debug_mode()
self.configure_warnings()
self.configure_sanitizer()
self.cxx = CXXCompiler(self, cxx) if not self.cxx_is_clang_cl else \
self._configure_clang_cl(cxx)
self.cxx.compile_env = dict(os.environ)
- # 'CCACHE_CPP2' prevents ccache from stripping comments while
- # preprocessing. This is required to prevent stripping of '-verify'
- # comments.
- self.cxx.compile_env['CCACHE_CPP2'] = '1'
def _configure_clang_cl(self, clang_path):
def _split_env_var(var):
compile_flags=compile_flags,
link_flags=link_flags)
- def _dump_macros_verbose(self, *args, **kwargs):
- macros_or_error = self.cxx.dumpMacros(*args, **kwargs)
- if isinstance(macros_or_error, tuple):
- cmd, out, err, rc = macros_or_error
- report = libcxx.util.makeReport(cmd, out, err, rc)
- report += "Compiler failed unexpectedly when dumping macros!"
- self.lit_config.fatal(report)
- return None
- assert isinstance(macros_or_error, dict)
- return macros_or_error
-
def configure_src_root(self):
self.libcxx_src_root = self.get_lit_conf(
'libcxx_src_root', os.path.dirname(self.config.test_source_root))
if self.get_lit_conf('enable_experimental') is None:
self.config.enable_experimental = 'true'
- def configure_ccache(self):
- use_ccache_default = os.environ.get('LIBCXX_USE_CCACHE') is not None
- use_ccache = self.get_lit_bool('use_ccache', use_ccache_default)
- if use_ccache:
- self.cxx.use_ccache = True
- self.lit_config.note('enabling ccache')
-
def configure_features(self):
additional_features = self.get_lit_conf('additional_features')
if additional_features:
self.cxx.link_flags += ['-lc++external_threads']
self.target_info.add_cxx_link_flags(self.cxx.link_flags)
- def configure_color_diagnostics(self):
- use_color = self.get_lit_conf('color_diagnostics')
- if use_color is None:
- use_color = os.environ.get('LIBCXX_COLOR_DIAGNOSTICS')
- if use_color is None:
- return
- if use_color != '':
- self.lit_config.fatal('Invalid value for color_diagnostics "%s".'
- % use_color)
- color_flag = '-fdiagnostics-color=always'
- # Check if the compiler supports the color diagnostics flag. Issue a
- # warning if it does not since color diagnostics have been requested.
- if not self.cxx.hasCompileFlag(color_flag):
- self.lit_config.warning(
- 'color diagnostics have been requested but are not supported '
- 'by the compiler')
- else:
- self.cxx.flags += [color_flag]
-
def configure_debug_mode(self):
debug_level = self.get_lit_conf('debug_level', None)
if not debug_level: