-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Harness output individual files (#3360)
Resolves #3356 1. Changes allow for directory with individual output of files named by the full harness name. --output-into-files command line argument will allow for placing all output of individual harnesses into files named by the full harness pretty_name. The output directory is either --target-dir or a hard coded default: "kani_output" directory. (These can be changed if there is a better interface). Still prints output to std::out exactly as previous. 2. Previously, all output was placed into std::out. This will allow for some control over output. It will also enable easier parsing of harness output. 3. Only solved #3356 but could be expanded to include more features. 4. Ran manually to check the flags and output behaved as expected. Indeed: --output-into-files enabled will place output into individual files, disabled will not --output-terse will create terse output to command line, regular output to individual files if --output-into-files is enabled. --target-dir will place output into target-dir directory when --output-into-files is enabled, and will not place file output when disabled. Let me know if you need specific explanations of code segments, a clean list of all the testing configurations, or any feature enhancement for greater configuration options. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Alexander Aghili <[email protected]> Co-authored-by: Jaisurya Nanduri <[email protected]> Co-authored-by: Celina G. Val <[email protected]>
- Loading branch information
1 parent
568de5e
commit edec4dc
Showing
7 changed files
with
143 additions
and
9 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 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..." | ||
cargo kani -Z unstable-options --output-into-files | ||
|
||
OUTPUT_DIR="result_output_dir" | ||
|
||
# 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()); | ||
} | ||
} |