Skip to content

Commit 87ee713

Browse files
authored
Merge pull request #5343 from NlightNFotis/feature/harness_dirty
Output C code from harness generation tool.
2 parents a621e98 + d8a9207 commit 87ee713

File tree

56 files changed

+352
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+352
-96
lines changed

regression/goto-harness/chain.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,28 @@ name=${*:$#}
1212
name=${name%.c}
1313
args=${*:5:$#-5}
1414

15+
input_c_file="${name}.c"
16+
input_goto_binary="${name}.gb"
17+
harness_c_file="${name}-harness.c"
18+
19+
20+
1521
if [[ "${is_windows}" == "true" ]]; then
16-
$goto_cc "${name}.c"
17-
mv "${name}.exe" "${name}.gb"
22+
$goto_cc "$input_c_file"
23+
mv "${name}.exe" "$input_goto_binary"
1824
else
19-
$goto_cc -o "${name}.gb" "${name}.c"
25+
$goto_cc -o "$input_goto_binary" "$input_c_file"
2026
fi
2127

22-
if [ -e "${name}-mod.gb" ] ; then
23-
rm -f "${name}-mod.gb"
28+
if [ -e "$harness_c_file" ] ; then
29+
rm -f "$harness_c_file"
2430
fi
2531

2632
# `# some comment` is an inline comment - basically, cause bash to execute an empty command
27-
$cbmc --show-goto-functions "${name}.gb"
28-
$goto_harness "${name}.gb" "${name}-mod.gb" --harness-function-name $entry_point ${args}
29-
$cbmc --show-goto-functions "${name}-mod.gb"
30-
$cbmc --function $entry_point "${name}-mod.gb" \
33+
$cbmc --show-goto-functions "$input_goto_binary"
34+
$goto_harness "$input_goto_binary" "$harness_c_file" --harness-function-name $entry_point ${args}
35+
$cbmc --show-goto-functions "$harness_c_file"
36+
$cbmc --function $entry_point "$input_c_file" "$harness_c_file" \
3137
--pointer-check `# because we want to see out of bounds errors` \
3238
--unwind 11 `# with the way we set up arrays symex can't figure out loop bounds automatically` \
3339
--unwinding-assertions `# we want to make sure we don't accidentally pass tests because we didn't unwind enough` \
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <assert.h>
2+
3+
void entry_point(const int x)
4+
{
5+
// expected to succeed
6+
assert(x - x == 0);
7+
8+
// expected to fail
9+
assert(x != 13);
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
test.c
3+
--function entry_point --harness-type call-function
4+
\[entry_point.assertion.1\] line \d+ assertion x - x == 0: SUCCESS
5+
\[entry_point.assertion.2\] line \d+ assertion x != 13: FAILURE
6+
^EXIT=10$
7+
^SIGNAL=0$
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <stdlib.h>
2+
3+
struct SomeStruct
4+
{
5+
int x;
6+
};
7+
8+
void entry_point(const struct SomeStruct value)
9+
{
10+
assert(value.x - value.x == 0);
11+
assert(value.x != 13);
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
test.c
3+
--function entry_point --harness-type call-function
4+
\[entry_point.assertion.1\] line \d+ assertion value.x - value.x == 0: SUCCESS
5+
\[entry_point.assertion.2\] line \d+ assertion value.x != 13: FAILURE
6+
^EXIT=10$
7+
^SIGNAL=0$
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-y-snapshot.json --initial-goto-location main:7 --havoc-variables y
44
^\[main.assertion.1\] line \d+ assertion y \+ 2 > y: FAILURE$
@@ -7,3 +7,5 @@ main.c
77
^SIGNAL=0$
88
--
99
^warning: ignoring
10+
--
11+
More information can be found in github#5351.

regression/goto-harness/havoc-global-int-03/test.desc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-source-location main.c:6 --havoc-variables x
44
^EXIT=10$
@@ -8,3 +8,5 @@ main.c
88
\[main.assertion.3\] line [0-9]+ assertion x == 3: FAILURE
99
--
1010
^warning: ignoring
11+
--
12+
More information can be found in github#5351.

regression/goto-harness/havoc-global-struct/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-struct-snapshot.json --initial-goto-location main:3 --havoc-variables simple
44
^EXIT=10$

regression/goto-harness/load-snapshot-recursive-static-global-int-01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-goto-location main:1
44
^EXIT=0$

regression/goto-harness/load-snapshot-static-global-array-01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--harness-type initialise-with-memory-snapshot --memory-snapshot snapshot.json --initial-goto-location main:0
44
^EXIT=0$
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-goto-location main:0
44
^EXIT=0$
55
^SIGNAL=0$
66
VERIFICATION SUCCESSFUL
77
--
88
^warning: ignoring
9+
--
10+
More information can be found in github#5351.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-goto-location main:0
44
^EXIT=10$
@@ -7,3 +7,5 @@ main.c
77
\[main.assertion.2\] line [0-9]+ assertion y == 1: FAILURE
88
--
99
^warning: ignoring
10+
--
11+
More information can be found in github#5351.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-goto-location main:0
44
^EXIT=0$
55
^SIGNAL=0$
66
VERIFICATION SUCCESSFUL
77
--
88
^warning: ignoring
9+
--
10+
More information can be found in github#5351.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-goto-location main:1
44
^EXIT=0$
55
^SIGNAL=0$
66
VERIFICATION SUCCESSFUL
77
--
88
^warning: ignoring
9+
--
10+
More information can be found in github#5351.

regression/goto-harness/load-snapshot-static-global-pointer-01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--harness-type initialise-with-memory-snapshot --memory-snapshot snapshot.json --initial-goto-location main:0
44
^EXIT=0$
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
void entry_point(const int *x)
5+
{
6+
if(x != NULL)
7+
{
8+
assert(*x - *x == 0);
9+
}
10+
// expected to fail because we should get non-null pointers
11+
assert(x == NULL);
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
test.c
3+
--function entry_point --harness-type call-function
4+
\[entry_point.assertion.1\] line \d+ assertion \*x - \*x == 0: SUCCESS
5+
\[entry_point.assertion.2\] line \d+ assertion x == .*: FAILURE
6+
^EXIT=10$
7+
^SIGNAL=0$
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <assert.h>
2+
3+
struct SomeStruct
4+
{
5+
const int x;
6+
};
7+
8+
void entry_point(struct SomeStruct value)
9+
{
10+
// expected to succeed
11+
assert(value.x - value.x == 0);
12+
13+
// expected to fail
14+
assert(value.x != 13);
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function entry_point --harness-type call-function
4+
\[entry_point.assertion.1\] line \d+ assertion value.x - value.x == 0: SUCCESS
5+
\[entry_point.assertion.2\] line \d+ assertion value.x != 13: FAILURE
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
--
9+
--
10+
Note that the generated C code has a bug - the constant field actually isn't constant in CBMC.
11+
This is a bug that gets introduced somewhere in the C frontend, so we have no way of fixing this
12+
over here, but this test may have to be revisited once this has been resolved.

regression/snapshot-harness/arrays_01/test.desc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
array,p,q --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^EXIT=0$
@@ -11,3 +11,5 @@ array,p,q --harness-type initialise-with-memory-snapshot --initial-goto-location
1111
VERIFICATION SUCCESSFUL
1212
--
1313
^warning: ignoring
14+
--
15+
For more information take a look at github#5351

regression/snapshot-harness/arrays_02/test.desc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
p,q --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^EXIT=0$
@@ -9,3 +9,5 @@ p,q --harness-type initialise-with-memory-snapshot --initial-goto-location main:
99
VERIFICATION SUCCESSFUL
1010
--
1111
^warning: ignoring
12+
--
13+
For more information take a look at github#5351

regression/snapshot-harness/dynamic-array-int-ordering/test.desc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
a,a1,iterator1,a2,a3,iterator2,a4,a5,iterator3,a6,a7,array2,a8 --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^EXIT=10$
@@ -14,3 +14,5 @@ a,a1,iterator1,a2,a3,iterator2,a4,a5,iterator3,a6,a7,array2,a8 --harness-type in
1414
VERIFICATION FAILED
1515
--
1616
unwinding assertion loop \d+: FAILURE
17+
--
18+
For more information take a look at github#5351

regression/snapshot-harness/dynamic-array-int/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
array,iterator1,iterator2,iterator3 --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^EXIT=10$
@@ -16,3 +16,4 @@ VERIFICATION FAILED
1616
unwinding assertion loop \d+: FAILURE
1717
--
1818
Broken by https://github.com/diffblue/cbmc/issues/4978
19+
For more information take a look at github#5351

regression/snapshot-harness/function_pointer_01/test.desc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
fun_ptr --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^EXIT=0$
@@ -9,3 +9,5 @@ fun_ptr --harness-type initialise-with-memory-snapshot --initial-goto-location m
99
VERIFICATION SUCCESSFUL
1010
--
1111
^warning: ignoring
12+
--
13+
For more information take a look at github#5351

regression/snapshot-harness/function_pointer_02/test.desc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
fun_ptr1,fun_ptr2 --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^EXIT=0$
@@ -11,3 +11,5 @@ fun_ptr1,fun_ptr2 --harness-type initialise-with-memory-snapshot --initial-goto-
1111
VERIFICATION SUCCESSFUL
1212
--
1313
^warning: ignoring
14+
--
15+
For more information take a look at github#5351

regression/snapshot-harness/function_pointer_03/test.desc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
fun_array,fun_ptr1,fun_ptr2 --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^EXIT=0$
@@ -11,3 +11,5 @@ fun_array,fun_ptr1,fun_ptr2 --harness-type initialise-with-memory-snapshot --ini
1111
VERIFICATION SUCCESSFUL
1212
--
1313
^warning: ignoring
14+
--
15+
For more information take a look at github#5351
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
p --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 --min-null-tree-depth 10 --max-nondet-tree-depth 4 --havoc-variables p
44
^EXIT=0$
55
^SIGNAL=0$
66
VERIFICATION SUCCESSFUL
77
--
88
^warning: ignoring
9+
--
10+
For more information take a look at github#5351
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
p --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 --havoc-variables p --min-null-tree-depth 10 --max-nondet-tree-depth 3
44
^SIGNAL=0$
55
^EXIT=0$
66
VERIFICATION SUCCESSFUL
77
--
88
unwinding assertion loop \d+: FAILURE
9+
--
10+
For more information take a look at github#5351
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
first,second,array_size --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^SIGNAL=0$
55
^EXIT=0$
66
VERIFICATION SUCCESSFUL
77
--
88
unwinding assertion loop \d+: FAILURE
9+
--
10+
For more information take a look at github#5351
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
first,second,string_size,prefix --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 --havoc-variables prefix --size-of-array prefix:prefix_size --max-array-size 5
44
^SIGNAL=0$
55
^EXIT=0$
66
VERIFICATION SUCCESSFUL
77
--
88
unwinding assertion loop \d+: FAILURE
9+
--
10+
For more information take a look at github#5351
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
first,second,array_size,prefix,prefix_size --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 --havoc-variables prefix --size-of-array prefix:prefix_size --max-array-size 4
44
^SIGNAL=0$
55
^EXIT=0$
66
VERIFICATION SUCCESSFUL
77
--
88
unwinding assertion loop \d+: FAILURE
9+
--
10+
For more information take a look at github#5351
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
x,p --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^EXIT=0$
@@ -7,3 +7,5 @@ x,p --harness-type initialise-with-memory-snapshot --initial-goto-location main:
77
VERIFICATION SUCCESSFUL
88
--
99
^warning: ignoring
10+
--
11+
For more information take a look at github#5351

regression/snapshot-harness/pointer_02/test.desc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
x,p1,p2,p3 --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^EXIT=10$
@@ -10,3 +10,5 @@ x,p1,p2,p3 --harness-type initialise-with-memory-snapshot --initial-goto-locatio
1010
\[main.assertion.5\] line [0-9]+ assertion \*p1 == x: SUCCESS
1111
--
1212
^warning: ignoring
13+
--
14+
For more information take a look at github#5351

0 commit comments

Comments
 (0)