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$

0 commit comments

Comments
 (0)