Skip to content

Commit 9683ddc

Browse files
committed
Add regression test to check that linking succeeds
Simple test of calling a function defined in a separate binary. First compile both with goto-cc and then call cbmc on the two binaries.
1 parent a2f7478 commit 9683ddc

File tree

9 files changed

+103
-0
lines changed

9 files changed

+103
-0
lines changed

regression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ add_subdirectory(systemc)
5151
add_subdirectory(contracts)
5252
add_subdirectory(goto-harness)
5353
add_subdirectory(goto-cc-file-local)
54+
add_subdirectory(linking-goto-binaries)

regression/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ DIRS = cbmc \
2626
systemc \
2727
contracts \
2828
goto-cc-file-local \
29+
linking-goto-binaries \
2930
# Empty last line
3031

3132
# Run all test directories in sequence
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if(WIN32)
2+
set(is_windows true)
3+
else()
4+
set(is_windows false)
5+
endif()
6+
7+
add_test_pl_tests(
8+
"../chain.sh \
9+
$<TARGET_FILE:goto-cc> \
10+
$<TARGET_FILE:cbmc> \
11+
${is_windows}")
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
default: tests.log
2+
3+
include ../../src/config.inc
4+
include ../../src/common
5+
6+
GOTO_CC_EXE=../../../src/goto-cc/goto-cc
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+
17+
test:
18+
@../test.pl -e -p -c "../chain.sh $(GOTO_CC_EXE) $(CBMC_EXE) $(is_windows)"
19+
20+
tests.log: ../test.pl
21+
@../test.pl -e -p -c "../chain.sh $(GOTO_CC_EXE) $(CBMC_EXE) $(is_windows)"
22+
23+
show:
24+
@for dir in *; do \
25+
if [ -d "$$dir" ]; then \
26+
vim -o "$$dir/*.c" "$$dir/*.out"; \
27+
fi; \
28+
done;
29+
30+
clean:
31+
find -name '*.out' -execdir $(RM) '{}' \;
32+
find -name '*.gb' -execdir $(RM) {} \;
33+
$(RM) tests.log
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
goto_cc=$1
6+
cbmc=$2
7+
is_windows=$3
8+
entry_point='generated_entry_function'
9+
10+
main=${*:$#}
11+
main=${main%.c}
12+
args=${*:4:$#-4}
13+
next=${args%.c}
14+
15+
if [[ "${is_windows}" == "true" ]]; then
16+
$goto_cc "${main}.c"
17+
$goto_cc "${next}.c"
18+
mv "${main}.exe" "${main}.gb"
19+
mv "${next}.exe" "${next}.gb"
20+
else
21+
$goto_cc -o "${main}.gb" "${main}.c"
22+
$goto_cc -o "${next}.gb" "${next}.c"
23+
fi
24+
25+
$cbmc "${main}.gb" "${next}.gb"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "supp.h"
2+
#include <assert.h>
3+
4+
const int five = 5;
5+
6+
int main()
7+
{
8+
int ten = times_two(five);
9+
assert(ten == 10);
10+
return 0;
11+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "supp.h"
2+
3+
int times_two(int i)
4+
{
5+
return 2 * i;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef SUPP_H
2+
#define SUPP_H
3+
4+
int times_two(int i);
5+
6+
#endif // SUPP_H
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
supp.c
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
\[main.assertion.1\] line [0-9]+ assertion ten == 10: SUCCESS
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
^warning: ignoring

0 commit comments

Comments
 (0)