Skip to content

Commit 8e40f4b

Browse files
ywxtSparrowLii
andcommitted
Add the parallel front-end test suit
Co-authored-by: SparrowLii <[email protected]>
1 parent 3014e79 commit 8e40f4b

33 files changed

+690
-72
lines changed

rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ignore = [
1818
"/tests/crashes/", # Many of these tests contain syntax errors.
1919
"/tests/debuginfo/", # These tests are somewhat sensitive to source code layout.
2020
"/tests/incremental/", # These tests are somewhat sensitive to source code layout.
21+
"/tests/parallel/", # Some have syntax errors.
2122
"/tests/pretty/", # These tests are very sensitive to source code layout.
2223
"/tests/run-make/export", # These tests contain syntax errors.
2324
"/tests/run-make/translation/test.rs", # This test contains syntax errors.

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,8 @@ test!(RustdocJson {
14011401
only_hosts: true,
14021402
});
14031403

1404+
test!(Parallel { path: "tests/parallel", mode: "parallel", suite: "parallel", default: true });
1405+
14041406
test!(Pretty {
14051407
path: "tests/pretty",
14061408
mode: "pretty",

src/bootstrap/src/core/builder/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ impl<'a> Builder<'a> {
10541054
test::UiFullDeps,
10551055
test::Rustdoc,
10561056
test::CoverageRunRustdoc,
1057+
test::Parallel,
10571058
test::Pretty,
10581059
test::CodegenCranelift,
10591060
test::CodegenGCC,

src/tools/compiletest/src/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ string_enum! {
3030
CoverageMap => "coverage-map",
3131
CoverageRun => "coverage-run",
3232
Crashes => "crashes",
33+
Parallel => "parallel",
3334
}
3435
}
3536

@@ -66,6 +67,7 @@ string_enum! {
6667
Debuginfo => "debuginfo",
6768
Incremental => "incremental",
6869
MirOpt => "mir-opt",
70+
Parallel => "parallel",
6971
Pretty => "pretty",
7072
RunMake => "run-make",
7173
Rustdoc => "rustdoc",

src/tools/compiletest/src/directives.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ pub struct TestProps {
150150
// empty before the test starts. Incremental mode tests will reuse the
151151
// incremental directory between passes in the same test.
152152
pub incremental: bool,
153+
// Number of times to run the test, for the parallel front-end test suit.
154+
// Repeat tests to ensure no ICEs occur.
155+
pub iteration_count: Option<usize>,
153156
// If `true`, this test is a known bug.
154157
//
155158
// When set, some requirements are relaxed. Currently, this only means no
@@ -238,6 +241,7 @@ mod directives {
238241
pub const ASSEMBLY_OUTPUT: &'static str = "assembly-output";
239242
pub const STDERR_PER_BITWIDTH: &'static str = "stderr-per-bitwidth";
240243
pub const INCREMENTAL: &'static str = "incremental";
244+
pub const ITERATION_COUNT: &'static str = "iteration-count";
241245
pub const KNOWN_BUG: &'static str = "known-bug";
242246
pub const TEST_MIR_PASS: &'static str = "test-mir-pass";
243247
pub const REMAP_SRC_BASE: &'static str = "remap-src-base";
@@ -280,6 +284,7 @@ impl TestProps {
280284
forbid_output: vec![],
281285
incremental_dir: None,
282286
incremental: false,
287+
iteration_count: None,
283288
known_bug: false,
284289
pass_mode: None,
285290
fail_mode: None,
@@ -540,6 +545,16 @@ impl TestProps {
540545
&mut self.stderr_per_bitwidth,
541546
);
542547
config.set_name_directive(ln, INCREMENTAL, &mut self.incremental);
548+
config.set_name_value_directive(
549+
ln,
550+
ITERATION_COUNT,
551+
&mut self.iteration_count,
552+
|s| {
553+
s.trim()
554+
.parse()
555+
.expect("The value of iteration-count must be a positive integer.")
556+
},
557+
);
543558

544559
// Unlike the other `name_value_directive`s this needs to be handled manually,
545560
// because it sets a `bool` flag.
@@ -892,6 +907,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
892907
"ignore-x86_64-pc-windows-gnu",
893908
"ignore-x86_64-unknown-linux-gnu",
894909
"incremental",
910+
"iteration-count",
895911
"known-bug",
896912
"llvm-cov-flags",
897913
"max-llvm-major-version",

src/tools/compiletest/src/runtest.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ mod debuginfo;
4141
mod incremental;
4242
mod js_doc;
4343
mod mir_opt;
44+
mod parallel;
4445
mod pretty;
4546
mod run_make;
4647
mod rustdoc;
@@ -272,6 +273,7 @@ impl<'test> TestCx<'test> {
272273
TestMode::CoverageMap => self.run_coverage_map_test(), // see self::coverage
273274
TestMode::CoverageRun => self.run_coverage_run_test(), // see self::coverage
274275
TestMode::Crashes => self.run_crash_test(),
276+
TestMode::Parallel => self.run_parallel_test(),
275277
}
276278
}
277279

@@ -1518,8 +1520,10 @@ impl<'test> TestCx<'test> {
15181520
};
15191521
rustc.arg(input_file);
15201522

1521-
// Use a single thread for efficiency and a deterministic error message order
1522-
rustc.arg("-Zthreads=1");
1523+
if self.config.mode != TestMode::Parallel {
1524+
// Use a single thread for efficiency and a deterministic error message order
1525+
rustc.arg("-Zthreads=1");
1526+
}
15231527

15241528
// Hide libstd sources from ui tests to make sure we generate the stderr
15251529
// output that users will see.
@@ -1705,7 +1709,8 @@ impl<'test> TestCx<'test> {
17051709
| TestMode::Rustdoc
17061710
| TestMode::RustdocJson
17071711
| TestMode::RunMake
1708-
| TestMode::RustdocJs => {
1712+
| TestMode::RustdocJs
1713+
| TestMode::Parallel => {
17091714
// do not use JSON output
17101715
}
17111716
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use crate::runtest::{TestCx, WillExecute};
2+
3+
impl TestCx<'_> {
4+
pub(super) fn run_parallel_test(&self) {
5+
let pm = self.pass_mode();
6+
let emit_metadata = self.should_emit_metadata(pm);
7+
8+
// Repeated testing due to instability in multithreaded environments.
9+
let iteration_count = self.props.iteration_count.unwrap_or(50);
10+
for _ in 0..iteration_count {
11+
let proc_res = self.compile_test(WillExecute::No, emit_metadata);
12+
// Ensure there is no ICE during parallel complication.
13+
self.check_no_compiler_crash(&proc_res, false);
14+
}
15+
}
16+
}

src/tools/opt-dist/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ llvm-config = "{llvm_config}"
105105
"tests/codegen-units",
106106
"tests/incremental",
107107
"tests/mir-opt",
108+
"tests/parallel",
108109
"tests/pretty",
109110
// Make sure that we don't use too new GLIBC symbols on x64
110111
"tests/run-make/glibc-symbols-x86_64-unknown-linux-gnu",

tests/parallel/SUMMARY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This directory contains the robustness test for prallel front end, which means deadlocks
2+
and other ice bugs. In other words, we don't care whether the compiler output in these tests,
3+
but whether they can compile normally without deadlock or other ice bugs.
4+
5+
So when a test in this directory fails, please pay attention to whether it causes any ice problems.
6+
If so(it should do), please post your comments in the issue corresponding to each test (or create a new issue
7+
with the `wg-parallel-rustc` label). Even if it is an existing issue, please add a new comment,
8+
which will help us determine the reproducibility of the bug.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Test for #111528, the ice issue cause waiting on a query that panicked
2+
//
3+
//@ compile-flags: -Z threads=16
4+
5+
#![crate_type = "rlib"]
6+
#![allow(warnings)]
7+
8+
#[export_name = "fail"]
9+
pub fn a() {}
10+
11+
#[export_name = "fail"]
12+
pub fn b() {}
13+
14+
fn main() {}

0 commit comments

Comments
 (0)