File tree Expand file tree Collapse file tree 13 files changed +128
-143
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 +128
-143
lines changed Original file line number Diff line number Diff line change 11CORE
22main.c
3- --enforce-contract f1 --enforce-contract f2 --enforce-contract f3
4- ^EXIT=10 $
3+ --enforce-contract f1
4+ ^EXIT=0 $
55^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$
716--
817--
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 11CORE
22main.c
3- --enforce-contract foo --enforce-contract bar --enforce-contract baz --enforce-contract qux
3+ --enforce-contract foo --enforce-contract baz --enforce-contract qux
44^EXIT=10$
55^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$
98^VERIFICATION FAILED$
109--
1110--
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 11CORE
22main.c
3- --enforce-contract f1 --enforce-contract f2 --enforce-contract f3
4- ^EXIT=10 $
3+ --enforce-contract f1
4+ ^EXIT=0 $
55^SIGNAL=0$
6- ^VERIFICATION FAILED $
6+ ^VERIFICATION SUCCESSFUL $
77--
88--
99This test replicates the behavior of assigns_enforce_04, but separates
Original file line number Diff line number Diff line change 44^EXIT=0$
55^SIGNAL=0$
66^\[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$
812^\[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$
1013^VERIFICATION SUCCESSFUL$
1114--
1215^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: FAILURE$
Original file line number Diff line number Diff line change 11CORE
22main.c
3- --enforce-contract f1 --enforce-contract f2 _ --unwind 20 --unwinding-assertions
3+ --enforce-contract f1 _ --unwind 20 --unwinding-assertions
44^EXIT=10$
55^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$
68^VERIFICATION FAILED$
79--
810--
911Verification:
1012 function | pre-cond | post-cond
1113 ---------|----------|----------
1214 f1 | assumed | asserted
13- f2 | assumed | asserted
1415
1516Test should fail:
1617The 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 11CORE
22main.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
44^EXIT=10$
55^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$
68^VERIFICATION FAILED$
79--
810--
911Verification:
1012 function | pre-cond | post-cond
1113 ---------|----------|----------
1214 f1 | assumed | asserted
13- f2_out | assumed | asserted
14- f2_in | assumed | asserted
1515
1616Test should fail:
1717The 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