Skip to content

Commit e7d87ae

Browse files
authored
Merge pull request #5901 from tautschnig/enable-acceleration-tests
Enable acceleration tests
2 parents 1b6d8d9 + 26cfdd8 commit e7d87ae

File tree

19 files changed

+134
-40
lines changed

19 files changed

+134
-40
lines changed

regression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ add_subdirectory(goto-cc-goto-analyzer)
5252
add_subdirectory(statement-list)
5353
add_subdirectory(systemc)
5454
add_subdirectory(contracts)
55+
add_subdirectory(acceleration)
5556
add_subdirectory(goto-harness)
5657
add_subdirectory(goto-harness-multi-file-project)
5758
add_subdirectory(goto-cc-file-local)

regression/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ DIRS = cbmc \
2727
statement-list \
2828
systemc \
2929
contracts \
30+
acceleration \
3031
goto-harness \
3132
goto-harness-multi-file-project \
3233
goto-cc-file-local \
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
if(WIN32)
2+
set(is_windows true)
3+
else()
4+
set(is_windows false)
5+
endif()
6+
7+
add_test_pl_tests(
8+
"../accelerate.sh \
9+
$<TARGET_FILE:goto-cc> \
10+
$<TARGET_FILE:goto-instrument> \
11+
$<TARGET_FILE:cbmc> \
12+
${is_windows}")

regression/acceleration/Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
default: tests.log
22

3+
include ../../src/config.inc
4+
include ../../src/common
5+
6+
GOTO_INSTRUMENT_EXE=../../../src/goto-instrument/goto-instrument
7+
CBMC_EXE=../../../src/cbmc/cbmc
8+
9+
ifeq ($(BUILD_ENV_),MSVC)
10+
GOTO_CC_EXE=../../../src/goto-cc/goto-cl
11+
is_windows=true
12+
else
13+
GOTO_CC_EXE=../../../src/goto-cc/goto-cc
14+
is_windows=false
15+
endif
16+
317
test:
4-
@../test.pl -c ../../../src/goto-instrument/accelerate/accelerate.sh
18+
@../test.pl -e -p -c "../accelerate.sh $(GOTO_CC_EXE) $(GOTO_INSTRUMENT_EXE) $(CBMC_EXE) $(is_windows)"
519

620
tests.log: ../test.pl
7-
@../test.pl -c ../../../src/goto-instrument/accelerate/accelerate.sh
21+
@../test.pl -e -p -c "../accelerate.sh $(GOTO_CC_EXE) $(GOTO_INSTRUMENT_EXE) $(CBMC_EXE) $(is_windows)"
822

923
show:
1024
@for dir in *; do \

regression/acceleration/accelerate.sh

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,30 @@
22

33
cleanup()
44
{
5-
rm -f $ofile $accfile $instrfile
5+
rm -rf "$target_dir"
66
}
77

88
trap cleanup EXIT
99

10-
bindir=`dirname $0`
11-
goto_cc="$bindir/../../goto-cc/goto-cc"
12-
goto_instrument="$bindir/../goto-instrument"
13-
cbmc="$bindir/../../cbmc/cbmc"
10+
set -e
11+
12+
goto_cc=$1
13+
goto_instrument=$2
14+
cbmc=$3
15+
is_windows=$4
16+
shift 4
17+
1418
cfile=""
1519
cbmcargs=""
16-
ofile=`mktemp`
17-
instrfile=`mktemp`
18-
accfile=`mktemp`
20+
21+
# create the temporary directory relative to the current directory, thus
22+
# avoiding file names that start with a "/", which confuses goto-cl (Windows)
23+
# when running in git-bash.
24+
target_dir="$(TMPDIR=. mktemp -d)"
25+
26+
ofile="$target_dir/compiled.gb"
27+
instrfile="$target_dir/instrumented.gb"
28+
accfile="$target_dir/accelerated.gb"
1929

2030
for a in "$@"
2131
do
@@ -29,7 +39,12 @@ case $a in
2939
esac
3040
done
3141

32-
$goto_cc $cfile -o $ofile || exit 1
33-
$goto_instrument --inline --remove-pointers $ofile $instrfile || exit 1
34-
timeout 5 $goto_instrument --accelerate $instrfile $accfile
35-
timeout 5 $cbmc --unwind 5 --z3 $cbmcargs $accfile
42+
if [[ "${is_windows}" == "true" ]]; then
43+
$goto_cc "$cfile" "/Fe$ofile"
44+
else
45+
$goto_cc -o "$ofile" "$cfile"
46+
fi
47+
48+
"$goto_instrument" --inline --remove-pointers "$ofile" "$instrfile"
49+
"$goto_instrument" --accelerate "$instrfile" "$accfile"
50+
"$cbmc" --unwind 5 $cbmcargs "$accfile"
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7+
--
8+
The result spuriously is VERIFICATION SUCCESSFUL.

src/goto-instrument/accelerate/scratch_program.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ bool scratch_programt::check_sat(bool do_slice, guard_managert &guard_manager)
3636
output(ns, "scratch", std::cout);
3737
#endif
3838

39-
symex_state = util_make_unique<goto_symex_statet>(
40-
symex_targett::sourcet(goto_functionst::entry_point(), *this),
41-
DEFAULT_MAX_FIELD_SENSITIVITY_ARRAY_SIZE,
42-
guard_manager,
43-
[this](const irep_idt &id) {
44-
return path_storage.get_unique_l2_index(id);
45-
});
46-
47-
symex.symex_with_state(
48-
*symex_state,
49-
[this](const irep_idt &key) -> const goto_functionst::goto_functiont & {
39+
goto_functiont this_goto_function;
40+
this_goto_function.body.copy_from(*this);
41+
auto get_goto_function =
42+
[this, &this_goto_function](
43+
const irep_idt &key) -> const goto_functionst::goto_functiont & {
44+
if(key == goto_functionst::entry_point())
45+
return this_goto_function;
46+
else
5047
return functions.function_map.at(key);
51-
},
52-
symex_symbol_table);
48+
};
49+
50+
symex_state = symex.initialize_entry_point_state(get_goto_function);
51+
52+
symex.symex_with_state(*symex_state, get_goto_function, symex_symbol_table);
5353

5454
if(do_slice)
5555
{

src/goto-instrument/accelerate/scratch_program.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,33 @@ Author: Matt Lewis
3333

3434
#include "path.h"
3535

36+
// Wrapper around goto_symext to make initialize_entry_point_state available.
37+
struct scratch_program_symext : public goto_symext
38+
{
39+
scratch_program_symext(
40+
message_handlert &mh,
41+
const symbol_tablet &outer_symbol_table,
42+
symex_target_equationt &_target,
43+
const optionst &options,
44+
path_storaget &path_storage,
45+
guard_managert &guard_manager)
46+
: goto_symext(
47+
mh,
48+
outer_symbol_table,
49+
_target,
50+
options,
51+
path_storage,
52+
guard_manager)
53+
{
54+
}
55+
56+
std::unique_ptr<statet>
57+
initialize_entry_point_state(const get_goto_functiont &get_goto_function)
58+
{
59+
return goto_symext::initialize_entry_point_state(get_goto_function);
60+
}
61+
};
62+
3663
class scratch_programt:public goto_programt
3764
{
3865
public:
@@ -85,7 +112,7 @@ class scratch_programt:public goto_programt
85112
symex_target_equationt equation;
86113
path_fifot path_storage;
87114
optionst options;
88-
goto_symext symex;
115+
scratch_program_symext symex;
89116

90117
std::unique_ptr<propt> satcheck;
91118
bv_pointerst satchecker;

0 commit comments

Comments
 (0)