Skip to content

Kani - Generate an array with a constraint on elements #181

Closed Answered by zhassan-aws
Yenyun035 asked this question in Q&A
Discussion options

You must be logged in to vote

And this question refers to the second case. Or, is Check 2 self-contained in Check 1?

Yes, it seems to me that harnesses 1 and 2 should be merged.

But if we have a harness that checks if panic happens when from_bytes_until_nul is invoked on an array that has no null bytes, we might want to generate such an array (e.g. with kani::any_where).

It might be more efficient to generate an array and assume the value is non-zero in a loop, e.g.:

    let mut string: [u8; ARR_LEN] = kani::any();
    for i in 0..ARR_LEN {
        kani::assume(string[i] != 0);
    }

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Yenyun035
Comment options

@zhassan-aws
Comment options

Answer selected by Yenyun035
@celinval
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants