Skip to content

Commit 6a8dc61

Browse files
author
Carolyn Zech
committed
add tests that autoharness does not generate harnesses for functions outside the local crate
1 parent f105a9c commit 6a8dc61

File tree

7 files changed

+52
-0
lines changed

7 files changed

+52
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
[package]
4+
name = "cargo_autoharness_dependencies"
5+
version = "0.1.0"
6+
edition = "2021"
7+
8+
[dependencies]
9+
other_crate = { path = "other_crate" }
10+
11+
[package.metadata.kani.unstable]
12+
stubbing = true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
script: dependencies.sh
4+
expected: dependencies.expected
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Autoharness: Checking function yes_harness against all possible inputs...
2+
Verification succeeded for - yes_harness
3+
Complete - 1 successfully verified functions, 0 failures, 1 total.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
# Copyright Kani Contributors
3+
# SPDX-License-Identifier: Apache-2.0 OR MIT
4+
5+
cargo kani autoharness -Z autoharness
6+
# We expect verification to fail, so the above command will produce an exit status of 1
7+
# However, we don't want the test to fail because of that exit status; we only want it to fail if the expected file doesn't match
8+
# So, exit with a status code of 0 explicitly.
9+
exit 0;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
[package]
4+
name = "other_crate"
5+
version = "0.1.0"
6+
edition = "2021"
7+
8+
[dependencies]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
fn no_harness(x: u8) -> u8 {
5+
x + 1
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
//! This tests that the autoharness feature doesn't generate harnesses for functions outside the local crate.
5+
6+
use other_crate;
7+
8+
fn yes_harness(x: u8) -> u8 {
9+
x
10+
}

0 commit comments

Comments
 (0)