-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unwind Attribute without Python Changes (#846)
* Unwind Attribute without Python Changes
- Loading branch information
Showing
18 changed files
with
345 additions
and
13 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 |
---|---|---|
|
@@ -9,4 +9,4 @@ edition = "2021" | |
[dependencies] | ||
|
||
[kani.flags] | ||
output-format = "old" | ||
output-format = "old" |
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,13 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
[package] | ||
name = "simple-unwind-annotation" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
|
||
[kani.flags] | ||
output-format = "old" | ||
function = "harness" |
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 @@ | ||
[harness.assertion.2] line 21 assertion failed: counter < 10: FAILURE |
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,32 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// kani-flags: --function harness | ||
|
||
// The expected file presently looks for "1 == 2" above. | ||
// But eventually this test may start to fail as we might stop regarding 'main' | ||
// as a valid proof harness, since it isn't annotated as such. | ||
// This test should be updated if we go that route. | ||
|
||
fn main() { | ||
assert!(1 == 2); | ||
} | ||
|
||
#[kani::proof] | ||
#[kani::unwind(9)] | ||
fn harness() { | ||
let mut counter = 0; | ||
loop { | ||
counter += 1; | ||
assert!(counter < 10); | ||
} | ||
} | ||
|
||
#[kani::proof] | ||
fn harness_2() { | ||
let mut counter = 0; | ||
loop { | ||
counter += 1; | ||
assert!(counter < 10); | ||
} | ||
} |
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,21 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// kani-flags: --no-unwinding-checks | ||
|
||
// Added to fix me because there are no tests for the annotations themselves. | ||
// TODO : The unwind value needs to be parsed and the unwind needs to be applied to each harness, we do not test this behavior yet. | ||
|
||
fn main() { | ||
assert!(1 == 2); | ||
} | ||
|
||
#[kani::proof] | ||
#[kani::unwind(10)] | ||
fn harness() { | ||
let mut counter = 0; | ||
loop { | ||
counter += 1; | ||
assert!(counter < 10); | ||
} | ||
} |
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,6 @@ | ||
--> main.rs:13:1 | ||
| | ||
13 | #[kani::proof(some, argument2)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: message: #[kani::proof] does not take any arguments |
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 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// kani-flags: --no-unwinding-checks | ||
|
||
// This test is to check Kani's error handling for harnesses that have proof attributes | ||
// with arguments when the expected declaration takes no arguments. | ||
|
||
fn main() { | ||
assert!(1 == 2); | ||
} | ||
|
||
#[kani::proof(some, argument2)] | ||
fn harness() { | ||
let mut counter = 0; | ||
loop { | ||
counter += 1; | ||
assert!(counter < 10); | ||
} | ||
} |
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 @@ | ||
warning: Only one '#[kani::proof]' allowed | ||
--> main.rs:14:1 | ||
| | ||
14 | #[kani::proof] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in the attribute macro `kani::proof` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
warning: 1 warning emitted |
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,21 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// kani-flags: --no-unwinding-checks --verbose | ||
|
||
// This test is to check Kani's error handling for harnesses that have multiple proof annotations | ||
// declared. | ||
|
||
fn main() { | ||
assert!(1 == 2); | ||
} | ||
|
||
#[kani::proof] | ||
#[kani::proof] | ||
fn harness() { | ||
let mut counter = 0; | ||
loop { | ||
counter += 1; | ||
assert!(counter < 10); | ||
} | ||
} |
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 @@ | ||
error[E0433]: failed to resolve: could not find `test_annotation` in `kani` | ||
--> main.rs:14:9 | ||
| | ||
14 | #[kani::test_annotation] | ||
| ^^^^^^^^^^^^^^^ could not find `test_annotation` in `kani` | ||
|
||
error: aborting due to previous error |
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,21 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// kani-flags: --no-unwinding-checks --verbose | ||
|
||
// This test is to check Kani's error handling for harnesses that have multiple proof annotations | ||
// declared. | ||
|
||
fn main() { | ||
assert!(1 == 2); | ||
} | ||
|
||
#[kani::proof] | ||
#[kani::test_annotation] | ||
fn harness() { | ||
let mut counter = 0; | ||
loop { | ||
counter += 1; | ||
assert!(counter < 10); | ||
} | ||
} |
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 @@ | ||
error: Exactly one Unwind Argument as Integer accepted | ||
--> main.rs:14:1 | ||
| | ||
14 | #[kani::unwind(10,5)] | ||
| ^^^^^^^^^^^^^^^^^^^^^ |
Oops, something went wrong.