Repository navigation
Move all tests under rust-tests to compiletest. #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -434,9 +434,14 @@ impl<'a> Builder<'a> { | |
| test::RustdocJson, | ||
| // Run bootstrap close to the end as it's unlikely to fail | ||
| test::Bootstrap, | ||
| // RMC regression tests | ||
| test::CBMC, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment here to mark the beginning of RMC tests?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
| test::Firecracker, | ||
| test::Prusti, | ||
| test::Serial, | ||
| test::SMACK, | ||
| // Run run-make last, since these won't pass without make on Windows | ||
| test::RunMake, | ||
| test::CBMC, | ||
| ), | ||
| Kind::Bench => describe!(test::Crate, test::CrateLibrustc), | ||
| Kind::Doc => describe!( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1123,6 +1123,14 @@ default_test!(Assembly { path: "src/test/assembly", mode: "assembly", suite: "as | |
|
|
||
| default_test!(CBMC { path: "src/test/cbmc", mode: "rmc", suite: "cbmc" }); | ||
|
|
||
| default_test!(Firecracker { path: "src/test/firecracker", mode: "rmc", suite: "firecracker" }); | ||
|
|
||
| default_test!(Prusti { path: "src/test/prusti", mode: "rmc", suite: "prusti" }); | ||
|
|
||
| default_test!(Serial { path: "src/test/serial", mode: "rmc", suite: "serial" }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know we are not running these at the moment, but do you know how much they would take to complete? |
||
|
|
||
| default_test!(SMACK { path: "src/test/smack", mode: "rmc", suite: "smack" }); | ||
|
|
||
| #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | ||
| struct Compiletest { | ||
| compiler: Compiler, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| // cbmc-flags: --unwind 10 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not for any reasonably small unwind value (I gave up at 1000). We might be able to add the flag if we set an upper bound to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see. This would be a good candidate for the RMC flag that allows you to opt-out from basic safety checks like |
||
|
|
||
| fn __nondet<T>() -> T { | ||
| unimplemented!() | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| // cbmc-flags: --unwind 11 --unwinding-assertions | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was not failing before because we had not included
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
|
|
||
| fn __nondet<T>() -> T { | ||
| unimplemented!() | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -396,6 +396,7 @@ impl<'test> TestCx<'test> { | |
| panic!("revision name must begin with rpass, rfail, or cfail"); | ||
| } | ||
| } | ||
| RMC => !self.testpaths.file.to_str().unwrap().contains("fail"), | ||
| mode => panic!("unimplemented for mode {:?}", mode), | ||
| } | ||
| } | ||
|
|
@@ -2382,19 +2383,30 @@ impl<'test> TestCx<'test> { | |
| } | ||
| } | ||
|
|
||
| /// Runs RMC on the test file specified by `self.testpaths.file`. | ||
| /// An error message is printed to stdout if verfication fails. | ||
| /// Runs RMC on the test file specified by `self.testpaths.file`. An error | ||
| /// message is printed to stdout if verification result is not expected. | ||
| fn run_rmc_test(&self) { | ||
| // Other modes call self.compile_test(...). However, we cannot call it here for two reasons: | ||
| // 1. It calls rustc instead of RMC | ||
| // 2. It may pass some options that do not make sense for RMC | ||
| // So we create our own command to execute RMC and pass it to self.compose_and_run_compiler(...) directly. | ||
| let mut rmc = Command::new("rmc"); | ||
| // Pass the test path along with RMC and CBMC flags parsed from comments at the top of the test file. | ||
| rmc.args(&self.props.rmc_flags) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a short comment about this arguments extension.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Please take a look. |
||
| .arg(&self.testpaths.file) | ||
| .arg("--") | ||
| .args(&self.props.cbmc_flags); | ||
| self.add_rmc_dir_to_path(&mut rmc); | ||
| rmc.arg(&self.testpaths.file); | ||
| let proc_res = self.compose_and_run_compiler(rmc, None); | ||
| if !proc_res.status.success() { | ||
| self.fatal_proc_rec("verification failed!", &proc_res); | ||
| // Print an error if the verification result is not expected. | ||
| if self.should_compile_successfully(self.pass_mode()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a short comment here too.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
| if !proc_res.status.success() { | ||
| self.fatal_proc_rec("test failed: expected success, got failure", &proc_res); | ||
| } | ||
| } else { | ||
| if proc_res.status.success() { | ||
| self.fatal_proc_rec("test failed: expected failure, got success", &proc_res); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯