@@ -77,6 +77,10 @@ TOML_FILE=${KANI_TOML_FILE:-$DEFAULT_TOML_FILE}
77
77
REPO_URL=${KANI_REPO_URL:- $DEFAULT_REPO_URL }
78
78
BRANCH_NAME=${KANI_BRANCH_NAME:- $DEFAULT_BRANCH_NAME }
79
79
80
+ # Kani list related variables, set in get_harnesses(); these are only used to parallelize harness verification
81
+ declare -a ALL_HARNESSES
82
+ declare -i HARNESS_COUNT
83
+
80
84
# Function to read commit ID from TOML file
81
85
read_commit_from_toml () {
82
86
local file=" $1 "
@@ -151,16 +155,17 @@ get_kani_path() {
151
155
echo " $( realpath " $build_dir /scripts/kani" ) "
152
156
}
153
157
158
+ # Run kani list with JSON format and process with jq to extract all harness names
159
+ # Note: This code is based on `kani list` JSON version 0.1 -- if the version changes, this logic may need to change as well.
154
160
get_harnesses () {
155
161
local kani_path=" $1 "
156
- # Run kani list with JSON format and process with jq to extract all harness names
157
- # Note: This code is based on `kani list` JSON version 0.1 -- if the version changes, this logic may need to change as well.
158
- " $kani_path " list -Z list -Z function-contracts -Z mem-predicates -Z float-lib -Z c-ffi ./library --std --format json \
159
- jq -r '
162
+ " $kani_path " list -Z list -Z function-contracts -Z mem-predicates -Z float-lib -Z c-ffi ./library --std --format json
163
+ ALL_HARNESSES=($( jq -r '
160
164
([.["standard-harnesses"] | to_entries | .[] | .value[]] +
161
- [.["contract-harnesses"] | to_entries | .[] | .value[]]) |
165
+ [.["contract-harnesses"] | to_entries | .[] | .value[]]) |
162
166
.[]
163
- '
167
+ ' $WORK_DIR /kani-list.json) )
168
+ HARNESS_COUNT=${# ALL_HARNESSES[@]}
164
169
}
165
170
166
171
run_verification_subset () {
@@ -180,7 +185,7 @@ run_verification_subset() {
180
185
-Z loop-contracts \
181
186
-Z float-lib \
182
187
-Z c-ffi \
183
- $harness_args -- exact \
188
+ $harness_args --exact \
184
189
$command_args \
185
190
--enable-unstable \
186
191
--cbmc-args --object-bits 12
@@ -239,19 +244,16 @@ main() {
239
244
if [[ " $run_command " == " verify-std" ]]; then
240
245
if [[ -n " $PARALLEL_INDEX " && -n " $PARALLEL_TOTAL " ]]; then
241
246
echo " Running as parallel worker $PARALLEL_INDEX of $PARALLEL_TOTAL "
242
-
243
- # Get all harnesses
244
- readarray -t all_harnesses < <( get_harnesses " $kani_path " )
245
- total_harnesses=${# all_harnesses[@]}
247
+ get_harnesses " $kani_path "
246
248
247
249
# Calculate this worker's portion
248
- chunk_size=$(( (total_harnesses + PARALLEL_TOTAL - 1 ) / PARALLEL_TOTAL ))
250
+ chunk_size=$(( (HARNESS_COUNT + PARALLEL_TOTAL - 1 ) / PARALLEL_TOTAL ))
249
251
start_idx=$(( (PARALLEL_INDEX - 1 ) * chunk_size ))
250
252
end_idx=$(( start_idx + chunk_size ))
251
- [[ $end_idx -gt $total_harnesses ]] && end_idx=$total_harnesses
253
+ [[ $end_idx -gt $HARNESS_COUNT ]] && end_idx=$HARNESS_COUNT
252
254
253
255
# Extract this worker's harnesses
254
- worker_harnesses=(" ${all_harnesses [@]: $start_idx : $chunk_size } " )
256
+ worker_harnesses=(" ${ALL_HARNESSES [@]: $start_idx : $chunk_size } " )
255
257
256
258
# Run verification for this subset
257
259
run_verification_subset " $kani_path " " ${worker_harnesses[@]} "
0 commit comments