Skip to content

Commit e0c3138

Browse files
author
klaas
committed
Added detailed description to regression tests.
1 parent 3464088 commit e0c3138

File tree

13 files changed

+84
-9
lines changed

13 files changed

+84
-9
lines changed

regression/contracts/function_apply_01/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
#include <assert.h>
1+
// function_apply_01
22

3-
// Note that this is supposed to have an incorrect contract.
3+
// Note that this test is supposed to have an incorrect contract.
44
// We verify that applying (without checking) the contract yields success,
55
// and that checking the contract yields failure.
6+
7+
#include <assert.h>
8+
69
int foo()
710
__CPROVER_ensures(__CPROVER_return_value == 0)
811
{

regression/contracts/function_check_01/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// function_check_01
2+
3+
// This tests a simple example of a function with requires and
4+
// ensures which should both be satisfied.
5+
16
#include <assert.h>
27

38
int min(int a, int b)

regression/contracts/function_check_02/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// function_check_02
2+
3+
// This test checks the use of quantifiers in ensures clauses.
4+
// A known bug causes the use of quantifiers in ensures to fail.
5+
16
int initialize(int* arr)
27
__CPROVER_ensures(
38
__CPROVER_forall {int i; (0 <= i && i < 10) ==> arr[i] == i}

regression/contracts/function_check_03/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// function_check_03
2+
3+
// This extends function_check_02's test of quantifiers in ensures
4+
// and adds in a loop invariant which can be used to prove the ensures.
5+
// This currently fails because side-effect checking in loop invariants is
6+
// incorrect.
7+
18
void initialize(int* arr, int len)
29
__CPROVER_ensures(
310
__CPROVER_forall {int i; (0 <= i && i < len) ==> arr[i] == i}

regression/contracts/function_check_04/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
// function_check_04
2+
3+
// Note that this test is supposed to have an incorrect contract.
4+
// We verify that checking this faulty contract (correctly) yields a failure.
5+
16
#include <assert.h>
27

3-
// Note that this is supposed to have an incorrect contract.
4-
// We verify that applying (without checking) the contract yields success,
5-
// and that checking the contract yields failure.
68
int foo()
79
__CPROVER_ensures(__CPROVER_return_value == 0)
810
{

regression/contracts/function_check_05/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// function_check_05
2+
3+
// This test checks that when a function call is replaced by an invariant,
4+
// it adequately havocs the locations modified by the function.
5+
// This test currently fails because the analysis of what is modified by
6+
// a function is flawed.
7+
18
#include <assert.h>
29

310
int foo(int* x)

regression/contracts/function_check_mem_01/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// function_check_mem_01
2+
3+
// This test checks the use of pointer-related predicates in assumptions and
4+
// requires.
5+
// This test currently fails because of the lack of support for assuming
6+
// pointer predicates.
7+
18
#include <stddef.h>
29

310
#define __CPROVER_VALID_MEM(ptr, size) \

regression/contracts/invar_check_01/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// invar_check_01
2+
3+
// This test checks that a basic loop invariant can be proven and used in
4+
// combination with the negation of the loop guard to get a result.
5+
16
#include <assert.h>
27

38
int main()

regression/contracts/invar_check_02/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// invar_check_02
2+
3+
// This test checks that loop invariants adequately handle continues.
4+
15
#include <assert.h>
26

37
int main()

regression/contracts/invar_check_03/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// invar_check_03
2+
3+
// This test checks the use of loop invariants on a larger problem --- in this
4+
// case, the partition portion of quicksort, applied to a fixed-length array.
5+
// This serves as a stop-gap test until issues to do with quantifiers and
6+
// side-effects in loop invariants are fixed.
7+
18
#include <stdio.h>
29
#include <assert.h>
310

regression/contracts/invar_check_04/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// invar_check_04
2+
3+
// This test checks the handling of break by loop invariants.
4+
// This test is expected to fail along the code path where r is even before
5+
// entering the loop.
6+
17
#include <assert.h>
28

39
int main()

regression/contracts/invar_loop_constant/main.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
// invar_loop_constant
2+
3+
// This test checks to see whether loop invariant checking discards sufficiently
4+
// little information to be aware after the loop that s is necessarily 1.
5+
// This test currently fails due to excessive havocking in checking loop
6+
// invariants, but is not an obstacle to soundness of contract checking.
7+
18
#include <assert.h>
29

310
int main() {
411
int r;
5-
int s;
6-
__CPROVER_assume(r > 0);
12+
int s = 1;
13+
__CPROVER_assume(r >= 0);
714
while(r > 0)
815
__CPROVER_loop_invariant(r >= 0)
916
{

regression/contracts/quicksort_contracts_01/main.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// quicksort_contracts_01
2+
3+
// This test checks the correctness of a quicksort implementation using explicit
4+
// ghost state.
5+
6+
// This test currently fails for a variety of reasons, including:
7+
// (1) Lack of support for quantifiers in ensures statements.
8+
// (2) Lack of support for reading from memory in loop invariants (under some
9+
// circumstances)
10+
111
#include <stdio.h>
212
#include <stdlib.h>
313
#include <string.h>
@@ -32,13 +42,13 @@ __CPROVER_ensures(
3242
int pivot = arr[pivot_idx];
3343

3444
while(h > l)
35-
/* __CPROVER_loop_invariant(
45+
__CPROVER_loop_invariant(
3646
0 <= l && l <= pivot_idx && pivot_idx <= h && h < len &&
3747
arr[pivot_idx] == pivot &&
3848
__CPROVER_forall {int i; (0 <= i && i < l) ==> arr[i] <= pivot} &&
3949
__CPROVER_forall {int i; (h < i && i < len) ==> pivot <= arr[i]} &&
4050
1 == 1
41-
)*/
51+
)
4252
{
4353
if(arr[h] <= pivot && arr[l] >= pivot) {
4454
swap(arr + h, arr + l);

0 commit comments

Comments
 (0)