generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 142
Enable Concrete Playback Unit tests to run with --cfg kani
#2353
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
Merged
jaisnan
merged 22 commits into
model-checking:main
from
jaisnan:Fix-concrete-playback-cfg-kani
Apr 7, 2023
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a160eed
Generate unit test, line by line
jaisnan 0168917
clippy changes
jaisnan 964c22e
add tempfile dependency
jaisnan 7d749bf
Merge branch 'main' of https://github.com/model-checking/kani into main
jaisnan aa83942
Merge branch 'main' of https://github.com/model-checking/kani into main
jaisnan 16c2400
Merge branch 'main' of https://github.com/model-checking/kani into main
jaisnan de833b3
Merge branch 'main' of https://github.com/model-checking/kani into main
jaisnan d51294e
Add concrete_playback feature to kani_macros
jaisnan 47e48f2
Merge branch 'main' of https://github.com/model-checking/kani into Fi…
jaisnan 6c59f18
Add regression test
jaisnan d61f6ab
Merge branch 'main' of https://github.com/model-checking/kani into Fi…
jaisnan bc3671a
Delete accidental changes
jaisnan 4ae20a3
Add copyright strings
jaisnan 3429b9e
Fix cargo.toml
jaisnan c728dc3
Remove logging in CI test
jaisnan d1ddd11
Add nightly from toolchain file
jaisnan f43e284
Fix diff error in CI
jaisnan c111570
Remove time from expected
jaisnan 223b9a8
Address comments
jaisnan 8899012
Merge branch 'main' into Fix-concrete-playback-cfg-kani
jaisnan 1c5c5b7
Update tests/script-based-pre/playback_with_cfg_kani/sample_crate/src…
jaisnan 3d3f1fb
Merge branch 'main' into Fix-concrete-playback-cfg-kani
jaisnan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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_with_cfg_kani.sh | ||
| expected: playback_with_cfg_kani.expected |
4 changes: 4 additions & 0 deletions
4
tests/script-based-pre/playback_with_cfg_kani/playback_with_cfg_kani.expected
This file contains hidden or 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 @@ | ||
| failures: | ||
| harnesses::kani_concrete_playback_harness_15598097466099501582 | ||
|
|
||
| test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; |
34 changes: 34 additions & 0 deletions
34
tests/script-based-pre/playback_with_cfg_kani/playback_with_cfg_kani.sh
This file contains hidden or 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,34 @@ | ||
| #!/usr/bin/env bash | ||
| # Copyright Kani Contributors | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| set +e | ||
|
|
||
| OUT_DIR=sample_crate/target | ||
|
|
||
| echo | ||
| echo "Starting output file check..." | ||
| echo | ||
|
|
||
|
|
||
| # Check if cargo is installed | ||
| if ! command -v cargo &> /dev/null; then | ||
| echo "cargo command not found. Please install Rust and Cargo." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Running cargo test on the unit test ..." | ||
| echo | ||
|
|
||
| cd sample_crate/ | ||
|
|
||
| output=$(grep 'channel = ' ../../../../rust-toolchain.toml | cut -d '"' -f 2) | ||
| echo "$output" | ||
|
|
||
| # Run cargo test on the unit test | ||
| RUSTFLAGS="--cfg=kani" cargo +${output} test 2>/dev/null | ||
|
|
||
| cd .. | ||
|
|
||
| # Try to leave a clean output folder at the end | ||
| rm -rf ${OUT_DIR} |
13 changes: 13 additions & 0 deletions
13
tests/script-based-pre/playback_with_cfg_kani/sample_crate/Cargo.toml
This file contains hidden or 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,13 @@ | ||
| # Copyright Kani Contributors | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| [package] | ||
| name = "sample_crate" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
|
|
||
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
|
||
| [dependencies] | ||
|
|
||
| [dev-dependencies] | ||
| kani = { path = "../../../../library/kani", features = ["concrete_playback"] } |
33 changes: 33 additions & 0 deletions
33
tests/script-based-pre/playback_with_cfg_kani/sample_crate/src/main.rs
This file contains hidden or 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,33 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| // This test checks that running the unit test generated using the concrete playback feature | ||
| // with `RUSTFLAGS="--cfg=kani" cargo +nightly test doesn't cause a compilation error. | ||
| // There is an existing UI test to generate the unit test itself (in kani/tests/ui/concrete-playback/result). | ||
|
|
||
| fn main() {} | ||
|
|
||
| #[cfg(kani)] | ||
| mod harnesses { | ||
| #[kani::proof] | ||
| fn harness() { | ||
| let result_1: Result<u8, u8> = kani::any(); | ||
| let result_2: Result<u8, u8> = kani::any(); | ||
| assert!(!(result_1 == Ok(101) && result_2 == Err(102))); | ||
| } | ||
|
|
||
| #[test] | ||
| fn kani_concrete_playback_harness_15598097466099501582() { | ||
| let concrete_vals: Vec<Vec<u8>> = vec![ | ||
| // 1 | ||
| vec![1], | ||
| // 101 | ||
| vec![101], | ||
| // 0 | ||
| vec![0], | ||
| // 102 | ||
| vec![102], | ||
| ]; | ||
| kani::concrete_playback_run(concrete_vals, harness); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.