-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure we run cargo with a nightly version
Also add support to the playback command and use a script to test the fix. Inside the Kani test folder, rustup will pick up the version from our toolchain configuration file.
- Loading branch information
Showing
10 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
set +e | ||
|
||
TMP_DIR="/tmp/build-rs" | ||
|
||
rm -rf ${TMP_DIR} | ||
cp -r . ${TMP_DIR} | ||
pushd ${TMP_DIR} > /dev/null | ||
|
||
|
||
echo "[TEST] Run verification..." | ||
cargo kani --concrete-playback=inplace -Z concrete-playback | ||
|
||
echo "[TEST] Run playback..." | ||
cargo kani playback -Z concrete-playback --lib -- check_kani | ||
|
||
echo "[TEST] Run test..." | ||
cargo test --lib | ||
|
||
# Cleanup | ||
popd > /dev/null | ||
rm -r ${TMP_DIR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
script: build_rs.sh | ||
expected: expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[TEST] Run verification... | ||
Checking harness verify::check_kani... | ||
Complete - 1 successfully verified harnesses, 0 failures, 1 total | ||
|
||
[TEST] Run playback... | ||
running 1 test\ | ||
test verify::kani_concrete_playback_check_kani_\ | ||
\ | ||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out | ||
|
||
[TEST] Run test... | ||
running 1 test\ | ||
test test::check_not_kani ... ok\ | ||
\ | ||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out | ||
|
8 changes: 5 additions & 3 deletions
8
...argo-kani/build-rs-conditional/src/lib.rs → ...based-pre/build-rs-conditional/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
//! This tests ensures that build scripts are able to conditionally check if they are running under | ||
//! Kani. | ||
//! Kani (in both verification and playback mode). | ||
|
||
#[cfg(kani)] | ||
mod verify { | ||
/// Running `cargo kani` should verify that "RUNNING_KANI" is equals to "Yes" | ||
#[kani::proof] | ||
fn check() { | ||
fn check_kani() { | ||
assert_eq!(env!("RUNNING_KANI"), "Yes"); | ||
// Add a dummy cover so playback generates a test that should succeed. | ||
kani::cover!(kani::any()); | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
/// Running `cargo test` should check that "RUNNING_KANI" is "No". | ||
#[test] | ||
fn check() { | ||
fn check_not_kani() { | ||
assert_eq!(env!("RUNNING_KANI"), "No"); | ||
} | ||
} |