-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More expected tests (readable/writable)
- Loading branch information
1 parent
9584340
commit 2369fe3
Showing
4 changed files
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FAILURE\ | ||
memmove source region readable |
16 changes: 16 additions & 0 deletions
16
tests/expected/intrinsics/copy/copy-unreadable-src/main.rs
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 | ||
|
||
// Checks that `copy` fails when `src` is not valid for reads. | ||
#[kani::proof] | ||
fn test_copy_invalid() { | ||
let arr: [i32; 3] = [0, 1, 0]; | ||
let src: *const i32 = arr.as_ptr(); | ||
|
||
unsafe { | ||
// Get an invalid pointer with a negative offset | ||
let src_invalid = unsafe { src.sub(1) as *const i32 }; | ||
let dst = src.add(1) as *mut i32; | ||
core::intrinsics::copy(src_invalid, dst, 1); | ||
} | ||
} |
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,2 @@ | ||
FAILURE\ | ||
memmove destination region writeable |
15 changes: 15 additions & 0 deletions
15
tests/expected/intrinsics/copy/copy-unwritable-dst/main.rs
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,15 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Checks that `copy` fails when `dst` is not valid for writes. | ||
#[kani::proof] | ||
fn test_copy_invalid() { | ||
let arr: [i32; 3] = [0, 1, 0]; | ||
let src: *const i32 = arr.as_ptr(); | ||
|
||
unsafe { | ||
// Get an invalid pointer with an out-of-bounds offset | ||
let dst_invalid = src.add(3) as *mut i32; | ||
core::intrinsics::copy(src, dst_invalid, 1); | ||
} | ||
} |