// Verifies that MemorySanitizer track-origins level can be controlled
// with -Zsanitizer-memory-track-origins option.
//
-// needs-sanitizer-support
-// only-linux
-// only-x86_64
+// needs-sanitizer-memory
// revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO
//
//[MSAN-0] compile-flags: -Zsanitizer=memory
// Verifies that no_sanitize attribute prevents inlining when
// given sanitizer is enabled, but has no effect on inlining otherwise.
//
-// needs-sanitizer-support
-// only-x86_64
-//
+// needs-sanitizer-address
+// needs-sanitizer-leak
// revisions: ASAN LSAN
-//
//[ASAN] compile-flags: -Zsanitizer=address -C opt-level=3 -Z mir-opt-level=3
//[LSAN] compile-flags: -Zsanitizer=leak -C opt-level=3 -Z mir-opt-level=3
// Verifies that no_sanitze attribute can be used to
// selectively disable sanitizer instrumentation.
//
-// needs-sanitizer-support
+// needs-sanitizer-address
// compile-flags: -Zsanitizer=address
#![crate_type="lib"]
// Verifies that AddressSanitizer and MemorySanitizer
// recovery mode can be enabled with -Zsanitizer-recover.
//
-// needs-sanitizer-support
-// only-linux
-// only-x86_64
+// needs-sanitizer-address
+// needs-sanitizer-memory
// revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER MSAN-RECOVER-LTO
// no-prefer-dynamic
//
# needs-sanitizer-support
-# only-x86_64
+# needs-sanitizer-address
# only-linux
-include ../tools.mk
# needs-sanitizer-support
-# only-x86_64
+# needs-sanitizer-address
# only-linux
-include ../tools.mk
# needs-sanitizer-support
-# only-x86_64
+# needs-sanitizer-address
# only-linux
-include ../tools.mk
// needs-sanitizer-support
+// needs-sanitizer-address
// compile-flags: --test -Z sanitizer=address
//
// #43031: Verify that rustdoc passes `-Z` options to rustc. Use an extern
// needs-sanitizer-support
-// only-x86_64
+// needs-sanitizer-address
//
// compile-flags: -Z sanitizer=address -O -g
//
// needs-sanitizer-support
-// only-x86_64
+// needs-sanitizer-address
//
// compile-flags: -Z sanitizer=address -O
//
// the `#[cfg(sanitize = "option")]` attribute is configured.
// needs-sanitizer-support
-// only-linux
-// only-x86_64
+// needs-sanitizer-address
+// needs-sanitizer-leak
+// needs-sanitizer-memory
+// needs-sanitizer-thread
// check-pass
// revisions: address leak memory thread
//[address]compile-flags: -Zsanitizer=address --cfg address
// miscompilation which was subsequently detected by AddressSanitizer as UB.
//
// needs-sanitizer-support
-// only-x86_64
+// needs-sanitizer-address
//
// compile-flags: -Copt-level=0 -Zsanitizer=address
// run-pass
// needs-sanitizer-support
-// only-x86_64
+// needs-sanitizer-leak
//
// compile-flags: -Z sanitizer=leak -O
//
// needs-sanitizer-support
-// only-linux
-// only-x86_64
+// needs-sanitizer-memory
//
// compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O
//
//
// min-llvm-version 9.0
// needs-sanitizer-support
-// only-x86_64
+// needs-sanitizer-address
//
// no-prefer-dynamic
// revisions: opt0 opt1
// would occasionally fail, making test flaky.
//
// needs-sanitizer-support
-// only-x86_64
+// needs-sanitizer-thread
//
// compile-flags: -Z sanitizer=thread -O
//
// needs-sanitizer-support
-// only-x86_64
+// needs-sanitizer-address
//
// compile-flags: -Zsanitizer=address
// run-fail
let mut props = EarlyProps::default();
let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some();
let rustc_has_sanitizer_support = env::var_os("RUSTC_SANITIZER_SUPPORT").is_some();
+ let has_asan = util::ASAN_SUPPORTED_TARGETS.contains(&&*config.target);
+ let has_lsan = util::LSAN_SUPPORTED_TARGETS.contains(&&*config.target);
+ let has_msan = util::MSAN_SUPPORTED_TARGETS.contains(&&*config.target);
+ let has_tsan = util::TSAN_SUPPORTED_TARGETS.contains(&&*config.target);
iter_header(testfile, None, rdr, &mut |ln| {
// we should check if any only-<platform> exists and if it exists
props.ignore = true;
}
- if !rustc_has_sanitizer_support && config.parse_needs_sanitizer_support(ln) {
+ if !rustc_has_sanitizer_support
+ && config.parse_name_directive(ln, "needs-sanitizer-support")
+ {
+ props.ignore = true;
+ }
+
+ if !has_asan && config.parse_name_directive(ln, "needs-sanitizer-address") {
+ props.ignore = true;
+ }
+
+ if !has_lsan && config.parse_name_directive(ln, "needs-sanitizer-leak") {
+ props.ignore = true;
+ }
+
+ if !has_msan && config.parse_name_directive(ln, "needs-sanitizer-memory") {
+ props.ignore = true;
+ }
+
+ if !has_tsan && config.parse_name_directive(ln, "needs-sanitizer-thread") {
props.ignore = true;
}
self.parse_name_directive(line, "needs-profiler-support")
}
- fn parse_needs_sanitizer_support(&self, line: &str) -> bool {
- self.parse_name_directive(line, "needs-sanitizer-support")
- }
-
/// Parses a name-value directive which contains config-specific information, e.g., `ignore-x86`
/// or `normalize-stderr-32bit`.
fn parse_cfg_name_directive(&self, line: &str, prefix: &str) -> ParsedNameDirective {
config.debugger = Some(Debugger::Lldb);
assert!(parse_rs(&config, "// ignore-lldb").ignore);
}
+
+#[test]
+fn sanitizers() {
+ let mut config = config();
+
+ // Target that supports all sanitizers:
+ config.target = "x86_64-unknown-linux-gnu".to_owned();
+ assert!(!parse_rs(&config, "// needs-sanitizer-address").ignore);
+ assert!(!parse_rs(&config, "// needs-sanitizer-leak").ignore);
+ assert!(!parse_rs(&config, "// needs-sanitizer-memory").ignore);
+ assert!(!parse_rs(&config, "// needs-sanitizer-thread").ignore);
+
+ // Target that doesn't support sanitizers:
+ config.target = "wasm32-unknown-emscripten".to_owned();
+ assert!(parse_rs(&config, "// needs-sanitizer-address").ignore);
+ assert!(parse_rs(&config, "// needs-sanitizer-leak").ignore);
+ assert!(parse_rs(&config, "// needs-sanitizer-memory").ignore);
+ assert!(parse_rs(&config, "// needs-sanitizer-thread").ignore);
+}
("xcore", "xcore"),
];
+pub const ASAN_SUPPORTED_TARGETS: &'static [&'static str] =
+ &["aarch64-fuchsia", "x86_64-apple-darwin", "x86_64-fuchsia", "x86_64-unknown-linux-gnu"];
+
+pub const LSAN_SUPPORTED_TARGETS: &'static [&'static str] =
+ &["x86_64-apple-darwin", "x86_64-unknown-linux-gnu"];
+
+pub const MSAN_SUPPORTED_TARGETS: &'static [&'static str] = &["x86_64-unknown-linux-gnu"];
+
+pub const TSAN_SUPPORTED_TARGETS: &'static [&'static str] =
+ &["x86_64-apple-darwin", "x86_64-unknown-linux-gnu"];
+
pub fn matches_os(triple: &str, name: &str) -> bool {
// For the wasm32 bare target we ignore anything also ignored on emscripten
// and then we also recognize `wasm32-bare` as the os for the target