File tree Expand file tree Collapse file tree 13 files changed +132
-138
lines changed
assigns_enforce_multi_file_01
assigns_validity_pointer_02
test_aliasing_ensure_indirect
src/goto-instrument/contracts Expand file tree Collapse file tree 13 files changed +132
-138
lines changed Original file line number Diff line number Diff line change 1
1
CORE
2
2
main.c
3
- --enforce-contract f1 --enforce-contract f2 --enforce-contract f3
4
- ^EXIT=10 $
3
+ --enforce-contract f1
4
+ ^EXIT=0 $
5
5
^SIGNAL=0$
6
- ^VERIFICATION FAILED$
6
+ ^\[f1.\d+\] line \d+ Check that x2 is assignable: SUCCESS$
7
+ ^\[f1.\d+\] line \d+ Check that y2 is assignable: SUCCESS$
8
+ ^\[f1.\d+\] line \d+ Check that z2 is assignable: SUCCESS$
9
+ ^\[f2.\d+\] line \d+ Check that x3 is assignable: SUCCESS$
10
+ ^\[f2.\d+\] line \d+ Check that y3 is assignable: SUCCESS$
11
+ ^\[f2.\d+\] line \d+ Check that z3 is assignable: SUCCESS$
12
+ ^\[f3.\d+\] line \d+ Check that \*x3 is assignable: SUCCESS$
13
+ ^\[f3.\d+\] line \d+ Check that \*y3 is assignable: SUCCESS$
14
+ ^\[f3.\d+\] line \d+ Check that \*z3 is assignable: SUCCESS$
15
+ ^VERIFICATION SUCCESSFUL$
7
16
--
8
17
--
9
- This test checks that verification fails when an assigns clause is not respected through multiple function calls .
18
+ This test checks that verification only considers assigns clause from enforced function.
Original file line number Diff line number Diff line change 1
1
CORE
2
2
main.c
3
- --enforce-contract foo --enforce-contract bar --enforce-contract baz --enforce-contract qux
3
+ --enforce-contract foo --enforce-contract baz --enforce-contract qux
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
- ^\[bar\.1\] line \d+ .*: FAILURE$
7
- ^\[baz\.1\] line \d+ .*: FAILURE$
8
- ^\[qux\.1\] line \d+ .*: FAILURE$
6
+ ^\[baz.\d+\] line \d+ Check that global is assignable: FAILURE$
7
+ ^\[qux.\d+\] line \d+ Check that global is assignable: FAILURE$
9
8
^VERIFICATION FAILED$
10
9
--
11
10
--
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ int x = 0 ;
5
+
6
+ void quz () __CPROVER_assigns (x )
7
+ {
8
+ x = -1 ;
9
+ }
10
+
11
+ int baz () __CPROVER_assigns ()
12
+ {
13
+ return 5 ;
14
+ }
15
+
16
+ void bar (int * y , int w ) __CPROVER_assigns (* y )
17
+ {
18
+ * y = 3 ;
19
+ w = baz ();
20
+ quz ();
21
+ }
22
+
23
+ void foo (int * y , int z ) __CPROVER_assigns (* y )
24
+ {
25
+ int w = 5 ;
26
+ assert (w == 5 );
27
+ bar (y , w );
28
+ z = -2 ;
29
+ }
30
+
31
+ int main ()
32
+ {
33
+ int * y = malloc (sizeof (* y ));
34
+ * y = 0 ;
35
+ int z = 1 ;
36
+ foo (y , z );
37
+ assert (x == -1 );
38
+ assert (* y == 3 );
39
+ assert (z == 1 );
40
+ return 0 ;
41
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --enforce-contract foo
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ main.c function bar
7
+ ^\[bar.\d+\] line \d+ Check that \*y is assignable: SUCCESS$
8
+ ^\[baz.\d+\] line \d+ Check that w is assignable: SUCCESS$
9
+ ^\[foo.\d+\] line \d+ Check that w is assignable: SUCCESS$
10
+ ^\[foo.\d+\] line \d+ Check that z is assignable: SUCCESS$
11
+ ^\[quz.\d+\] line \d+ Check that x is assignable: FAILURE$
12
+ ^VERIFICATION FAILED$
13
+ --
14
+ --
15
+ Checks whether checks write set for sub-function calls.
Original file line number Diff line number Diff line change 1
1
CORE
2
2
main.c
3
- --enforce-contract f1 --enforce-contract f2 --enforce-contract f3
4
- ^EXIT=10 $
3
+ --enforce-contract f1
4
+ ^EXIT=0 $
5
5
^SIGNAL=0$
6
- ^VERIFICATION FAILED $
6
+ ^VERIFICATION SUCCESSFUL $
7
7
--
8
8
--
9
9
This test replicates the behavior of assigns_enforce_04, but separates
Original file line number Diff line number Diff line change 4
4
^EXIT=0$
5
5
^SIGNAL=0$
6
6
^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: SUCCESS$
7
- ^\[foo.\d+\] line \d+ Check that bar\'s assigns clause is a subset of foo\'s assigns clause: SUCCESS$
7
+ ^\[bar.\d+\] line \d+ Check that \*x is assignable: SUCCESS$
8
+ ^\[bar.\d+\] line \d+ Check that \*y is assignable: SUCCESS$
9
+ ^\[baz.\d+\] line \d+ Check that \*z is assignable: SUCCESS$
10
+ ^\[foo.\d+\] line \d+ Check that x is assignable: SUCCESS$
11
+ ^\[foo.\d+\] line \d+ Check that y is assignable: SUCCESS$
8
12
^\[foo.\d+\] line \d+ Check that \*x is assignable: SUCCESS$
9
- ^\[foo.\d+\] line \d+ Check that baz\'s assigns clause is a subset of foo\'s assigns clause: SUCCESS$
10
13
^VERIFICATION SUCCESSFUL$
11
14
--
12
15
^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: FAILURE$
Original file line number Diff line number Diff line change 1
1
CORE
2
2
main.c
3
- --enforce-contract f1 --enforce-contract f2 _ --unwind 20 --unwinding-assertions
3
+ --enforce-contract f1 _ --unwind 20 --unwinding-assertions
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
+ ^file main.c line \d+ function f2: recursion is ignored on call to \'f2\'$
7
+ ^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: FAILURE$
6
8
^VERIFICATION FAILED$
7
9
--
8
10
--
9
11
Verification:
10
12
function | pre-cond | post-cond
11
13
---------|----------|----------
12
14
f1 | assumed | asserted
13
- f2 | assumed | asserted
14
15
15
16
Test should fail:
16
17
The postcondition of f2 is incorrect, considering the recursion particularity.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
CORE
2
2
main.c
3
- --enforce-contract f1 --enforce-contract f2_out --enforce-contract f2_in _ --unwind 20 --unwinding-assertions
3
+ --enforce-contract f1 _ --unwind 20 --unwinding-assertions
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
+ ^file main.c line \d+ function f2\_in: recursion is ignored on call to \'f2\_out\'$
7
+ ^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: FAILURE$
6
8
^VERIFICATION FAILED$
7
9
--
8
10
--
9
11
Verification:
10
12
function | pre-cond | post-cond
11
13
---------|----------|----------
12
14
f1 | assumed | asserted
13
- f2_out | assumed | asserted
14
- f2_in | assumed | asserted
15
15
16
16
Test should fail:
17
17
The postcondition of f2 is incorrect, considering the recursion particularity.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments