From fe3fbf0ab425c9d43d008449c3bbe03c1f49bcaf Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 22 Jul 2024 16:30:32 -0400 Subject: [PATCH] rewrite sanitizer-dylib-link to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 2 -- tests/run-make/sanitizer-dylib-link/Makefile | 16 ---------------- tests/run-make/sanitizer-dylib-link/rmake.rs | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 tests/run-make/sanitizer-dylib-link/Makefile create mode 100644 tests/run-make/sanitizer-dylib-link/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index eecaa193b46..b46fe419269 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -70,8 +70,6 @@ run-make/reproducible-build-2/Makefile run-make/reproducible-build/Makefile run-make/rlib-format-packed-bundled-libs-2/Makefile run-make/rlib-format-packed-bundled-libs/Makefile -run-make/sanitizer-cdylib-link/Makefile -run-make/sanitizer-dylib-link/Makefile run-make/sanitizer-staticlib-link/Makefile run-make/share-generics-dylib/Makefile run-make/simd-ffi/Makefile diff --git a/tests/run-make/sanitizer-dylib-link/Makefile b/tests/run-make/sanitizer-dylib-link/Makefile deleted file mode 100644 index c5a698db3a0..00000000000 --- a/tests/run-make/sanitizer-dylib-link/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# needs-sanitizer-support -# needs-sanitizer-address - -include ../tools.mk - -LOG := $(TMPDIR)/log.txt - -# This test builds a shared object, then an executable that links it as a native -# rust library (contrast to an rlib). The shared library and executable both -# are compiled with address sanitizer, and we assert that a fault in the dylib -# is correctly detected. - -all: - $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) library.rs - $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) program.rs - LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow diff --git a/tests/run-make/sanitizer-dylib-link/rmake.rs b/tests/run-make/sanitizer-dylib-link/rmake.rs new file mode 100644 index 00000000000..b43420adc72 --- /dev/null +++ b/tests/run-make/sanitizer-dylib-link/rmake.rs @@ -0,0 +1,16 @@ +// This test builds a shared object, then an executable that links it as a native +// rust library (contrast to an rlib). The shared library and executable both +// are compiled with address sanitizer, and we assert that a fault in the dylib +// is correctly detected. +// See https://github.com/rust-lang/rust/pull/38699 + +//@ needs-sanitizer-support +//@ needs-sanitizer-address + +use run_make_support::{run_fail, rustc}; + +fn main() { + rustc().arg("-g").arg("-Zsanitizer=address").crate_type("dylib").input("library.rs").run(); + rustc().arg("-g").arg("-Zsanitizer=address").crate_type("bin").input("program.rs").run(); + run_fail("program").assert_stderr_contains("stack-buffer-overflow"); +}