Skip to content

Commit 9d2bfda

Browse files
author
klaas
committed
Fixed test descriptions to put comments in the correct place and updated some stylistic issues with test cases.
1 parent e0c3138 commit 9d2bfda

File tree

22 files changed

+98
-35
lines changed

22 files changed

+98
-35
lines changed

regression/contracts/function_apply_01/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ __CPROVER_ensures(__CPROVER_return_value == 0)
1212
return 1;
1313
}
1414

15-
int main() {
15+
int main()
16+
{
1617
int x = foo();
1718
assert(x == 0);
1819
return 0;
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
KNOWNBUG # Applying code contracts currently also checks them.
1+
KNOWNBUG
22
main.c
33
--apply-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Applying code contracts currently also checks them.

regression/contracts/function_check_01/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ int min(int a, int b)
1212
(__CPROVER_return_value == a || __CPROVER_return_value == b)
1313
)
1414
{
15-
if (a <= b) {
15+
if (a <= b)
16+
{
1617
return a;
17-
} else {
18+
}
19+
else
20+
{
1821
return b;
1922
}
2023
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
KNOWNBUG # --check-code-contracts not implemented yet.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
--check-code-contracts not implemented yet.

regression/contracts/function_check_02/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ __CPROVER_ensures(
88
__CPROVER_forall {int i; (0 <= i && i < 10) ==> arr[i] == i}
99
)
1010
{
11-
for(int i = 0; i < 10; i++) {
11+
for(int i = 0; i < 10; i++)
12+
{
1213
arr[i] = i;
1314
}
1415

1516
return 0;
1617
}
1718

18-
int main() {
19+
int main()
20+
{
1921
int arr[10];
2022
initialize(arr);
2123
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
KNOWNBUG # Ensures statements currently do not allow quantified predicates unless the function has void return type.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Ensures statements currently do not allow quantified predicates unless the
10+
function has void return type.

regression/contracts/function_check_03/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ __CPROVER_ensures(
1919
}
2020
}
2121

22-
int main() {
22+
int main()
23+
{
2324
int arr[10];
2425
initialize(arr, 10);
2526
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
KNOWNBUG # Loop invariants currently do not support memory reads.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Loop invariants currently do not support memory reads in at least some
10+
circumstances.

regression/contracts/function_check_04/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ __CPROVER_ensures(__CPROVER_return_value == 0)
1111
return 1;
1212
}
1313

14-
int main() {
14+
int main()
15+
{
1516
int x = foo();
1617
assert(x == 0);
1718
return 0;
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
KNOWNBUG # --check-code-contracts not implemented yet.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^\[main.assertion.1\] assertion x == 0: SUCCESS$
55
^\[foo.1\] : FAILURE$
66
^VERIFICATION FAILED$
7+
--
8+
--
9+
--check-code-contracts not implemented yet.

regression/contracts/function_check_05/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ __CPROVER_ensures(__CPROVER_return_value == 1)
1414
return 1;
1515
}
1616

17-
int main() {
17+
int main()
18+
{
1819
int y = 0;
1920
int z = foo(&y);
2021
// This assert should fail.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
KNOWNBUG # Contract checking does not properly havoc function calls
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^\[main.assertion.1\] assertion y == 0: FAILURE$
55
^\[main.assertion.2\] assertion z == 1: SUCCESS$
66
^\[foo.1\] : SUCCESS$
7-
87
^VERIFICATION SUCCESSFUL$
8+
--
9+
--
10+
Contract checking does not properly havoc function calls.

regression/contracts/function_check_mem_01/main.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010
#define __CPROVER_VALID_MEM(ptr, size) \
1111
__CPROVER_POINTER_OBJECT((ptr)) != __CPROVER_POINTER_OBJECT(NULL) && \
1212
!__CPROVER_invalid_pointer((ptr)) && \
13-
__CPROVER_POINTER_OBJECT((ptr)) != __CPROVER_POINTER_OBJECT(__CPROVER_deallocated) && \
14-
__CPROVER_POINTER_OBJECT((ptr)) != __CPROVER_POINTER_OBJECT(__CPROVER_dead_object) && \
15-
(__builtin_object_size((ptr), 1) >= (size) && __CPROVER_POINTER_OFFSET((ptr)) >= 0l || \
13+
__CPROVER_POINTER_OBJECT((ptr)) != \
14+
__CPROVER_POINTER_OBJECT(__CPROVER_deallocated) && \
15+
__CPROVER_POINTER_OBJECT((ptr)) != \
16+
__CPROVER_POINTER_OBJECT(__CPROVER_dead_object) && \
17+
(__builtin_object_size((ptr), 1) >= (size) && \
18+
__CPROVER_POINTER_OFFSET((ptr)) >= 0l || \
1619
__CPROVER_DYNAMIC_OBJECT((ptr))) && \
1720
(__CPROVER_POINTER_OFFSET((ptr)) >= 0 && \
1821
__CPROVER_malloc_size >= (size) + __CPROVER_POINTER_OFFSET((ptr)) || \
19-
__CPROVER_POINTER_OBJECT((ptr)) != __CPROVER_POINTER_OBJECT(__CPROVER_malloc_object))
22+
__CPROVER_POINTER_OBJECT((ptr)) != \
23+
__CPROVER_POINTER_OBJECT(__CPROVER_malloc_object))
2024

2125
typedef struct bar {
2226
int x;
@@ -31,7 +35,8 @@ __CPROVER_requires(__CPROVER_VALID_MEM(x, sizeof(bar)))
3135
return
3236
}
3337

34-
int main() {
38+
int main()
39+
{
3540
bar* y;
3641
__CPROVER_assume(__CPROVER_VALID_MEM(y, sizeof(bar)));
3742
y->x = 0;
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
KNOWNBUG # cbmc currently does not support assumptions about pointers.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
CBMC currently does not support assumptions about pointers in the general way
10+
that other assumptions are supported.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
KNOWNBUG # --check-code-contracts not implemented yet.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
--check-code-contracts not implemented yet.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
KNOWNBUG # --check-code-contracts not implemented yet.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
--check-code-contracts not implemented yet.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
KNOWNBUG # --check-code-contracts not implemented yet.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
--check-code-contracts not implemented yet.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
KNOWNBUG # --check-code-contracts not implemented yet.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^\[main.1\] Loop invariant violated before entry: SUCCESS$
55
^\[main.2\] Loop invariant not preserved: SUCCESS$
66
^\[main.assertion.1\] assertion r==0: FAILURE$
77
^VERIFICATION FAILED$
8+
--
9+
--
10+
--check-code-contracts not implemented yet.

regression/contracts/invar_loop_constant/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
#include <assert.h>
99

10-
int main() {
10+
int main()
11+
{
1112
int r;
1213
int s = 1;
1314
__CPROVER_assume(r >= 0);
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
KNOWNBUG # Loop invariant checking throws away more information than needed.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Loop invariant checking throws away more information than needed.

regression/contracts/quicksort_contracts_01/main.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,26 @@ __CPROVER_ensures(
5050
1 == 1
5151
)
5252
{
53-
if(arr[h] <= pivot && arr[l] >= pivot) {
53+
if(arr[h] <= pivot && arr[l] >= pivot)
54+
{
5455
swap(arr + h, arr + l);
55-
if(pivot_idx == h) {
56+
if(pivot_idx == h)
57+
{
5658
pivot_idx = l;
5759
h--;
5860
}
59-
if(pivot_idx == l) {
61+
if(pivot_idx == l)
62+
{
6063
pivot_idx = h;
6164
l++;
6265
}
6366
}
64-
else if(arr[h] <= pivot) {
67+
else if(arr[h] <= pivot)
68+
{
6569
l++;
6670
}
67-
else {
71+
else
72+
{
6873
h--;
6974
}
7075
}
@@ -83,7 +88,8 @@ __CPROVER_ensures(
8388
1 == 1
8489
)
8590
{
86-
if (len <= 1) {
91+
if (len <= 1)
92+
{
8793
return;
8894
}
8995
int* new_ghost = malloc(len * sizeof(int));
@@ -99,7 +105,8 @@ __CPROVER_ensures(
99105
free(new_ghost);
100106
}
101107

102-
int main() {
108+
int main()
109+
{
103110
int arr[5] = {1, 2, 3, 0, 4};
104111
int arr_ghost[5] = {1, 2, 3, 0, 4};
105112
quicksort(arr_ghost, arr, 5);
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
KNOWNBUG # Loop invariants are overzealous in deciding what counts as side effects.
1+
KNOWNBUG
22
main.c
33
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Loop invariants are overzealous in deciding what counts as side effects.

0 commit comments

Comments
 (0)