Skip to content

Commit 365d85c

Browse files
committed
Make the harness running in CI
1 parent 1422f9d commit 365d85c

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

library/core/src/str/pattern.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option<bool> {
18871887
/// # Safety
18881888
///
18891889
/// Both slices must have the same length.
1890-
#[cfg(all(target_arch = "x86_64", target_feature = "sse2"))] // only called on x86
1890+
#[cfg(all(target_arch = "x86_64", any(kani, target_feature = "sse2")))] // only called on x86
18911891
#[inline]
18921892
#[requires(x.len() == y.len())]
18931893
unsafe fn small_slice_eq(x: &[u8], y: &[u8]) -> bool {
@@ -1958,17 +1958,13 @@ unsafe fn small_slice_eq(x: &[u8], y: &[u8]) -> bool {
19581958
pub mod verify {
19591959
use super::*;
19601960

1961+
// Copied from https://github.com/model-checking/kani/blob/main/library/kani/src/slice.rs
1962+
// should be removed when these functions are moved to `kani_core`
19611963
pub fn any_slice_of_array<T, const LENGTH: usize>(arr: &[T; LENGTH]) -> &[T] {
19621964
let (from, to) = any_range::<LENGTH>();
19631965
&arr[from..to]
19641966
}
19651967

1966-
/// A mutable version of the previous function
1967-
pub fn any_slice_of_array_mut<T, const LENGTH: usize>(arr: &mut [T; LENGTH]) -> &mut [T] {
1968-
let (from, to) = any_range::<LENGTH>();
1969-
&mut arr[from..to]
1970-
}
1971-
19721968
fn any_range<const LENGTH: usize>() -> (usize, usize) {
19731969
let from: usize = kani::any();
19741970
let to: usize = kani::any();
@@ -1977,14 +1973,16 @@ pub mod verify {
19771973
(from, to)
19781974
}
19791975

1980-
#[cfg(all(target_arch = "x86_64", target_feature = "sse2"))] // only called on x86
1976+
#[cfg(all(kani, target_arch = "x86_64"))] // only called on x86
19811977
#[kani::proof]
1978+
#[kani::unwind(4)]
19821979
pub fn check_small_slice_eq() {
19831980
const ARR_SIZE: usize = 1000;
19841981
let x: [u8; ARR_SIZE] = kani::any();
19851982
let y: [u8; ARR_SIZE] = kani::any();
19861983
let xs = any_slice_of_array(&x);
19871984
let ys = any_slice_of_array(&y);
1985+
kani::assume(xs.len() == ys.len());
19881986
unsafe {
19891987
small_slice_eq(xs, ys);
19901988
}

scripts/check_kani.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ cargo build-dev --release
4444
echo "Running tests..."
4545
echo
4646
cd "$VERIFY_RUST_STD_DIR"
47-
$KANI_DIR/scripts/kani verify-std -Z unstable-options $VERIFY_RUST_STD_DIR/library --target-dir "$RUNNER_TEMP" -Z function-contracts -Z mem-predicates -Z loop-contracts
47+
$KANI_DIR/scripts/kani verify-std -Z unstable-options $VERIFY_RUST_STD_DIR/library --target-dir "$RUNNER_TEMP" -Z function-contracts -Z mem-predicates -Z loop-contracts --enable-unstable --cbmc-args --object-bits 8
4848

4949
echo "Tests completed."
5050
echo

0 commit comments

Comments
 (0)