about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-07-22 16:30:43 -0400
committerOneirical <manchot@videotron.ca>2024-07-23 10:26:35 -0400
commitd22425606ef2e41f47b4b6248c7982b29cc2caf2 (patch)
treecc4ae02897830250a3529e196ab103988119e6db
parentfe3fbf0ab425c9d43d008449c3bbe03c1f49bcaf (diff)
downloadrust-d22425606ef2e41f47b4b6248c7982b29cc2caf2.tar.gz
rust-d22425606ef2e41f47b4b6248c7982b29cc2caf2.zip
rewrite sanitizer-cdylib-link to rmake
-rw-r--r--tests/run-make/sanitizer-cdylib-link/Makefile16
-rw-r--r--tests/run-make/sanitizer-cdylib-link/rmake.rs17
2 files changed, 17 insertions, 16 deletions
diff --git a/tests/run-make/sanitizer-cdylib-link/Makefile b/tests/run-make/sanitizer-cdylib-link/Makefile
deleted file mode 100644
index 10d94afc39e..00000000000
--- a/tests/run-make/sanitizer-cdylib-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 cdylib
-# is correctly detected.
-
-all:
-	$(RUSTC) -g -Z sanitizer=address --crate-type cdylib --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-cdylib-link/rmake.rs b/tests/run-make/sanitizer-cdylib-link/rmake.rs
new file mode 100644
index 00000000000..f9d7fd98789
--- /dev/null
+++ b/tests/run-make/sanitizer-cdylib-link/rmake.rs
@@ -0,0 +1,17 @@
+// Identical to sanitizer-dylib-link, but with a cdylib.
+// 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 cdylib
+// 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("cdylib").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");
+}