Skip to content

Commit

Permalink
Auto merge of #127523 - Oneirical:treasure-test, r=<try>
Browse files Browse the repository at this point in the history
Migrate `dump-ice-to-disk` and `panic-abort-eh_frame` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Please try:

try-job: aarch64-apple
try-job: x86_64-msvc
  • Loading branch information
bors committed Jul 9, 2024
2 parents f25e92b + 7b37e2b commit 56e4ec0
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 86 deletions.
2 changes: 0 additions & 2 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ run-make/cross-lang-lto/Makefile
run-make/dep-info-doesnt-run-much/Makefile
run-make/dep-info-spaces/Makefile
run-make/dep-info/Makefile
run-make/dump-ice-to-disk/Makefile
run-make/dump-mono-stats/Makefile
run-make/emit-to-stdout/Makefile
run-make/env-dep-info/Makefile
Expand Down Expand Up @@ -96,7 +95,6 @@ run-make/no-alloc-shim/Makefile
run-make/no-builtins-attribute/Makefile
run-make/no-duplicate-libs/Makefile
run-make/obey-crate-type-flag/Makefile
run-make/panic-abort-eh_frame/Makefile
run-make/pass-non-c-like-enum-to-c/Makefile
run-make/pdb-buildinfo-cl-cmd/Makefile
run-make/pgo-gen-lto/Makefile
Expand Down
10 changes: 0 additions & 10 deletions tests/run-make/dump-ice-to-disk/Makefile

This file was deleted.

64 changes: 0 additions & 64 deletions tests/run-make/dump-ice-to-disk/check.sh

This file was deleted.

File renamed without changes.
64 changes: 64 additions & 0 deletions tests/run-make/dump-ice-to-disk/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// This test checks if internal compilation error (ICE) log files work as expected.
// - Get the number of lines from the log files without any configuration options,
// then check that the line count doesn't change if the backtrace gets configured to be short
// or full.
// - Check that disabling ICE logging results in zero files created.
// - Check that the ICE files contain some of the expected strings.
// See https://github.com/rust-lang/rust/pull/108714

// FIXME(Oneirical): try it on Windows!

use run_make_support::{cwd, fs_wrapper, has_extension, has_prefix, rustc, shallow_find_files};

fn main() {
rustc().input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
let ice_text = get_text_from_ice();
let default_set = ice_text.lines().count();
let content = ice_text;
// Ensure that the ICE files don't contain `:` in their filename because
// this causes problems on Windows.
for file in shallow_find_files(cwd(), |path| {
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
}) {
assert!(!file.display().to_string().contains(":"));
}

clear_ice_files();
rustc().input("lib.rs").env("RUST_BACKTRACE", "short").arg("-Ztreat-err-as-bug=1").run_fail();
let short = get_text_from_ice().lines().count();
clear_ice_files();
rustc().input("lib.rs").env("RUST_BACKTRACE", "full").arg("-Ztreat-err-as-bug=1").run_fail();
let full = get_text_from_ice().lines().count();
clear_ice_files();

// The ICE dump is explicitely disabled. Therefore, this should produce no files.
rustc().env("RUSTC_ICE", "0").input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
assert!(get_text_from_ice().is_empty());

// The line count should not change.
assert_eq!(short, default_set);
assert_eq!(full, default_set);
// Some of the expected strings in an ICE file should appear.
assert!(content.contains("thread 'rustc' panicked at"));
assert!(content.contains("stack backtrace:"));
}

fn clear_ice_files() {
let ice_files = shallow_find_files(cwd(), |path| {
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
});
for file in ice_files {
fs_wrapper::remove_file(file);
}
}

fn get_text_from_ice() -> String {
let ice_files = shallow_find_files(cwd(), |path| {
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
});
let mut output = String::new();
for file in ice_files {
output.push_str(&fs_wrapper::read_to_string(file));
}
output
}
10 changes: 0 additions & 10 deletions tests/run-make/panic-abort-eh_frame/Makefile

This file was deleted.

22 changes: 22 additions & 0 deletions tests/run-make/panic-abort-eh_frame/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// An `.eh_frame` section in an object file is a symptom of an UnwindAction::Terminate
// being inserted, useful for determining whether or not unwinding is necessary.
// This is useless when panics would NEVER unwind due to -C panic=abort. This section should
// therefore never appear in the emit file of a -C panic=abort compilation, and this test
// checks that this is respected.
// See https://github.com/rust-lang/rust/pull/112403

// FIXME(Oneirical): try it on more than only-linux!

use run_make_support::{llvm_objdump, rustc};

fn main() {
rustc()
.input("foo.rs")
.crate_type("lib")
.emit("obj=foo.o")
.panic("abort")
.edition("2021")
.arg("-Zvalidate-mir")
.run();
llvm_objdump().arg("--dwarf=frames").input("foo.o").run().assert_stdout_not_contains("DW_CFA");
}

0 comments on commit 56e4ec0

Please sign in to comment.