File tree Expand file tree Collapse file tree 5 files changed +63
-0
lines changed
tests/cargo-kani/proptest-lib Expand file tree Collapse file tree 5 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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
2630runs :
2731 using : " composite"
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 : |
Original file line number Diff line number Diff line change 1+ /target
Original file line number Diff line number Diff line change 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 ]
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments