Skip to content

Commit 02764e1

Browse files
Yoshiki TakashimaYoshiki Takashimaadpaco-aws
authored
PropProof integration (#19)
Co-authored-by: Yoshiki Takashima <[email protected]> Co-authored-by: Adrian Palacios <[email protected]>
1 parent 8b10534 commit 02764e1

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

.github/workflows/test-action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ jobs:
1616
uses: ./ # Uses the action in the root directory
1717
with:
1818
working-directory: tests/cargo-kani/simple-lib
19+
- name: Test ProfProof within Kani Action
20+
uses: ./
21+
with:
22+
working-directory: tests/cargo-kani/proptest-lib
23+
args: --tests
24+
enable-propproof: true

action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
description: 'Arguments to pass to kani.'
2323
required: false
2424
default: ''
25+
enable-propproof:
26+
description: 'Experimental: Allow Kani to verify proptest harnesses using the PropProof feature'
27+
required: false
28+
default: false
2529

2630
runs:
2731
using: "composite"
@@ -42,6 +46,17 @@ runs:
4246
cargo install --version $KANI_VERSION --locked kani-verifier;
4347
cargo-kani setup;
4448
49+
- name: Install PropProof
50+
if: ${{ inputs.enable-propproof }}
51+
shell: bash
52+
run: |
53+
export PROPPROOF_PATH=$HOME/propproof
54+
git clone https://github.com/model-checking/kani \
55+
--branch features/proptest $PROPPROOF_PATH || true
56+
git -C $PROPPROOF_PATH submodule update --init --recursive
57+
echo "paths = [\"$PROPPROOF_PATH\"]" > $HOME/.cargo/config.toml
58+
# || true is used to handle cases where the propproof folder is cached.
59+
4560
- name: Run Kani
4661
shell: bash
4762
run: |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
[package]
4+
name = "proptest-lib"
5+
version = "0.1.0"
6+
edition = "2021"
7+
8+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9+
10+
[dependencies]
11+
proptest = "1.0"
12+
13+
[workspace]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
//! Basic proptest examples. First one verifies, but the second one
5+
//! does not.
6+
7+
#[cfg(test)]
8+
mod test {
9+
use proptest::prelude::*;
10+
proptest! {
11+
/// Works fine. Shift has no overflow check.
12+
fn works_fine(even_num in any::<u32>().prop_map(|x| x << 1)) {
13+
prop_assert_eq!(even_num % 2, 0, "even number");
14+
}
15+
}
16+
17+
#[cfg(not(kani))]
18+
mod expected {
19+
proptest! {
20+
/// Overflow by check in x * 2. TODO: Need to implement
21+
/// expected fail tests. tracking issue:
22+
/// https://github.com/model-checking/kani-github-action/issues/5
23+
fn fails(even_num in any::<i32>().prop_map(|x| x * 2)) {
24+
prop_assert_eq!(even_num % 2, 0, "even number");
25+
}
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)