2014-05-09 08:28:18 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
# Setup source root.
|
|
|
|
config.test_source_root = os.path.join(os.path.dirname(__file__), "TestCases")
|
|
|
|
|
2016-02-10 00:14:31 +08:00
|
|
|
config.name = "SanitizerCommon-" + config.name_suffix
|
2014-05-09 08:28:18 +08:00
|
|
|
|
2015-08-28 04:40:24 +08:00
|
|
|
default_tool_options = []
|
2014-05-09 08:28:18 +08:00
|
|
|
if config.tool_name == "asan":
|
|
|
|
tool_cflags = ["-fsanitize=address"]
|
2014-10-25 02:34:43 +08:00
|
|
|
tool_options = "ASAN_OPTIONS"
|
2014-05-09 08:28:18 +08:00
|
|
|
elif config.tool_name == "tsan":
|
|
|
|
tool_cflags = ["-fsanitize=thread"]
|
2014-10-25 02:34:43 +08:00
|
|
|
tool_options = "TSAN_OPTIONS"
|
2014-05-09 08:28:18 +08:00
|
|
|
elif config.tool_name == "msan":
|
|
|
|
tool_cflags = ["-fsanitize=memory"]
|
2014-10-25 02:34:43 +08:00
|
|
|
tool_options = "MSAN_OPTIONS"
|
2014-07-04 15:30:34 +08:00
|
|
|
elif config.tool_name == "lsan":
|
|
|
|
tool_cflags = ["-fsanitize=leak"]
|
2014-10-25 02:34:43 +08:00
|
|
|
tool_options = "LSAN_OPTIONS"
|
2017-09-09 14:10:58 +08:00
|
|
|
elif config.tool_name == "ubsan":
|
|
|
|
tool_cflags = ["-fsanitize=undefined"]
|
|
|
|
tool_options = "UBSAN_OPTIONS"
|
2014-05-09 08:28:18 +08:00
|
|
|
else:
|
|
|
|
lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name)
|
|
|
|
|
2014-05-26 21:08:08 +08:00
|
|
|
config.available_features.add(config.tool_name)
|
|
|
|
|
2017-08-29 04:30:12 +08:00
|
|
|
if config.host_os == 'Linux' and config.tool_name == "lsan" and config.target_arch == 'i386':
|
2017-01-31 15:15:37 +08:00
|
|
|
config.available_features.add("lsan-x86")
|
|
|
|
|
2015-08-28 04:40:24 +08:00
|
|
|
if config.host_os == 'Darwin':
|
|
|
|
# On Darwin, we default to `abort_on_error=1`, which would make tests run
|
|
|
|
# much slower. Let's override this and run lit tests with 'abort_on_error=0'.
|
|
|
|
default_tool_options += ['abort_on_error=0']
|
2017-09-16 13:14:05 +08:00
|
|
|
elif config.android:
|
|
|
|
# The same as on Darwin, we default to "abort_on_error=1" which slows down
|
|
|
|
# testing. Also, all existing tests are using "not" instead of "not --crash"
|
|
|
|
# which does not work for abort()-terminated programs.
|
|
|
|
default_tool_options += ['abort_on_error=0']
|
|
|
|
|
2015-08-28 04:40:24 +08:00
|
|
|
default_tool_options_str = ':'.join(default_tool_options)
|
|
|
|
if default_tool_options_str:
|
|
|
|
config.environment[tool_options] = default_tool_options_str
|
|
|
|
default_tool_options_str += ':'
|
|
|
|
|
2014-09-06 06:05:32 +08:00
|
|
|
clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags]
|
2014-05-09 08:28:18 +08:00
|
|
|
clang_cxxflags = config.cxx_mode_flags + clang_cflags
|
|
|
|
|
|
|
|
def build_invocation(compile_flags):
|
Revert "[ubsan] lit changes for lld testing, future lto testing."
This reverts commit r319525.
This change has introduced a problem with the Lit tests build for compiler-rt using Gold: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/6047/steps/test%20standalone%20compiler-rt/logs/stdio
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm/utils/lit/lit/TestingConfig.py:101: fatal: unable to parse config file '/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/profile/Linux/lit.local.cfg', traceback: Traceback (most recent call last):
File "/b/sanitizer-x86_64-linux/build/llvm/utils/lit/lit/TestingConfig.py", line 88, in load_from_path
exec(compile(data, path, 'exec'), cfg_globals, None)
File "/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/profile/Linux/lit.local.cfg", line 37, in <module>
if root.host_os not in ['Linux'] or not is_gold_linker_available():
File "/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/profile/Linux/lit.local.cfg", line 27, in is_gold_linker_available
stderr = subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1024, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
llvm-svn: 319529
2017-12-01 18:09:27 +08:00
|
|
|
return " " + " ".join([config.compile_wrapper, config.clang] + compile_flags) + " "
|
2014-05-09 08:28:18 +08:00
|
|
|
|
|
|
|
config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
|
|
|
|
config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
|
2015-05-30 06:31:28 +08:00
|
|
|
config.substitutions.append( ("%tool_name", config.tool_name) )
|
2015-08-28 04:40:24 +08:00
|
|
|
config.substitutions.append( ("%tool_options", tool_options) )
|
2015-08-27 03:29:07 +08:00
|
|
|
config.substitutions.append( ('%env_tool_opts=',
|
|
|
|
'env ' + tool_options + '=' + default_tool_options_str))
|
2014-05-09 08:28:18 +08:00
|
|
|
|
|
|
|
config.suffixes = ['.c', '.cc', '.cpp']
|
|
|
|
|
|
|
|
if config.host_os not in ['Linux', 'Darwin']:
|
|
|
|
config.unsupported = True
|