Skip to content

Enable acceleration tests #5901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ add_subdirectory(goto-cc-goto-analyzer)
add_subdirectory(statement-list)
add_subdirectory(systemc)
add_subdirectory(contracts)
add_subdirectory(acceleration)
add_subdirectory(goto-harness)
add_subdirectory(goto-harness-multi-file-project)
add_subdirectory(goto-cc-file-local)
Expand Down
1 change: 1 addition & 0 deletions regression/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ DIRS = cbmc \
statement-list \
systemc \
contracts \
acceleration \
goto-harness \
goto-harness-multi-file-project \
goto-cc-file-local \
Expand Down
12 changes: 12 additions & 0 deletions regression/acceleration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if(WIN32)
set(is_windows true)
else()
set(is_windows false)
endif()

add_test_pl_tests(
"../accelerate.sh \
$<TARGET_FILE:goto-cc> \
$<TARGET_FILE:goto-instrument> \
$<TARGET_FILE:cbmc> \
${is_windows}")
18 changes: 16 additions & 2 deletions regression/acceleration/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
default: tests.log

include ../../src/config.inc
include ../../src/common

GOTO_INSTRUMENT_EXE=../../../src/goto-instrument/goto-instrument
CBMC_EXE=../../../src/cbmc/cbmc

ifeq ($(BUILD_ENV_),MSVC)
GOTO_CC_EXE=../../../src/goto-cc/goto-cl
is_windows=true
else
GOTO_CC_EXE=../../../src/goto-cc/goto-cc
is_windows=false
endif

test:
@../test.pl -c ../../../src/goto-instrument/accelerate/accelerate.sh
@../test.pl -e -p -c "../accelerate.sh $(GOTO_CC_EXE) $(GOTO_INSTRUMENT_EXE) $(CBMC_EXE) $(is_windows)"

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

show:
@for dir in *; do \
Expand Down
39 changes: 27 additions & 12 deletions regression/acceleration/accelerate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,30 @@

cleanup()
{
rm -f $ofile $accfile $instrfile
rm -rf "$target_dir"
}

trap cleanup EXIT

bindir=`dirname $0`
goto_cc="$bindir/../../goto-cc/goto-cc"
goto_instrument="$bindir/../goto-instrument"
cbmc="$bindir/../../cbmc/cbmc"
set -e

goto_cc=$1
goto_instrument=$2
cbmc=$3
is_windows=$4
shift 4

cfile=""
cbmcargs=""
ofile=`mktemp`
instrfile=`mktemp`
accfile=`mktemp`

# create the temporary directory relative to the current directory, thus
# avoiding file names that start with a "/", which confuses goto-cl (Windows)
# when running in git-bash.
target_dir="$(TMPDIR=. mktemp -d)"

ofile="$target_dir/compiled.gb"
instrfile="$target_dir/instrumented.gb"
accfile="$target_dir/accelerated.gb"

for a in "$@"
do
Expand All @@ -29,7 +39,12 @@ case $a in
esac
done

$goto_cc $cfile -o $ofile || exit 1
$goto_instrument --inline --remove-pointers $ofile $instrfile || exit 1
timeout 5 $goto_instrument --accelerate $instrfile $accfile
timeout 5 $cbmc --unwind 5 --z3 $cbmcargs $accfile
if [[ "${is_windows}" == "true" ]]; then
$goto_cc "$cfile" "/Fe$ofile"
else
$goto_cc -o "$ofile" "$cfile"
fi

"$goto_instrument" --inline --remove-pointers "$ofile" "$instrfile"
"$goto_instrument" --accelerate "$instrfile" "$accfile"
"$cbmc" --unwind 5 $cbmcargs "$accfile"
4 changes: 3 additions & 1 deletion regression/acceleration/array_unsafe1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/array_unsafe2/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/array_unsafe3/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/array_unsafe4/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/const_unsafe1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/diamond_unsafe1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/functions_unsafe1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/nested_unsafe1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/overflow_unsafe1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/phases_unsafe1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/simple_unsafe1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
4 changes: 3 additions & 1 deletion regression/acceleration/simple_unsafe4/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CORE
KNOWNBUG
main.c
--no-unwinding-assertions
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
The result spuriously is VERIFICATION SUCCESSFUL.
26 changes: 13 additions & 13 deletions src/goto-instrument/accelerate/scratch_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ bool scratch_programt::check_sat(bool do_slice, guard_managert &guard_manager)
output(ns, "scratch", std::cout);
#endif

symex_state = util_make_unique<goto_symex_statet>(
symex_targett::sourcet(goto_functionst::entry_point(), *this),
DEFAULT_MAX_FIELD_SENSITIVITY_ARRAY_SIZE,
guard_manager,
[this](const irep_idt &id) {
return path_storage.get_unique_l2_index(id);
});

symex.symex_with_state(
*symex_state,
[this](const irep_idt &key) -> const goto_functionst::goto_functiont & {
goto_functiont this_goto_function;
this_goto_function.body.copy_from(*this);
auto get_goto_function =
[this, &this_goto_function](
const irep_idt &key) -> const goto_functionst::goto_functiont & {
if(key == goto_functionst::entry_point())
return this_goto_function;
else
return functions.function_map.at(key);
},
symex_symbol_table);
};

symex_state = symex.initialize_entry_point_state(get_goto_function);

symex.symex_with_state(*symex_state, get_goto_function, symex_symbol_table);

if(do_slice)
{
Expand Down
29 changes: 28 additions & 1 deletion src/goto-instrument/accelerate/scratch_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,33 @@ Author: Matt Lewis

#include "path.h"

// Wrapper around goto_symext to make initialize_entry_point_state available.
struct scratch_program_symext : public goto_symext
{
scratch_program_symext(
message_handlert &mh,
const symbol_tablet &outer_symbol_table,
symex_target_equationt &_target,
const optionst &options,
path_storaget &path_storage,
guard_managert &guard_manager)
: goto_symext(
mh,
outer_symbol_table,
_target,
options,
path_storage,
guard_manager)
{
}

std::unique_ptr<statet>
initialize_entry_point_state(const get_goto_functiont &get_goto_function)
{
return goto_symext::initialize_entry_point_state(get_goto_function);
}
};

class scratch_programt:public goto_programt
{
public:
Expand Down Expand Up @@ -85,7 +112,7 @@ class scratch_programt:public goto_programt
symex_target_equationt equation;
path_fifot path_storage;
optionst options;
goto_symext symex;
scratch_program_symext symex;

std::unique_ptr<propt> satcheck;
bv_pointerst satchecker;
Expand Down