blob: 4be6921549bfec7f3ffae8358699276afc0d74e4 [file] [log] [blame]
# -*- Python -*-
# Configuration file for 'lit' test runner.
# This file contains common rules for various compiler-rt testsuites.
# It is mostly copied from lit.cfg used by Clang.
import os
import platform
import lit.formats
# Setup test format
execute_external = (platform.system() != 'Windows'
or lit_config.getBashPath() not in [None, ""])
config.test_format = lit.formats.ShTest(execute_external)
# Setup clang binary.
clang_path = getattr(config, 'clang', None)
if (not clang_path) or (not os.path.exists(clang_path)):
lit_config.fatal("Can't find Clang on path %r" % clang_path)
# Clear some environment variables that might affect Clang.
possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
'LIBCLANG_RESOURCE_USAGE',
'LIBCLANG_CODE_COMPLETION_LOGGING']
# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
if platform.system() != 'Windows':
possibly_dangerous_env_vars.append('INCLUDE')
for name in possibly_dangerous_env_vars:
if name in config.environment:
del config.environment[name]
# Tweak PATH to include llvm tools dir.
llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)):
lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir)
path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
config.environment['PATH'] = path
# Define path to external llvm-symbolizer tool.
config.llvm_symbolizer_path = os.path.join(llvm_tools_dir, "llvm-symbolizer")
# Use ugly construction to explicitly prohibit "clang", "clang++" etc.
# in RUN lines.
config.substitutions.append(
(' clang', """\n\n*** Do not use 'clangXXX' in tests,
instead define '%clangXXX' substitution in lit config. ***\n\n""") )
# Add supported compiler_rt architectures to a list of available features.
compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
if compiler_rt_arch:
for arch in compiler_rt_arch.split(";"):
config.available_features.add(arch + "-supported-target")