-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test + fix small formatting with harness runner
- Loading branch information
1 parent
78733a0
commit c86ff09
Showing
5 changed files
with
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
script: individual_file_output.sh |
46 changes: 46 additions & 0 deletions
46
tests/script-based-pre/individual_file_output/individual_file_output.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,46 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
set +e | ||
|
||
OUT_DIR=tmp_sample_crate | ||
|
||
# Ensure output folder is clean | ||
rm -rf ${OUT_DIR} | ||
|
||
# Move the original source to the output folder since it will be modified | ||
cp -r sample_crate ${OUT_DIR} | ||
pushd $OUT_DIR | ||
|
||
echo "Run verification..." | ||
../../../../scripts/cargo-kani -Z unstable-options --output-into-files | ||
|
||
OUTPUT_DIR="kani_results" | ||
|
||
# Check if the output directory exists | ||
if [ ! -d "$OUTPUT_DIR" ]; then | ||
echo "Output directory $OUT_DIR/$OUTPUT_DIR does not exist. Verification failed." | ||
exit 1 | ||
fi | ||
|
||
# Check if there are any files in the output directory | ||
output_files=("$OUTPUT_DIR"/*) | ||
|
||
if [ ${#output_files[@]} -eq 0 ]; then | ||
echo "No files found in the output directory. Verification failed." | ||
exit 1 | ||
fi | ||
|
||
# Check if each file contains text | ||
for file in "${output_files[@]}"; do | ||
if [ ! -s "$file" ]; then | ||
echo "File $file is empty. Verification failed." | ||
exit 1 | ||
else | ||
echo "File $file is present and contains text." | ||
fi | ||
done | ||
|
||
popd | ||
rm -rf ${OUT_DIR} |
15 changes: 15 additions & 0 deletions
15
tests/script-based-pre/individual_file_output/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,15 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
[package] | ||
name = "sample_crate" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[package.metadata.kani.flags] | ||
concrete-playback = "inplace" | ||
|
||
[package.metadata.kani.unstable] | ||
concrete-playback = true | ||
|
||
[lints.rust] | ||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kani)'] } |
19 changes: 19 additions & 0 deletions
19
tests/script-based-pre/individual_file_output/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,19 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
//! This test checks that we can correctly generate tests from a cover statement and run them. | ||
|
||
#[cfg(kani)] | ||
mod verify { | ||
#[kani::proof] | ||
fn any_is_ok() { | ||
let result: Result<char, bool> = kani::any(); | ||
kani::cover!(result.is_ok()); | ||
} | ||
|
||
#[kani::proof] | ||
fn any_is_err() { | ||
let result: Result<char, bool> = kani::any(); | ||
kani::cover!(result.is_err()); | ||
} | ||
} |