Index: test/lit.cfg
===================================================================
--- test/lit.cfg
+++ test/lit.cfg
@@ -252,7 +252,6 @@
self.configure_use_clang_verify()
self.configure_ccache()
self.configure_env()
- self.configure_std_flag()
self.configure_compile_flags()
self.configure_link_flags()
self.configure_sanitizer()
@@ -450,14 +449,26 @@
self.config.available_features.add('long_tests')
def configure_compile_flags(self):
- # Configure extra compiler flags.
+ # Try and get the std version from the command line. Fall back to
+ # default given in lit.site.cfg is not present. If default is not
+ # present then force c++11.
+ std = self.get_lit_conf('std', 'c++11')
+ self.compile_flags += ['-std={0}'.format(std)]
+ self.config.available_features.add(std)
+ # Configure include paths
self.compile_flags += ['-nostdinc++']
- self.compile_flags += ['-I' + self.src_root + '/include',
- '-I' + self.src_root + '/test/support']
+ self.compile_flags += ['-I' + self.src_root + '/test/support']
+ libcxx_headers = self.get_lit_conf('libcxx_headers',
+ self.src_root + '/include')
+ if not os.path.isdir(libcxx_headers):
+ self.lit_config.fatal("libcxx_headers='%s' is not a directory."
+ % libcxx_headers)
+ self.compile_flags += ['-I' + libcxx_headers]
if sys.platform.startswith('linux'):
self.compile_flags += ['-D__STDC_FORMAT_MACROS',
'-D__STDC_LIMIT_MACROS',
'-D__STDC_CONSTANT_MACROS']
+ # Configure feature flags.
enable_exceptions = self.get_lit_bool('enable_exceptions', True)
if enable_exceptions:
self.config.available_features.add('exceptions')
@@ -483,64 +494,70 @@
elif not enable_monotonic_clock:
self.lit_config.fatal('enable_monotonic_clock cannot be false when'
' enable_threads is true.')
+ # Use verbose output for better errors
+ self.compile_flags += ['-v']
+ # Configure extra compile flags.
+ compile_flags_str = self.get_lit_conf('compile_flags', '')
+ self.compile_flags += shlex.split(compile_flags_str)
def configure_link_flags(self):
self.link_flags += ['-nodefaultlibs']
- # Configure library search paths
+ libcxx_library = self.get_lit_conf('libcxx_library')
+ # Configure libc++ library paths.
+ if libcxx_library is not None:
+ # Check that the given value for libcxx_library is valid.
+ if not os.path.isfile(libcxx_library):
+ self.lit_config.fatal(
+ "libcxx_library='%s' is not a valid file." % libcxx_library)
+ if self.use_system_lib:
+ self.lit_config.fatal("Conflicting options: 'libcxx_library'"
+ " cannot be used with 'use_system_lib=true'")
+ self.link_flags += ['-Wl,-rpath,' + os.path.dirname(libcxx_library)]
+ elif not self.use_system_lib:
+ self.link_flags += ['-L' + self.library_root,
+ '-Wl,-rpath,' + self.library_root]
+ # Configure ABI library paths.
abi_library_path = self.get_lit_conf('abi_library_path', '')
- if not self.use_system_lib:
- self.link_flags += ['-L' + self.library_root]
- self.link_flags += ['-Wl,-rpath,' + self.library_root]
if abi_library_path:
self.link_flags += ['-L' + abi_library_path,
'-Wl,-rpath,' + abi_library_path]
# Configure libraries
- self.link_flags += ['-lc++']
- link_flags_str = self.get_lit_conf('link_flags')
- if link_flags_str is None:
- cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
- if cxx_abi == 'libstdc++':
- self.link_flags += ['-lstdc++']
- elif cxx_abi == 'libsupc++':
- self.link_flags += ['-lsupc++']
- elif cxx_abi == 'libcxxabi':
- self.link_flags += ['-lc++abi']
- elif cxx_abi == 'libcxxrt':
- self.link_flags += ['-lcxxrt']
- elif cxx_abi == 'none':
- pass
- else:
- self.lit_config.fatal(
- 'C++ ABI setting %s unsupported for tests' % cxx_abi)
-
- if sys.platform == 'darwin':
- self.link_flags += ['-lSystem']
- elif sys.platform.startswith('linux'):
- self.link_flags += ['-lgcc_eh', '-lc', '-lm', '-lpthread',
- '-lrt', '-lgcc_s']
- elif sys.platform.startswith('freebsd'):
- self.link_flags += ['-lc', '-lm', '-pthread', '-lgcc_s']
- else:
- self.lit_config.fatal("unrecognized system: %r" % sys.platform)
-
- if link_flags_str:
- self.link_flags += shlex.split(link_flags_str)
+ if libcxx_library:
+ self.link_flags += [libcxx_library]
+ else:
+ self.link_flags += ['-lc++']
+ cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
+ if cxx_abi == 'libstdc++':
+ self.link_flags += ['-lstdc++']
+ elif cxx_abi == 'libsupc++':
+ self.link_flags += ['-lsupc++']
+ elif cxx_abi == 'libcxxabi':
+ self.link_flags += ['-lc++abi']
+ elif cxx_abi == 'libcxxrt':
+ self.link_flags += ['-lcxxrt']
+ elif cxx_abi == 'none':
+ pass
+ else:
+ self.lit_config.fatal(
+ 'C++ ABI setting %s unsupported for tests' % cxx_abi)
+ # Configure extra libraries.
+ if sys.platform == 'darwin':
+ self.link_flags += ['-lSystem']
+ elif sys.platform.startswith('linux'):
+ self.link_flags += ['-lgcc_eh', '-lc', '-lm', '-lpthread',
+ '-lrt', '-lgcc_s']
+ elif sys.platform.startswith('freebsd'):
+ self.link_flags += ['-lc', '-lm', '-pthread', '-lgcc_s']
+ else:
+ self.lit_config.fatal("unrecognized system: %r" % sys.platform)
+ link_flags_str = self.get_lit_conf('link_flags', '')
+ self.link_flags += shlex.split(link_flags_str)
- def configure_std_flag(self):
- # Try and get the std version from the command line. Fall back to
- # default given in lit.site.cfg is not present. If default is not
- # present then force c++11.
- std = self.get_lit_conf('std')
- if std is None:
- std = 'c++11'
- self.lit_config.note('using default std: \'-std=c++11\'')
- self.compile_flags += ['-std={0}'.format(std)]
- self.config.available_features.add(std)
def configure_sanitizer(self):
- san = self.get_lit_conf('llvm_use_sanitizer', '').strip()
+ san = self.get_lit_conf('use_sanitizer', '').strip()
if san:
# Search for llvm-symbolizer along the compiler path first
# and then along the PATH env variable.
@@ -606,7 +623,12 @@
def configure_env(self):
if sys.platform == 'darwin' and not self.use_system_lib:
- self.env['DYLD_LIBRARY_PATH'] = self.library_root
+ libcxx_library = self.get_lit_conf('libcxx_library')
+ if libcxx_library:
+ library_root = os.path.dirname(libcxx_library)
+ else:
+ library_root = self.library_root
+ self.env['DYLD_LIBRARY_PATH'] = library_root
# name: The name of this test suite.
config.name = 'libc++'
Index: test/lit.site.cfg.in
===================================================================
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -11,7 +11,7 @@
config.enable_threads = "@LIBCXX_ENABLE_THREADS@"
config.enable_monotonic_clock = "@LIBCXX_ENABLE_MONOTONIC_CLOCK@"
config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
-config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
+config.use_sanitizer = "@LLVM_USE_SANITIZER@"
config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
# Let the main config do the real work.
Index: www/index.html
===================================================================
--- www/index.html
+++ www/index.html
@@ -470,6 +470,7 @@
<type_traits>
Excellent notes by Marshall Clow
Status of debug mode
+LIT usage guide
Index: www/lit_usage.html
===================================================================
--- /dev/null
+++ www/lit_usage.html
@@ -0,0 +1,168 @@
+
+
+
+
+
+ Testing libc++ using LIT
+
+
+
+
+
+
+
+
+
+
+
Testing libc++ using LIT
+
+
+libc++ uses LIT to configure and run its tests. The primary way to run the
+libc++ tests is by using make check-libcxx
. However since libc++
+can be used in any number of possible configurations it is important to
+customize the way LIT builds and runs the tests. This guide provides
+information on how to use LIT directly to test libc++.
+
+
+Documentation for LIT can be found
+here .
+
+
+
+
Getting Started
+
+
+After building libc++ use the following commands before you start using LIT to
+test.
+
+
+ alias lit='python path/to/llvm/utils/lit/lit.py'
+ export LIBCXX_SITE_CONFIG=path/to/build-libcxx/test/lit.site.cfg
+
+
+You can now run the libc++ tests by running:
+
+
+ cd path/to/libcxx
+ lit -sv ./test
+
+
+To only run a subsection of the tests use:
+
+ lit -sv test/std/numerics # Run only the numeric tests
+
+
+
+
Customization Options
+
+
+libc++'s testsuite provides multiple options to configure the way the tests
+are build and run. To use these options you pass them on the LIT command line
+as --param NAME
or --param NAME=VALUE
. Some options
+have default values specified during CMake's configuration. Passing the option
+on the command line will override the default.
+
+
+
+
+
libcxx_site_config=<path/to/lit.site.cfg>
+
+Specify the site configuration to use when running the tests. This option
+overrides the enviroment variable LIBCXX_SITE_CONFIG
+
+
+
+
+
libcxx_headers=<path/to/headers>
+
+Specify the libc++ headers that are tested. By default the headers in the source
+tree are used.
+
+
+
+
+
libcxx_library=<path/to/libc++.so>
+
+Specify the libc++ library that is tested. By default the library in the build
+directory is used. This option cannot be used when use_system_lib
+is provided.
+
+
+
+
+
use_system_lib=<bool>
+
+Default: False
+Enable or disable testing against the installed version of libc++ library.
+Note: This does not use the installed headers.
+
+
+
+
+
compile_flags="<list-of-args>"
+
+Specify additional compile flags as a space delimited string.
+Note: This options should not be used to change the standard version used.
+
+
+
+
+
link_flags="<list-of-args>"
+
+Specify additional link flags as a space delimited string.
+
+
+
+
+
std=<standard version>
+
+Values: c++98, c++03, c++11, c++14, c++1z
+Change the standard version used when building the tests.
+
+
+
+
+
use_sanitizer=<sanitizer name>
+
+Values: Memory, MemoryWithOrigins, Address, Undefined
+Run the tests using the given sanitizer. If LLVM_USE_SANITIZER
+was given when building libc++ then that sanitizer will be used by default.
+
+
+
+
+
+