From 7b19389d586a4bb29180c365e69138609b8a6f01 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 19 Jul 2024 14:05:09 -0400 Subject: [PATCH 1/3] rewrite test-benches to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/test-benches/Makefile | 12 ----------- tests/run-make/test-benches/rmake.rs | 21 +++++++++++++++++++ 3 files changed, 21 insertions(+), 13 deletions(-) delete mode 100644 tests/run-make/test-benches/Makefile create mode 100644 tests/run-make/test-benches/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 bd25a6c144e64..8612d591c7e40 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -100,7 +100,6 @@ run-make/staticlib-dylib-linkage/Makefile run-make/symbol-mangling-hashed/Makefile run-make/symbol-visibility/Makefile run-make/sysroot-crates-are-unstable/Makefile -run-make/test-benches/Makefile run-make/thumb-none-cortex-m/Makefile run-make/thumb-none-qemu/Makefile run-make/translation/Makefile diff --git a/tests/run-make/test-benches/Makefile b/tests/run-make/test-benches/Makefile deleted file mode 100644 index 11aed2e4c79a6..0000000000000 --- a/tests/run-make/test-benches/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -include ../tools.mk - -# ignore-cross-compile -# needs-unwind #[bench] and -Zpanic-abort-tests can't be combined - -all: - # Smoke-test that `#[bench]` isn't entirely broken. - $(RUSTC) --test smokebench.rs -O - $(call RUN,smokebench --bench) - $(call RUN,smokebench --bench noiter) - $(call RUN,smokebench --bench yesiter) - $(call RUN,smokebench) diff --git a/tests/run-make/test-benches/rmake.rs b/tests/run-make/test-benches/rmake.rs new file mode 100644 index 0000000000000..acf9b04becb23 --- /dev/null +++ b/tests/run-make/test-benches/rmake.rs @@ -0,0 +1,21 @@ +// #[bench] is a Rust feature to run benchmarks on performance-critical +// code, which previously experienced a runtime panic bug in #103794. +// In order to ensure future breakages of this feature are detected, this +// smoke test was created, using the benchmarking feature with various +// runtime flags. +// See https://github.com/rust-lang/rust/issues/103794 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed +//@ needs-unwind +// Reason: #[bench] and -Zpanic-abort-tests can't be combined + +use run_make_support::{run, run_with_args, rustc}; + +fn main() { + rustc().arg("--test").input("smokebench.rs").opt().run(); + run_with_args("smokebench", &["--bench"]); + run_with_args("smokebench", &["--bench", "noiter"]); + run_with_args("smokebench", &["--bench", "yesiter"]); + run("smokebench"); +} From 27334943ed92216760e232f0276610271ee3305b Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 19 Jul 2024 14:39:42 -0400 Subject: [PATCH 2/3] rewrite c-unwind-abi-catch-panic to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/c-unwind-abi-catch-panic/Makefile | 10 ---------- .../run-make/c-unwind-abi-catch-panic/rmake.rs | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 11 deletions(-) delete mode 100644 tests/run-make/c-unwind-abi-catch-panic/Makefile create mode 100644 tests/run-make/c-unwind-abi-catch-panic/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 8612d591c7e40..ed1ae071f07ca 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -4,7 +4,6 @@ run-make/c-dynamic-rlib/Makefile run-make/c-static-dylib/Makefile run-make/c-static-rlib/Makefile run-make/c-unwind-abi-catch-lib-panic/Makefile -run-make/c-unwind-abi-catch-panic/Makefile run-make/cat-and-grep-sanity-check/Makefile run-make/cdylib-dylib-linkage/Makefile run-make/compiler-lookup-paths-2/Makefile diff --git a/tests/run-make/c-unwind-abi-catch-panic/Makefile b/tests/run-make/c-unwind-abi-catch-panic/Makefile deleted file mode 100644 index 0a38d838e32a7..0000000000000 --- a/tests/run-make/c-unwind-abi-catch-panic/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# Exercise unwinding a panic. This catches a panic across an FFI boundary and downcasts it into an integer. The Rust code that panics is in the same directory. -# See https://github.com/rust-lang/rust/commit/baf227ea0c1e07fc54395a51e4b3881d701180cb - -# ignore-cross-compile -# needs-unwind -include ../tools.mk - -all: $(call NATIVE_STATICLIB,add) - $(RUSTC) main.rs - $(call RUN,main) || exit 1 diff --git a/tests/run-make/c-unwind-abi-catch-panic/rmake.rs b/tests/run-make/c-unwind-abi-catch-panic/rmake.rs new file mode 100644 index 0000000000000..a99dbd18ec619 --- /dev/null +++ b/tests/run-make/c-unwind-abi-catch-panic/rmake.rs @@ -0,0 +1,18 @@ +// A test for calling `C-unwind` functions across foreign function boundaries (FFI). +// This test triggers a panic when calling a foreign function that calls *back* into Rust. +// This catches a panic across an FFI boundary and downcasts it into an integer. +// The Rust code that panics is in the same directory, unlike `c-unwind-abi-catch-lib-panic`. +// See https://github.com/rust-lang/rust/pull/76570 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed +//@ needs-unwind +// Reason: this test exercises panic unwinding + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("add"); + rustc().input("main.rs").run(); + run("main"); +} From 2192a916d4193c2a602e1ab6c9e236f389a962b5 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 19 Jul 2024 15:00:10 -0400 Subject: [PATCH 3/3] rewrite compiler-lookup-paths-2 to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/compiler-lookup-paths-2/Makefile | 11 ---------- .../run-make/compiler-lookup-paths-2/rmake.rs | 20 +++++++++++++++++++ tests/run-make/test-benches/rmake.rs | 1 + 4 files changed, 21 insertions(+), 12 deletions(-) delete mode 100644 tests/run-make/compiler-lookup-paths-2/Makefile create mode 100644 tests/run-make/compiler-lookup-paths-2/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 ed1ae071f07ca..23ce7f242f71d 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -6,7 +6,6 @@ run-make/c-static-rlib/Makefile run-make/c-unwind-abi-catch-lib-panic/Makefile run-make/cat-and-grep-sanity-check/Makefile run-make/cdylib-dylib-linkage/Makefile -run-make/compiler-lookup-paths-2/Makefile run-make/compiler-rt-works-on-mingw/Makefile run-make/crate-hash-rustc-version/Makefile run-make/cross-lang-lto-clang/Makefile diff --git a/tests/run-make/compiler-lookup-paths-2/Makefile b/tests/run-make/compiler-lookup-paths-2/Makefile deleted file mode 100644 index ecc0577384ab6..0000000000000 --- a/tests/run-make/compiler-lookup-paths-2/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# This test checks that extern crate declarations in Cargo without a corresponding declaration in the manifest of a dependency are NOT allowed. -# See https://github.com/rust-lang/rust/pull/21113 - -include ../tools.mk - -all: - mkdir -p $(TMPDIR)/a $(TMPDIR)/b - $(RUSTC) a.rs && mv $(TMPDIR)/liba.rlib $(TMPDIR)/a - $(RUSTC) b.rs -L $(TMPDIR)/a && mv $(TMPDIR)/libb.rlib $(TMPDIR)/b - $(RUSTC) c.rs -L crate=$(TMPDIR)/b -L dependency=$(TMPDIR)/a \ - && exit 1 || exit 0 diff --git a/tests/run-make/compiler-lookup-paths-2/rmake.rs b/tests/run-make/compiler-lookup-paths-2/rmake.rs new file mode 100644 index 0000000000000..99efb157b5378 --- /dev/null +++ b/tests/run-make/compiler-lookup-paths-2/rmake.rs @@ -0,0 +1,20 @@ +// This test checks that extern crate declarations in Cargo without a corresponding declaration +// in the manifest of a dependency are NOT allowed. The last rustc call does it anyways, which +// should result in a compilation failure. +// See https://github.com/rust-lang/rust/pull/21113 + +use run_make_support::{path, rfs, rust_lib_name, rustc}; + +fn main() { + rfs::create_dir("a"); + rfs::create_dir("b"); + rustc().input("a.rs").run(); + rfs::rename(rust_lib_name("a"), path("a").join(rust_lib_name("a"))); + rustc().input("b.rs").library_search_path("a").run(); + rfs::rename(rust_lib_name("b"), path("b").join(rust_lib_name("b"))); + rustc() + .input("c.rs") + .library_search_path("crate=b") + .library_search_path("dependency=a") + .run_fail(); +} diff --git a/tests/run-make/test-benches/rmake.rs b/tests/run-make/test-benches/rmake.rs index acf9b04becb23..1458fb8c9904a 100644 --- a/tests/run-make/test-benches/rmake.rs +++ b/tests/run-make/test-benches/rmake.rs @@ -13,6 +13,7 @@ use run_make_support::{run, run_with_args, rustc}; fn main() { + // Smoke-test that #[bench] isn't entirely broken. rustc().arg("--test").input("smokebench.rs").opt().run(); run_with_args("smokebench", &["--bench"]); run_with_args("smokebench", &["--bench", "noiter"]);