-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add target selection for cargo kani (#2507)
Add the following options to restrict `cargo kani` verification target: - `--bin <BIN_TARGET>` - `--bins` - `--lib`. I found this very helpful for example to skip integration tests when running `cargo kani` with `--tests`.
- Loading branch information
Showing
17 changed files
with
324 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
[package] | ||
name = "lib_pkg" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
path = "../src/lib.rs" | ||
|
||
[[bin]] | ||
name = "foo" | ||
path = "../src/bin/foo.rs" | ||
|
||
[[bin]] | ||
name = "bar" | ||
path = "../src/bin/bar.rs" | ||
|
||
[[test]] | ||
name = "integ" | ||
path = "../tests/integ.rs" | ||
|
||
[package.metadata.kani.flags] | ||
tests=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Checking harness verify::bar_harness... | ||
Checking harness verify::foo_harness... | ||
Checking harness verify::lib_harness... | ||
Checking harness verify::integ_harness... | ||
Complete - 4 successfully verified harnesses, 0 failures, 4 total. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
[package] | ||
name = "bin_pkg" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
path = "../src/lib.rs" | ||
|
||
[[bin]] | ||
name = "foo" | ||
path = "../src/bin/foo.rs" | ||
|
||
[[bin]] | ||
name = "bar" | ||
path = "../src/bin/bar.rs" | ||
|
||
[package.metadata.kani.flags] | ||
bin="foo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Checking harness verify::foo_harness... | ||
|
||
Status: SATISFIED\ | ||
Description: "Cover `foo`" | ||
|
||
** 1 of 1 cover properties satisfied | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
[package] | ||
name = "bin_pkg" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
path = "../src/lib.rs" | ||
|
||
[[bin]] | ||
name = "foo" | ||
path = "../src/bin/foo.rs" | ||
|
||
[[bin]] | ||
name = "bar" | ||
path = "../src/bin/bar.rs" | ||
|
||
[package.metadata.kani.flags] | ||
bins=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Checking harness verify::bar_harness... | ||
Status: SATISFIED\ | ||
Description: "Cover `bar`" | ||
|
||
Checking harness verify::foo_harness... | ||
Status: SATISFIED\ | ||
Description: "Cover `foo`" | ||
|
||
Complete - 2 successfully verified harnesses, 0 failures, 2 total. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
[package] | ||
name = "lib_pkg" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
path = "../src/lib.rs" | ||
|
||
[[bin]] | ||
name = "foo" | ||
path = "../src/bin/foo.rs" | ||
|
||
[[bin]] | ||
name = "bar" | ||
path = "../src/bin/bar.rs" | ||
|
||
[[test]] | ||
name = "integ" | ||
path = "../tests/integ.rs" | ||
|
||
[package.metadata.kani.flags] | ||
lib=true | ||
tests=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Checking harness verify::lib_harness... | ||
Status: SATISFIED\ | ||
Description: "Cover lib" | ||
|
22 changes: 22 additions & 0 deletions
22
tests/cargo-ui/target-selection/non-test-targets/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
[package] | ||
name = "lib_pkg" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
path = "../src/lib.rs" | ||
|
||
[[bin]] | ||
name = "foo" | ||
path = "../src/bin/foo.rs" | ||
|
||
[[bin]] | ||
name = "bar" | ||
path = "../src/bin/bar.rs" | ||
|
||
|
||
[package.metadata.kani.flags] | ||
lib=true | ||
bins=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Checking harness verify::bar_harness... | ||
Checking harness verify::foo_harness... | ||
Checking harness verify::lib_harness... | ||
|
||
Complete - 3 successfully verified harnesses, 0 failures, 3 total. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// | ||
//! Define a binary with a "bar" cover used to ensure pkg targets are correctly picked by Kani. | ||
#[cfg(kani)] | ||
mod verify { | ||
#[kani::proof] | ||
fn bar_harness() { | ||
kani::cover!(true, "Cover `bar`"); | ||
} | ||
} | ||
|
||
fn main() { | ||
// Do nothing | ||
} |
Oops, something went wrong.