blob: b410259a9e716aaf97622cbee751a7dab169c184 [file] [log] [blame]
Alexey Samsonov7274ff82012-07-31 15:43:11 +00001# -*- 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)
18if not lit.quiet:
19 lit.note("using clang: %r" % clang_path)
20
21# Clear some environment variables that might affect Clang.
22possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
23 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
24 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
25 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
26 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
27 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
28 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
29 'LIBCLANG_RESOURCE_USAGE',
30 'LIBCLANG_CODE_COMPLETION_LOGGING']
31# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
32if platform.system() != 'Windows':
33 possibly_dangerous_env_vars.append('INCLUDE')
34for name in possibly_dangerous_env_vars:
35 if name in config.environment:
36 del config.environment[name]
37
Alexey Samsonov6ffcb582012-08-07 11:00:19 +000038# Tweak PATH to include llvm tools dir.
39llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
40if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)):
41 lit.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir)
42path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
43config.environment['PATH'] = path
44
Alexey Samsonov589231c2012-08-15 08:54:14 +000045# Define %clang and %clangxx substitutions to use in test RUN lines.
Alexey Samsonov7274ff82012-07-31 15:43:11 +000046config.substitutions.append( ("%clang ", (" " + config.clang + " ")) )
Alexey Samsonov589231c2012-08-15 08:54:14 +000047config.substitutions.append( ("%clangxx ", (" " + config.clang +
Alexey Samsonovea0177e2012-10-30 10:06:42 +000048 " -ccc-cxx ")) )
Alexey Samsonov7274ff82012-07-31 15:43:11 +000049
50# Use ugly construction to explicitly prohibit "clang", "clang++" etc.
51# in RUN lines.
52config.substitutions.append(
53 (' clang', """\n\n*** Do not use 'clangXXX' in tests,
54 instead define '%clangXXX' substitution in lit config. ***\n\n""") )
Alexey Samsonov6b5346e2013-05-21 08:22:03 +000055
56# Add supported compiler_rt architectures to a list of available features.
57compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
58if compiler_rt_arch:
59 for arch in compiler_rt_arch.split(";"):
60 config.available_features.add(arch + "-supported-target")