Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9cd4712

Browse files
committedJul 9, 2024
Auto merge of rust-lang#127523 - Oneirical:treasure-test, r=<try>
Migrate `dump-ice-to-disk` and `panic-abort-eh_frame` `run-make` tests to rmake Part of rust-lang#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: x86_64-msvc
2 parents f25e92b + fb0e011 commit 9cd4712

File tree

7 files changed

+87
-86
lines changed

7 files changed

+87
-86
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ run-make/cross-lang-lto/Makefile
2121
run-make/dep-info-doesnt-run-much/Makefile
2222
run-make/dep-info-spaces/Makefile
2323
run-make/dep-info/Makefile
24-
run-make/dump-ice-to-disk/Makefile
2524
run-make/dump-mono-stats/Makefile
2625
run-make/emit-to-stdout/Makefile
2726
run-make/env-dep-info/Makefile
@@ -96,7 +95,6 @@ run-make/no-alloc-shim/Makefile
9695
run-make/no-builtins-attribute/Makefile
9796
run-make/no-duplicate-libs/Makefile
9897
run-make/obey-crate-type-flag/Makefile
99-
run-make/panic-abort-eh_frame/Makefile
10098
run-make/pass-non-c-like-enum-to-c/Makefile
10199
run-make/pdb-buildinfo-cl-cmd/Makefile
102100
run-make/pgo-gen-lto/Makefile

‎tests/run-make/dump-ice-to-disk/Makefile

-10
This file was deleted.

‎tests/run-make/dump-ice-to-disk/check.sh

-64
This file was deleted.
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// This test checks if internal compilation error (ICE) log files work as expected.
2+
// - Get the number of lines from the log files without any configuration options,
3+
// then check that the line count doesn't change if the backtrace gets configured to be short
4+
// or full.
5+
// - Check that disabling ICE logging results in zero files created.
6+
// - Check that the ICE files contain some of the expected strings.
7+
// See https://github.com/rust-lang/rust/pull/108714
8+
9+
// FIXME(Oneirical): try it on Windows!
10+
11+
use run_make_support::{cwd, fs_wrapper, has_extension, has_prefix, rustc, shallow_find_files};
12+
13+
fn main() {
14+
rustc().input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
15+
let ice_text = get_text_from_ice();
16+
let default_set = ice_text.lines().count();
17+
let content = ice_text;
18+
// Ensure that the ICE files don't contain `:` in their filename because
19+
// this causes problems on Windows.
20+
for file in shallow_find_files(cwd(), |path| {
21+
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
22+
}) {
23+
println!("{}", file.display().to_string()); //FIXME(Oneirical): Remove this
24+
// assert!(!file.display().to_string().contains(":"));
25+
}
26+
27+
clear_ice_files();
28+
rustc().input("lib.rs").env("RUST_BACKTRACE", "short").arg("-Ztreat-err-as-bug=1").run_fail();
29+
let short = get_text_from_ice().lines().count();
30+
clear_ice_files();
31+
rustc().input("lib.rs").env("RUST_BACKTRACE", "full").arg("-Ztreat-err-as-bug=1").run_fail();
32+
let full = get_text_from_ice().lines().count();
33+
clear_ice_files();
34+
35+
// The ICE dump is explicitely disabled. Therefore, this should produce no files.
36+
rustc().env("RUSTC_ICE", "0").input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
37+
assert!(get_text_from_ice().is_empty());
38+
39+
// The line count should not change.
40+
assert_eq!(short, default_set);
41+
assert_eq!(full, default_set);
42+
// Some of the expected strings in an ICE file should appear.
43+
assert!(content.contains("thread 'rustc' panicked at"));
44+
assert!(content.contains("stack backtrace:"));
45+
}
46+
47+
fn clear_ice_files() {
48+
let ice_files = shallow_find_files(cwd(), |path| {
49+
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
50+
});
51+
for file in ice_files {
52+
fs_wrapper::remove_file(file);
53+
}
54+
}
55+
56+
fn get_text_from_ice() -> String {
57+
let ice_files = shallow_find_files(cwd(), |path| {
58+
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
59+
});
60+
let mut output = String::new();
61+
for file in ice_files {
62+
output.push_str(&fs_wrapper::read_to_string(file));
63+
}
64+
output
65+
}

‎tests/run-make/panic-abort-eh_frame/Makefile

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// An `.eh_frame` section in an object file is a symptom of an UnwindAction::Terminate
2+
// being inserted, useful for determining whether or not unwinding is necessary.
3+
// This is useless when panics would NEVER unwind due to -C panic=abort. This section should
4+
// therefore never appear in the emit file of a -C panic=abort compilation, and this test
5+
// checks that this is respected.
6+
// See https://github.com/rust-lang/rust/pull/112403
7+
8+
// FIXME(Oneirical): try it on more than only-linux!
9+
10+
use run_make_support::{llvm_objdump, rustc};
11+
12+
fn main() {
13+
rustc()
14+
.input("foo.rs")
15+
.crate_type("lib")
16+
.emit("obj=foo.o")
17+
.panic("abort")
18+
.edition("2021")
19+
.arg("-Zvalidate-mir")
20+
.run();
21+
llvm_objdump().arg("--dwarf=frames").input("foo.o").run().assert_stdout_not_contains("DW_CFA");
22+
}

0 commit comments

Comments
 (0)
Failed to load comments.