Skip to content

Commit b22524d

Browse files
committed
Adjusts regresison tests according to code review
1 parent 160d887 commit b22524d

File tree

13 files changed

+62
-24
lines changed

13 files changed

+62
-24
lines changed

regression/contracts/function_check_02/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33
--enforce-all-contracts
44
^EXIT=0$

regression/contracts/quantifiers-exists-ensures-01/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// clang-format off
12
int f1(int *arr) __CPROVER_ensures(__CPROVER_exists {
23
int i;
3-
(0 <= i && i < 10) && arr[i] == i
4+
(0 <= i && i < 10) ==> arr[i] == i
45
})
6+
// clang-format on
57
{
68
for(int i = 0; i < 10; i++)
79
{

regression/contracts/quantifiers-exists-ensures-01/test.desc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
Verification:
10-
This test asserts the postconditions of f1.
9+
The purpose of this test is to ensure that we can safety use __CPROVER_exists
10+
in __CPROVER_ensures clauses. By using the --enforce-all-contracts flag,
11+
goto-instrument will transform the __CPROVER_ensures clauses into an
12+
assertion and the verification remains sound when using __CPROVER_exists.

regression/contracts/quantifiers-exists-ensures-02/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// clang-format off
12
int f1(int *arr) __CPROVER_ensures(__CPROVER_exists {
23
int i;
3-
(0 <= i && i < 10) && arr[i] != 0
4+
(0 <= i && i < 10) ==> arr[i] != 0
45
})
6+
// clang-format on
57
{
68
for(int i = 0; i < 10; i++)
79
{
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--enforce-all-contracts
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
77
--
88
--
9-
Verification:
10-
This test asserts the postconditions of f1.
9+
The purpose of this test is to ensure that we can safety use __CPROVER_exists
10+
in __CPROVER_ensures clauses. By using the --enforce-all-contracts flag,
11+
goto-instrument will transform the __CPROVER_ensures clauses into an
12+
assertion and the verification remains sound when using __CPROVER_exists.
13+
14+
Known Bug:
15+
We expect verification to fail because arr[i] is always equal to 0 for
16+
[0 <= i < 10]. In fact, we expect the (0 <= i && i < 10) statement to act as a
17+
range for i. However, in the current implementation of quantifier handling,
18+
the (0 <= i && i < 10) statement is not interpreted as an explicit range, but
19+
instead, as part of a logic formula, which causes verification to succeed.

regression/contracts/quantifiers-exists-requires-01/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// clang-format off
12
int f1(int *arr) __CPROVER_requires(__CPROVER_exists {
23
int i;
3-
(0 <= i && i < 10) && arr[i] == 4
4+
(0 <= i && i < 10) ==> arr[i] == 4
45
}) __CPROVER_ensures(__CPROVER_return_value == 0)
6+
// clang-format on
57
{
68
return 0;
79
}

regression/contracts/quantifiers-exists-requires-01/test.desc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
Verification:
10-
This test asserts the preconditions of f1.
9+
The purpose of this test is to ensure that we can safety use __CPROVER_exists
10+
in __CPROVER_requires clauses. By using the --replace-all-calls-with-contracts
11+
flag, goto-instrument will transform the __CPROVER_requires clauses into an
12+
assertion and the verification remains sound when using __CPROVER_exists.

regression/contracts/quantifiers-exists-requires-02/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// clang-format off
12
int f1(int *arr) __CPROVER_requires(__CPROVER_exists {
23
int i;
3-
(0 <= i && i < 10) && arr[i] == 1
4+
(0 <= i && i < 10) ==> arr[i] == 1
45
}) __CPROVER_ensures(__CPROVER_return_value == 0)
6+
// clang-format on
57
{
68
return 0;
79
}
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--replace-all-calls-with-contracts
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
77
--
88
--
9-
Verification:
10-
This test asserts the preconditions of f1.
9+
The purpose of this test is to ensure that we can safety use __CPROVER_exists
10+
in __CPROVER_requires clauses. By using the --replace-all-calls-with-contracts
11+
flag, goto-instrument will transform the __CPROVER_requires clauses into an
12+
assertion and the verification remains sound when using __CPROVER_exists.
13+
14+
Known Bug:
15+
We expect verification to fail because arr[i] is never equal to 1 for
16+
[0 <= i < 10]. In fact, we expect the (0 <= i && i < 10) statement to act as a
17+
range for i. However, in the current implementation of quantifier handling,
18+
the (0 <= i && i < 10) statement is not interpreted as an explicit range, but
19+
instead, as part of a logic formula, which causes verification to succeed.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
CORE
22
main.c
3-
--replace-all-calls-with-contracts
3+
--enforce-all-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
Verification:
10-
This test asserts the preconditions of f1.
9+
The purpose of this test is to ensure that we can safety use __CPROVER_forall
10+
in __CPROVER_ensures clauses. By using the --enforce-all-contracts
11+
flag, goto-instrument will transform the __CPROVER_ensures clauses into an
12+
assertion and the verification remains sound when using __CPROVER_forall.

regression/contracts/quantifiers-forall-ensures-02/test.desc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ main.c
66
^VERIFICATION FAILED$
77
--
88
--
9-
Verification:
10-
This test asserts the postconditions of f1.
9+
The purpose of this test is to ensure that we can safety use __CPROVER_forall
10+
in __CPROVER_ensures clauses. By using the --enforce-all-contracts
11+
flag, goto-instrument will transform the __CPROVER_ensures clauses into an
12+
assertion and the verification remains sound when using __CPROVER_forall.

regression/contracts/quantifiers-forall-requires-01/test.desc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
Verification:
10-
This test asserts the preconditions of f1.
9+
The purpose of this test is to ensure that we can safety use __CPROVER_forall
10+
in __CPROVER_requires clauses. By using the --replace-all-calls-with-contracts
11+
flag, goto-instrument will transform the __CPROVER_requires clauses into an
12+
assertion and the verification remains sound when using __CPROVER_forall.

regression/contracts/quantifiers-forall-requires-02/test.desc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ main.c
66
^VERIFICATION FAILED$
77
--
88
--
9-
Verification:
10-
This test asserts the preconditions of f1.
9+
The purpose of this test is to ensure that we can safety use __CPROVER_forall
10+
in __CPROVER_requires clauses. By using the --replace-all-calls-with-contracts
11+
flag, goto-instrument will transform the __CPROVER_requires clauses into an
12+
assertion and the verification remains sound when using __CPROVER_forall.

0 commit comments

Comments
 (0)