Skip to content

Commit c7b962f

Browse files
authored
Merge pull request #4014 from NlightNFotis/new_chain_sh
Add function harness generator and generator factory
2 parents 85a2a6a + 7b55287 commit c7b962f

20 files changed

+678
-35
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ src/goto-cc/goto-cc
102102
src/goto-cc/goto-gcc
103103
src/goto-cc/goto-cc.exe
104104
src/goto-cc/goto-cl.exe
105+
src/goto-harness/goto-harness
106+
src/goto-harness/goto-harness.exe
105107
src/goto-instrument/goto-instrument
106108
src/goto-instrument/goto-instrument.exe
107109
src/solvers/smt2_solver
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1+
if(WIN32)
2+
set(is_windows true)
3+
else()
4+
set(is_windows false)
5+
endif()
6+
17
add_test_pl_tests(
2-
"$<TARGET_FILE:goto-harness>")
8+
"../chain.sh \
9+
$<TARGET_FILE:goto-cc> \
10+
$<TARGET_FILE:goto-harness> \
11+
$<TARGET_FILE:cbmc> \
12+
${is_windows}")

regression/goto-harness/Makefile

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

3+
include ../../src/config.inc
4+
include ../../src/common
5+
36
GOTO_HARNESS_EXE=../../../src/goto-harness/goto-harness
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
416

517
test:
6-
@../test.pl -p -c ${GOTO_HARNESS_EXE}
18+
@../test.pl -p -c "../chain.sh $(GOTO_CC_EXE) $(GOTO_HARNESS_EXE) $(CBMC_EXE) $(is_windows)"
719

820
tests.log: ../test.pl
9-
@../test.pl -p -c ${GOTO_HARNESS_EXE}
21+
@../test.pl -p -c "../chain.sh $(GOTO_CC_EXE) $(GOTO_HARNESS_EXE) $(CBMC_EXE) $(is_windows)"
1022

1123
show:
1224
@for dir in *; do \

regression/goto-harness/chain.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
goto_cc=$1
6+
goto_harness=$2
7+
cbmc=$3
8+
is_windows=$4
9+
entry_point='generated_entry_function'
10+
11+
name=${*:$#}
12+
name=${name%.c}
13+
args=${*:5:$#-5}
14+
15+
if [[ "${is_windows}" == "true" ]]; then
16+
$goto_cc "${name}.c"
17+
mv "${name}.exe" "${name}.gb"
18+
else
19+
$goto_cc -o "${name}.gb" "${name}.c"
20+
fi
21+
22+
if [ -e "${name}-mod.gb" ] ; then
23+
rm -f "${name}-mod.gb"
24+
fi
25+
26+
$goto_harness "${name}.gb" "${name}-mod.gb" --harness-function-name $entry_point ${args}
27+
$cbmc --function $entry_point "${name}-mod.gb"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <assert.h>
2+
3+
int function_to_test(int some_argument)
4+
{
5+
assert(some_argument == 0);
6+
return some_argument;
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
--harness-type call-function --function function_to_test
4+
^\[function_to_test.assertion.1\] line \d+ assertion some_argument == 0: FAILURE$
5+
^VERIFICATION FAILED$
6+
^EXIT=10$
7+
^SIGNAL=0$

regression/goto-harness/goto-harness-exists/test.desc

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ languages: util.dir langapi.dir \
4949

5050
solvers.dir: util.dir
5151

52-
goto-harness.dir: util.dir
52+
goto-harness.dir: util.dir goto-programs.dir
5353

5454
goto-instrument.dir: languages goto-programs.dir pointer-analysis.dir \
5555
goto-symex.dir linking.dir analyses.dir solvers.dir

src/goto-harness/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ add_executable(goto-harness ${sources})
33
generic_includes(goto-harness)
44

55
target_link_libraries(goto-harness
6-
util
6+
util
7+
goto-programs
78
)

src/goto-harness/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
SRC = \
2+
function_call_harness_generator.cpp \
3+
goto_harness_generator.cpp \
4+
goto_harness_generator_factory.cpp \
25
goto_harness_main.cpp \
36
goto_harness_parse_options.cpp \
47
# Empty last line
58

69
OBJ += \
710
../util/util$(LIBEXT) \
11+
../goto-programs/goto-programs$(LIBEXT) \
12+
../big-int/big-int$(LIBEXT) \
13+
../langapi/langapi$(LIBEXT) \
14+
../linking/linking$(LIBEXT) \
815
# Empty last line
916

1017
INCLUDES= -I ..

0 commit comments

Comments
 (0)