-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
423 additions
and
87 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
Large diffs are not rendered by default.
Oops, something went wrong.
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: playback_target.sh | ||
expected: playback_target.expected |
9 changes: 9 additions & 0 deletions
9
tests/script-based-pre/cargo_playback_array/playback_target.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,9 @@ | ||
Failed Checks: index out of bounds: the length is less than or equal to the given index | ||
|
||
VERIFICATION:- FAILED | ||
|
||
INFO: Now modifying the source code to include the concrete playback unit test: | ||
|
||
running 1 test | ||
|
||
index out of bounds: the len is 65 but the index is |
27 changes: 27 additions & 0 deletions
27
tests/script-based-pre/cargo_playback_array/playback_target.sh
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,27 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
set +e | ||
|
||
function check_playback { | ||
local OUTPUT=output.log | ||
cargo kani playback "${@}" >& $OUTPUT | ||
# Sort output so we can rely on the order. | ||
echo "$(grep "test verify::.* ok" $OUTPUT | sort)" | ||
echo | ||
echo "======= Raw Output =======" | ||
cat $OUTPUT | ||
echo "==========================" | ||
echo | ||
rm $OUTPUT | ||
} | ||
|
||
pushd sample_crate > /dev/null | ||
cargo clean | ||
|
||
cargo kani --concrete-playback inplace -Z concrete-playback | ||
check_playback -Z concrete-playback | ||
|
||
cargo clean | ||
popd > /dev/null |
10 changes: 10 additions & 0 deletions
10
tests/script-based-pre/cargo_playback_array/sample_crate/Cargo.toml
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,10 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
[package] | ||
name = "sample_crate" | ||
version = "0.1.0" | ||
edition = "2021" | ||
doctest = false | ||
|
||
[lints.rust] | ||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kani)'] } |
16 changes: 16 additions & 0 deletions
16
tests/script-based-pre/cargo_playback_array/sample_crate/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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
//! Test that concrete playback generates concrete values for arrays over the length of 64 | ||
//! and that playback can run those tests and find the index out of bounds bug, | ||
//! c.f. https://github.com/model-checking/kani/issues/3787 | ||
#[cfg(kani)] | ||
mod verify { | ||
#[kani::proof] | ||
fn index_array_65() { | ||
let arr: [u16; 65] = kani::any(); | ||
let idx: usize = kani::any(); | ||
arr[idx]; | ||
} | ||
} |
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