Skip to content

Commit 031d51b

Browse files
committed
kani list workflow step
1 parent bd56a76 commit 031d51b

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

.github/workflows/kani.yml

+10
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ jobs:
6565
- name: Test Kani script (In Repo Directory)
6666
working-directory: ${{github.workspace}}/head
6767
run: scripts/run-kani.sh --kani-args --harness ptr::verify::check_read_u128 --harness ptr --output-format=terse
68+
69+
# Step 3: Run list on the std library (assumes it creates kani_list.txt)
70+
- name: Run Kani List
71+
uses: actions/github-script@v6
72+
with:
73+
script: |
74+
head/scripts/run-kani.sh --run list --path ${{github.workspace}}/head;
75+
const fs = require('fs');
76+
const kaniOutput = fs.readFileSync('${{github.workspace}}/head/kani_list.txt', 'utf8');
77+
kaniOutput >> "$GITHUB_STEP_SUMMARY";

scripts/run-kani.sh

+21-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
set -e
44

55
usage() {
6-
echo "Usage: $0 [options] [-p <path>] [--kani-args <command arguments>]"
6+
echo "Usage: $0 [options] [-p <path>] [--run <verify-std|list>] [--kani-args <command arguments>]"
77
echo "Options:"
88
echo " -h, --help Show this help message"
99
echo " -p, --path <path> Optional: Specify a path to a copy of the std library. For example, if you want to run the script from an outside directory."
10+
echo " --run <verify-std|list> Optional: Specify whether to run 'verify-std' or 'list' command. Defaults to 'verify-std' if not specified."
1011
echo " --kani-args <command arguments to kani> Optional: Arguments to pass to the command. Simply pass them in the same way you would to the Kani binary. This should be the last argument."
1112
exit 1
1213
}
1314

1415
# Initialize variables
1516
command_args=""
1617
path=""
18+
run_command="verify-std"
1719

1820
# Parse command line arguments
1921
# TODO: Improve parsing with getopts
@@ -31,13 +33,23 @@ while [[ $# -gt 0 ]]; do
3133
usage
3234
fi
3335
;;
36+
--run)
37+
if [[ -n $2 && ($2 == "verify-std" || $2 == "list") ]]; then
38+
run_command=$2
39+
shift 2
40+
else
41+
echo "Error: Invalid run command. Must be 'verify-std' or 'list'."
42+
usage
43+
fi
44+
;;
3445
--kani-args)
3546
shift
3647
command_args="$@"
3748
break
3849
;;
3950
*)
40-
break
51+
echo "Error: Unknown option $1"
52+
usage
4153
;;
4254
esac
4355
done
@@ -181,9 +193,13 @@ main() {
181193
echo "Running Kani command..."
182194
"$kani_path" --version
183195

184-
echo "Running Kani verify-std command..."
185-
186-
"$kani_path" verify-std -Z unstable-options ./library --target-dir "$temp_dir_target" -Z function-contracts -Z mem-predicates --output-format=terse $command_args
196+
if [[ "$run_command" == "verify-std" ]]; then
197+
echo "Running Kani verify-std command..."
198+
"$kani_path" verify-std -Z unstable-options ./library --target-dir "$temp_dir_target" -Z function-contracts -Z mem-predicates --output-format=terse $command_args
199+
elif [[ "$run_command" == "list" ]]; then
200+
echo "Running Kani list command..."
201+
"$kani_path" list -Z list -Z function-contracts -Z mem-predicates ./library --std > $path/kani_list.txt
202+
fi
187203
}
188204

189205
main

0 commit comments

Comments
 (0)