Skip to content

Commit 9c92a78

Browse files
adpaco-awstedinski
authored andcommitted
Suite for "fixme" tests (rust-lang#660)
* Enable `rmc-fixme` suite in `compiletest` * Add "rmc-fixme" suite to regular regression
1 parent 6d2f28a commit 9c92a78

File tree

12 files changed

+30
-7
lines changed

12 files changed

+30
-7
lines changed

scripts/rmc-regression.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ check-cbmc-viewer-version.py --major 2 --minor 5
2525
./scripts/setup/build_rmc_lib.sh
2626

2727
# Standalone rmc tests, expected tests, and cargo tests
28-
./x.py test -i --stage 1 rmc firecracker prusti smack expected cargo-rmc rmc-docs
28+
./x.py test -i --stage 1 rmc firecracker prusti smack expected cargo-rmc rmc-docs rmc-fixme
2929
./x.py test -i --stage 0 compiler/cbmc
3030

3131
# Check codegen for the standard library

src/bootstrap/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ impl<'a> Builder<'a> {
474474
test::Dashboard,
475475
test::Stub,
476476
test::RmcDocs,
477+
test::RmcFixme,
477478
// Run run-make last, since these won't pass without make on Windows
478479
test::RunMake,
479480
),

src/bootstrap/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,8 @@ default_test!(Dashboard { path: "src/test/dashboard", mode: "rmc", suite: "dashb
12311231

12321232
default_test!(RmcDocs { path: "src/test/rmc-docs", mode: "rmc", suite: "rmc-docs" });
12331233

1234+
default_test!(RmcFixme { path: "src/test/rmc-fixme", mode: "rmc-fixme", suite: "rmc-fixme" });
1235+
12341236
default_test!(Stub { path: "src/test/stub-tests", mode: "stub-tests", suite: "stub-tests" });
12351237

12361238
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/test/rmc-fixme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rmc

src/test/rmc/Strings/fixme_boxed_str.rs renamed to src/test/rmc/Strings/boxed_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3-
// Fails with a type safety error - see TODO in rvalue.rs::codegen_misc_cast()
3+
44
fn main() {
55
let s = String::from("hello");
66
let _b = s.into_boxed_str();

src/test/rmc/Strings/fixme_main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ fn test2() {
66
assert!(s.chars().nth(1) == Some('o'));
77
}
88

9-
/// Runs forever
109
fn test3() {
1110
let s: &str = &("f".to_string() + "o");
1211
assert!(s.len() == 2);
@@ -20,7 +19,7 @@ fn test4() {
2019

2120
unsafe {
2221
assert!(!ptr.is_null());
23-
//assert!(*ptr.offset(1) as char == '2'); // u8 to char not handled yet
22+
assert!(*ptr.offset(1) as char == '2'); // u8 to char not handled yet
2423
}
2524
}
2625
fn main() {
File renamed without changes.

src/test/rmc/Vectors/fixme_main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// rmc-flags: --unwind 0
34
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)]
45
pub struct GuestAddress(pub u64);
56

src/tools/compiletest/src/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub enum Mode {
2424
MirOpt,
2525
Assembly,
2626
RMC,
27+
RmcFixme,
2728
CargoRMC,
2829
Expected,
2930
Stub,
@@ -58,6 +59,7 @@ impl FromStr for Mode {
5859
"mir-opt" => Ok(MirOpt),
5960
"assembly" => Ok(Assembly),
6061
"rmc" => Ok(RMC),
62+
"rmc-fixme" => Ok(RmcFixme),
6163
"cargo-rmc" => Ok(CargoRMC),
6264
"expected" => Ok(Expected),
6365
"stub-tests" => Ok(Stub),
@@ -83,6 +85,7 @@ impl fmt::Display for Mode {
8385
MirOpt => "mir-opt",
8486
Assembly => "assembly",
8587
RMC => "rmc",
88+
RmcFixme => "rmc-fixme",
8689
CargoRMC => "cargo-rmc",
8790
Expected => "expected",
8891
Stub => "stub-tests",

src/tools/compiletest/src/header.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,21 @@ pub fn make_test_description<R: Read>(
953953
ignore |= file_path.contains("fixme") || file_path.contains("ignore");
954954
}
955955

956+
// The `RmcFixme` mode runs tests that are ignored in the `rmc` suite
957+
if config.mode == Mode::RmcFixme {
958+
let file_path = path.to_str().unwrap();
959+
960+
// `file_path` is going to be `src/test/rmc-fixme/...` so we
961+
// need to extract the base name if we want to ignore it
962+
let test_name: Vec<&str> = file_path.rsplit('/').collect();
963+
let base_name = test_name[0];
964+
965+
// If the base name does NOT contain "fixme" or "ignore", we skip it.
966+
// All "fixme" tests are expected to fail
967+
ignore |= !(base_name.contains("fixme") || base_name.contains("ignore"));
968+
should_fail = true;
969+
}
970+
956971
iter_header(path, src, &mut |revision, ln| {
957972
if revision.is_some() && revision != cfg {
958973
return;

src/tools/compiletest/src/runtest.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::common::{
55
};
66
use crate::common::{incremental_dir, output_base_dir, output_base_name, output_testname_unique};
77
use crate::common::{
8-
Assembly, CargoRMC, Expected, Incremental, JsDocTest, MirOpt, RunMake, RustdocJson, Stub, Ui,
9-
RMC,
8+
Assembly, CargoRMC, Expected, Incremental, JsDocTest, MirOpt, RmcFixme, RunMake, RustdocJson,
9+
Stub, Ui, RMC,
1010
};
1111
use crate::common::{Codegen, CodegenUnits, DebugInfo, Debugger, Rustdoc};
1212
use crate::common::{CompareMode, FailMode, PassMode};
@@ -255,6 +255,7 @@ impl<'test> TestCx<'test> {
255255
Assembly => self.run_assembly_test(),
256256
JsDocTest => self.run_js_doc_test(),
257257
RMC => self.run_rmc_test(),
258+
RmcFixme => self.run_rmc_test(),
258259
CargoRMC => self.run_cargo_rmc_test(),
259260
Expected => self.run_expected_test(),
260261
Stub => self.run_stub_test(),
@@ -1843,7 +1844,7 @@ impl<'test> TestCx<'test> {
18431844
rustc.arg(dir_opt);
18441845
}
18451846
RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson | RunMake
1846-
| CodegenUnits | JsDocTest | Assembly | RMC | CargoRMC | Expected | Stub => {
1847+
| CodegenUnits | JsDocTest | Assembly | RMC | RmcFixme | CargoRMC | Expected | Stub => {
18471848
// do not use JSON output
18481849
}
18491850
}

0 commit comments

Comments
 (0)