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 = []
|
2018-06-09 08:47:37 +08:00
|
|
|
collect_stack_traces = ""
|
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"
|
2018-06-09 08:47:37 +08:00
|
|
|
collect_stack_traces = "-fsanitize-memory-track-origins"
|
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']
|
2020-06-09 03:01:14 +08:00
|
|
|
if config.tool_name == "tsan":
|
|
|
|
default_tool_options += ['ignore_interceptors_accesses=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 += ':'
|
|
|
|
|
2019-10-09 04:50:46 +08:00
|
|
|
extra_link_flags = []
|
|
|
|
|
2018-10-09 02:04:00 +08:00
|
|
|
if config.host_os in ['Linux']:
|
2019-10-09 04:50:46 +08:00
|
|
|
extra_link_flags += ["-ldl"]
|
|
|
|
|
2014-09-06 06:05:32 +08:00
|
|
|
clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags]
|
2018-10-09 02:04:00 +08:00
|
|
|
clang_cflags += extra_link_flags
|
2014-05-09 08:28:18 +08:00
|
|
|
clang_cxxflags = config.cxx_mode_flags + clang_cflags
|
|
|
|
|
|
|
|
def build_invocation(compile_flags):
|
[ubsan] Re-commit: lit changes for lld testing, future lto testing.
Summary:
As discussed in https://github.com/google/oss-fuzz/issues/933,
it would be really awesome to be able to use ThinLTO for fuzzing.
However, as @kcc has pointed out, it is currently undefined (untested)
whether the sanitizers actually function properly with LLD and/or LTO.
This patch is inspired by the cfi test, which already do test with LTO
(and/or LLD), since LTO is required for CFI to function.
I started with UBSan, because it's cmakelists / lit.* files appeared
to be the cleanest. This patch adds the infrastructure to easily add
LLD and/or LTO sub-variants of the existing lit test configurations.
Also, this patch adds the LLD flavor, that explicitly does use LLD to link.
The check-ubsan does pass on my machine. And to minimize the [initial]
potential buildbot breakage i have put some restrictions on this flavour.
Please review carefully, i have not worked with lit/sanitizer tests before.
The original attempt, r319525 was reverted in r319526 due
to the failures in compiler-rt standalone builds.
Reviewers: eugenis, vitalybuka
Reviewed By: eugenis
Subscribers: #sanitizers, pcc, kubamracek, mgorny, llvm-commits, mehdi_amini, inglorion, kcc
Differential Revision: https://reviews.llvm.org/D39508
llvm-svn: 319575
2017-12-02 03:36:29 +08:00
|
|
|
return " " + " ".join([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)) )
|
2018-06-09 08:47:37 +08:00
|
|
|
config.substitutions.append( ("%collect_stack_traces", collect_stack_traces) )
|
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
|
|
|
|
2019-08-06 03:25:35 +08:00
|
|
|
config.suffixes = ['.c', '.cpp']
|
2014-05-09 08:28:18 +08:00
|
|
|
|
FreeBSD sanitizer common, intercept couple of more functions
Summary:
Intercepts lstat, acct, access, faccessat and strlcpy/strlcat
Patch by David CARLIER
Reviewers: visa, vitalybuka
Subscribers: krytarowski, fedor.sergeev, srhines, kubamracek, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D44432
llvm-svn: 328376
2018-03-24 05:44:59 +08:00
|
|
|
if config.host_os not in ['Linux', 'Darwin', 'NetBSD', 'FreeBSD']:
|
2014-05-09 08:28:18 +08:00
|
|
|
config.unsupported = True
|
2019-02-13 09:56:53 +08:00
|
|
|
|
2019-03-01 03:26:53 +08:00
|
|
|
if not config.parallelism_group:
|
|
|
|
config.parallelism_group = 'shadow-memory'
|
2019-12-03 21:44:33 +08:00
|
|
|
|
|
|
|
if config.host_os == 'NetBSD':
|
|
|
|
config.substitutions.insert(0, ('%run', config.netbsd_noaslr_prefix))
|