1# -*- Python -*- 2 3# Configuration file for 'lit' test runner. 4# This file contains common rules for various compiler-rt testsuites. 5# It is mostly copied from lit.cfg used by Clang. 6import os 7import platform 8 9# Setup test format 10execute_external = (platform.system() != 'Windows' 11 or lit.getBashPath() not in [None, ""]) 12config.test_format = lit.formats.ShTest(execute_external) 13 14# Setup clang binary. 15clang_path = getattr(config, 'clang', None) 16if (not clang_path) or (not os.path.exists(clang_path)): 17 lit.fatal("Can't find Clang on path %r" % clang_path) 18 19# Clear some environment variables that might affect Clang. 20possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS', 21 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH', 22 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH', 23 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH', 24 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING', 25 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX', 26 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS', 27 'LIBCLANG_RESOURCE_USAGE', 28 'LIBCLANG_CODE_COMPLETION_LOGGING'] 29# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it. 30if platform.system() != 'Windows': 31 possibly_dangerous_env_vars.append('INCLUDE') 32for name in possibly_dangerous_env_vars: 33 if name in config.environment: 34 del config.environment[name] 35 36# Tweak PATH to include llvm tools dir. 37llvm_tools_dir = getattr(config, 'llvm_tools_dir', None) 38if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)): 39 lit.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir) 40path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH'])) 41config.environment['PATH'] = path 42 43# Define path to external llvm-symbolizer tool. 44config.llvm_symbolizer_path = os.path.join(llvm_tools_dir, "llvm-symbolizer") 45 46# Use ugly construction to explicitly prohibit "clang", "clang++" etc. 47# in RUN lines. 48config.substitutions.append( 49 (' clang', """\n\n*** Do not use 'clangXXX' in tests, 50 instead define '%clangXXX' substitution in lit config. ***\n\n""") ) 51 52# Add supported compiler_rt architectures to a list of available features. 53compiler_rt_arch = getattr(config, 'compiler_rt_arch', None) 54if compiler_rt_arch: 55 for arch in compiler_rt_arch.split(";"): 56 config.available_features.add(arch + "-supported-target") 57