[tests] Update to use lit_config and lit package, as appropriate.

llvm-svn: 188073
This commit is contained in:
Daniel Dunbar 2013-08-09 14:44:11 +00:00
parent 94ec6cc110
commit 4a38129468
2 changed files with 23 additions and 18 deletions

View File

@ -12,6 +12,10 @@ import errno
import time
import shlex
import lit.Test
import lit.formats
import lit.util
# FIXME: For now, this is cribbed from lit.TestRunner, to avoid introducing a
# dependency there. What we more ideally would like to do is lift the "xfail"
# and "requires" handling to be a core lit framework feature.
@ -207,7 +211,7 @@ config.suffixes = ['.cpp']
config.test_source_root = os.path.dirname(__file__)
# Gather various compiler parameters.
cxx_under_test = lit.params.get('cxx_under_test', None)
cxx_under_test = lit_config.params.get('cxx_under_test', None)
if cxx_under_test is None:
cxx_under_test = getattr(config, 'cxx_under_test', None)
@ -215,52 +219,53 @@ if cxx_under_test is None:
clangxx = lit.util.which('clang++', config.environment['PATH'])
if clangxx is not None:
cxx_under_test = clangxx
lit.note("inferred cxx_under_test as: %r" % (cxx_under_test,))
lit_config.note("inferred cxx_under_test as: %r" % (cxx_under_test,))
if cxx_under_test is None:
lit.fatal('must specify user parameter cxx_under_test '
'(e.g., --param=cxx_under_test=clang++)')
lit_config.fatal('must specify user parameter cxx_under_test '
'(e.g., --param=cxx_under_test=clang++)')
libcxx_src_root = lit.params.get('libcxx_src_root', None)
libcxx_src_root = lit_config.params.get('libcxx_src_root', None)
if libcxx_src_root is None:
libcxx_src_root = getattr(config, 'libcxx_src_root', None)
if libcxx_src_root is None:
libcxx_src_root = os.path.dirname(config.test_source_root)
libcxx_obj_root = lit.params.get('libcxx_obj_root', None)
libcxx_obj_root = lit_config.params.get('libcxx_obj_root', None)
if libcxx_obj_root is None:
libcxx_obj_root = getattr(config, 'libcxx_obj_root', None)
if libcxx_obj_root is None:
libcxx_obj_root = libcxx_src_root
cxx_has_stdcxx0x_flag_str = lit.params.get('cxx_has_stdcxx0x_flag', None)
cxx_has_stdcxx0x_flag_str = lit_config.params.get('cxx_has_stdcxx0x_flag', None)
if cxx_has_stdcxx0x_flag_str is not None:
if cxx_has_stdcxx0x_flag_str.lower() in ('1', 'true'):
cxx_has_stdcxx0x_flag = True
elif cxx_has_stdcxx0x_flag_str.lower() in ('', '0', 'false'):
cxx_has_stdcxx0x_flag = False
else:
lit.fatal('user parameter cxx_has_stdcxx0x_flag_str should be 0 or 1')
lit_config.fatal(
'user parameter cxx_has_stdcxx0x_flag_str should be 0 or 1')
else:
cxx_has_stdcxx0x_flag = getattr(config, 'cxx_has_stdcxx0x_flag', True)
# This test suite supports testing against either the system library or the
# locally built one; the former mode is useful for testing ABI compatibility
# between the current headers and a shipping dynamic library.
use_system_lib_str = lit.params.get('use_system_lib', None)
use_system_lib_str = lit_config.params.get('use_system_lib', None)
if use_system_lib_str is not None:
if use_system_lib_str.lower() in ('1', 'true'):
use_system_lib = True
elif use_system_lib_str.lower() in ('', '0', 'false'):
use_system_lib = False
else:
lit.fatal('user parameter use_system_lib should be 0 or 1')
lit_config.fatal('user parameter use_system_lib should be 0 or 1')
else:
# Default to testing against the locally built libc++ library.
use_system_lib = False
lit.note("inferred use_system_lib as: %r" % (use_system_lib,))
lit_config.note("inferred use_system_lib as: %r" % (use_system_lib,))
link_flags = []
link_flags_str = lit.params.get('link_flags', None)
link_flags_str = lit_config.params.get('link_flags', None)
if link_flags_str is None:
link_flags_str = getattr(config, 'link_flags', None)
if link_flags_str is None:
@ -270,8 +275,8 @@ if link_flags_str is None:
link_flags += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread',
'-lrt', '-lgcc_s']
else:
lit.fatal("unrecognized system")
lit.note("inferred link_flags as: %r" % (link_flags,))
lit_config.fatal("unrecognized system")
lit_config.note("inferred link_flags as: %r" % (link_flags,))
if not link_flags_str is None:
link_flags += shlex.split(link_flags_str)
@ -294,7 +299,7 @@ elif sys.platform == 'linux2':
compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS',
'-D__STDC_CONSTANT_MACROS']
else:
lit.fatal("unrecognized system")
lit_config.fatal("unrecognized system")
config.test_format = LibcxxTestFormat(
cxx_under_test,
@ -303,12 +308,12 @@ config.test_format = LibcxxTestFormat(
exec_env = exec_env)
# Get or infer the target triple.
config.target_triple = lit.params.get('target_triple', None)
config.target_triple = lit_config.params.get('target_triple', None)
# If no target triple was given, try to infer it from the compiler under test.
if config.target_triple is None:
config.target_triple = lit.util.capture(
[cxx_under_test, '-dumpmachine']).strip()
lit.note("inferred target_triple as: %r" % (config.target_triple,))
lit_config.note("inferred target_triple as: %r" % (config.target_triple,))
# Write an "available feature" that combines the triple when use_system_lib is
# enabled. This is so that we can easily write XFAIL markers for tests that are

View File

@ -7,4 +7,4 @@ config.python_executable = "@PYTHON_EXECUTABLE@"
config.enable_shared = @LIBCXX_ENABLE_SHARED@
# Let the main config do the real work.
lit.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")