Skip to content

Commit 71e6800

Browse files
author
thk123
committed
Added regression test for using --function on a GOTO program
Ensure that despite the prescence of a main method being compiled as the entry point, we can still override it using --function in CBMC.
1 parent 94b7185 commit 71e6800

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

regression/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ DIRS = ansi-c \
55
cbmc-java-inheritance \
66
cpp \
77
goto-analyzer \
8+
goto-cc-cbmc \
89
goto-diff \
910
goto-gcc \
1011
goto-instrument \

regression/goto-cc-cbmc/Makefile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
default: tests.log
2+
3+
test:
4+
@if ! ../test.pl -c ../chain.sh ; then \
5+
../failed-tests-printer.pl ; \
6+
exit 1; \
7+
fi
8+
9+
tests.log:
10+
@if ! ../test.pl -c ../chain.sh ; then \
11+
../failed-tests-printer.pl ; \
12+
exit 1; \
13+
fi
14+
15+
show:
16+
@for dir in *; do \
17+
if [ -d "$$dir" ]; then \
18+
vim -o "$$dir/*.c" "$$dir/*.out"; \
19+
fi; \
20+
done;
21+
22+
clean:
23+
@for dir in *; do \
24+
$(RM) tests.log; \
25+
if [ -d "$$dir" ]; then \
26+
cd "$$dir"; \
27+
$(RM) *.out *.gb; \
28+
cd ..; \
29+
fi \
30+
done

regression/goto-cc-cbmc/chain.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
SRC=../../../src
4+
5+
GC=$SRC/goto-cc/goto-cc
6+
CBMC=$SRC/cbmc/cbmc
7+
8+
OPTS=$1
9+
NAME=${2%.c}
10+
11+
$GC $NAME.c -o $NAME.gb
12+
$CBMC $NAME.gb $OPTS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
int fun(int x)
2+
{
3+
if(x > 0)
4+
{
5+
return x * x;
6+
}
7+
else
8+
{
9+
return x;
10+
}
11+
}
12+
13+
int main(int argc, char** argv)
14+
{
15+
if(argc>4)
16+
{
17+
return 0;
18+
}
19+
else
20+
{
21+
return 1;
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
"--function fun --cover branch"
4+
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
^x=
8+
--
9+
^warning: ignoring

0 commit comments

Comments
 (0)