Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/esbmc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ jobs:

# Step 2: Generate contracts programs
- name: Generate contracts
run: ./scripts/run-kani.sh --kani-args --keep-temps --only-codegen --target-dir kani/contracts
id: contracts
run: |
target_dir=$(mktemp -d "$RUNNER_TEMP/kani-contracts.XXXXXX")
./scripts/run-kani.sh --kani-args --keep-temps --only-codegen --target-dir "$target_dir"
echo "target-dir=$target_dir" >> "$GITHUB_OUTPUT"

# Step 3: Run ESBMC on the GOTO binaries Kani generated
- name: Run ESBMC
run: ./scripts/run-esbmc.sh kani/contracts checked_unchecked.*.out
env:
CONTRACT_TARGET_DIR: ${{ steps.contracts.outputs.target-dir }}
run: ./scripts/run-esbmc.sh "$CONTRACT_TARGET_DIR" 'checked_unchecked.*\.out$'
30 changes: 13 additions & 17 deletions scripts/run-esbmc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ unsupported_regex=neg
esbmc_url=https://github.com/esbmc/esbmc/releases/download/v8.7/esbmc-linux.zip
esbmc=esbmc/release/bin/esbmc

contract_folder=$target/deps
# Cargo 1.99+ gives each package its own debug/build/PKG/HASH/out/ and no longer creates debug/deps.
if [ ! -d "$contract_folder" ]; then
contract_folder=$(find "$target/build" -path '*/out/*.out' | grep "$supported_regex" | head -n 1 | xargs -r dirname)
fi
if [ -z "$contract_folder" ]; then
echo "No contract programs matching '$supported_regex' under $target"
if [ ! -d "$target" ]; then
echo "Kani build directory not found: $target" >&2
exit 1
fi

Expand All @@ -38,24 +33,25 @@ if [ ! -x "$esbmc" ]; then
fi

checked=0
ls $contract_folder | grep "$supported_regex" | grep -v .symtab.out > _contracts.txt

while IFS= read -r line; do
# I expect each line to be similar to 'core-58cefd8dce4133f9__RNvNtNtCs9uKEoH8KKW4_4core3num6verify24checked_unchecked_add_i8.out'
shopt -s nullglob
# Cargo may place contracts in debug/deps or per-package debug/build/PKG/HASH/out directories.
for binary in "$target"/deps/*.out "$target"/build/*/*/out/*.out; do
name=${binary##*/}
[[ $name != *.symtab.out ]] || continue
grep -q -- "$supported_regex" <<< "$name" || continue
# A file name looks like 'core-58cefd8dce4133f9__RNvNtNtCs9uKEoH8KKW4_4core3num6verify24checked_unchecked_add_i8.out'.
# The entrypoint of the contract would be _RNvNtNtCs9uKEoH8KKW4_4core3num6verify24checked_unchecked_add_i8
[[ $line =~ (_RNv.*)\.out$ ]] || continue
[[ $name =~ (_RNv.*)\.out$ ]] || continue
contract=${BASH_REMATCH[1]}
if echo "$contract" | grep -q "$unsupported_regex"; then
if [[ $contract =~ $unsupported_regex ]]; then
continue
fi
echo "Processing: $contract"
# A failed reachability_check or cover means "reachable" or "satisfiable", not a bug.
$esbmc --binary $contract_folder/$line --function $contract \
"$esbmc" --binary "$binary" --function "$contract" \
--ignore-property-class reachability_check --ignore-property-class cover < /dev/null
checked=$((checked + 1))
done < "_contracts.txt"

rm "_contracts.txt"
done

if [ "$checked" -eq 0 ]; then
echo "No contract matching '$supported_regex' was checked"
Expand Down
Loading