Skip to content

Commit 01444b7

Browse files
author
Aren Babikian
committed
Assesses PR comments and adds handling for loop unwinding
1 parent 7166cd5 commit 01444b7

File tree

18 files changed

+117
-45
lines changed

18 files changed

+117
-45
lines changed

regression/contracts/chain.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ name=${*:$#}
1111
name=${name%.c}
1212

1313
args=${*:5:$#-5}
14+
if [[ "$args" != *" _ "* ]]
15+
then
16+
args_inst=$args
17+
args_cbmc=""
18+
else
19+
args_inst="${args%%" _ "*}"
20+
args_cbmc="${args#*" _ "}"
21+
fi
1422

1523
if [[ "${is_windows}" == "true" ]]; then
1624
$goto_cc "${name}.c"
@@ -20,10 +28,10 @@ else
2028
fi
2129

2230
rm -f "${name}-mod.gb"
23-
$goto_instrument ${args} "${name}.gb" "${name}-mod.gb"
31+
$goto_instrument ${args_inst} "${name}.gb" "${name}-mod.gb"
2432
if [ ! -e "${name}-mod.gb" ] ; then
2533
cp "$name.gb" "${name}-mod.gb"
26-
elif echo $args | grep -q -- "--dump-c" ; then
34+
elif echo $args_inst | grep -q -- "--dump-c" ; then
2735
mv "${name}-mod.gb" "${name}-mod.c"
2836

2937
if [[ "${is_windows}" == "true" ]]; then
@@ -36,4 +44,4 @@ elif echo $args | grep -q -- "--dump-c" ; then
3644
rm "${name}-mod.c"
3745
fi
3846
$goto_instrument --show-goto-functions "${name}-mod.gb"
39-
$cbmc "${name}-mod.gb"
47+
$cbmc "${name}-mod.gb" ${args_cbmc}

regression/contracts/function-calls-01/test-enf.desc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
This confirms the accuracy of the postconditions.
9+
Verification:
10+
function | pre-cond | post-cond
11+
---------|----------|----------
12+
f1 | assumed | asserted

regression/contracts/function-calls-01/test-rep.desc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
This confirms the accuracy of the preconditions.
9+
Verification:
10+
function | pre-cond | post-cond
11+
---------|----------|----------
12+
f1 | asserted | assumed

regression/contracts/function-calls-02-1/test-enf.desc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
This confirms the accuracy of the postconditions of both f1 and f2.
9+
Verification:
10+
function | pre-cond | post-cond
11+
---------|----------|----------
12+
f1 | assumed | asserted
13+
f2 | assumed | asserted
1014

1115
Known bug:
1216
Enforce flag not handled correctly for function calls within functions.
13-
This bug is fixed in PR #5538.

regression/contracts/function-calls-02-1/test-mix.desc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
This confirms the accuracy of the preconditions of f2 (called from f1) and of the postcondition of f1.
9+
Verification:
10+
function | pre-cond | post-cond
11+
---------|----------|----------
12+
f1 | assumed | asserted
13+
f2 | asserted | assumed

regression/contracts/function-calls-02-1/test-rep.desc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
This confirms the accuracy of the preconditions of f1 (called from main).
9+
Verification:
10+
function | pre-cond | post-cond
11+
---------|----------|----------
12+
f1 | asserted | assumed
13+
f2 | n/a | n/a
14+
15+
Note: the call to f2 does not occur because the call to f1 is replaced by its contracts.

regression/contracts/function-calls-02/test-enf.desc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
This confirms the accuracy of the postconditions of both f1 and f2.
9+
Verification:
10+
function | pre-cond | post-cond
11+
---------|----------|----------
12+
f1 | assumed | asserted
13+
f2 | assumed | asserted
1014

1115
Known bug:
1216
Enforce flag not handled correctly for function calls within functions.
13-
This bug is fixed in PR #5538.

regression/contracts/function-calls-02/test-mix.desc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
This confirms the accuracy of the preconditions of f2 (called from f1) and of the postcondition of f1.
9+
Verification:
10+
function | pre-cond | post-cond
11+
---------|----------|----------
12+
f1 | assumed | asserted
13+
f2 | asserted | assumed

regression/contracts/function-calls-02/test-rep.desc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ main.c
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
This confirms the accuracy of the preconditions of f1 (called from main).
9+
Verification:
10+
function | pre-cond | post-cond
11+
---------|----------|----------
12+
f1 | asserted | assumed
13+
f2 | n/a | n/a
14+
15+
Note: the call to f2 does not occur because the call to f1 is replaced by its contracts.

regression/contracts/function-calls-03-1/test-enf.desc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
KNOWNBUG
1+
CORE
22
main.c
3-
--enforce-all-contracts
3+
--enforce-all-contracts _ --unwind 20 --unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
77
--
88
--
9-
This confirms the accuracy of the postconditions of both f1 and f2.
9+
Verification:
10+
function | pre-cond | post-cond
11+
---------|----------|----------
12+
f1 | assumed | asserted
13+
f2 | assumed | asserted
1014

1115
Test should fail:
1216
The postcondition of f2 is incorrect, considering the recursion particularity.
1317

1418
Recursion:
1519
The base case for the recursive call to f2 provides different behavior than the common case (given the pre-conditions).
16-
17-
Known bug 2:
18-
This test requires the "--unwind 20 --unwinding-assertions" flag for the cbmc call in "chain.sh", which is currently not handled.

0 commit comments

Comments
 (0)