Skip to content

Commit 2f09338

Browse files
Update from branch 'master' of https://github.com/diffblue/cbmc
2 parents fbc712c + 1029635 commit 2f09338

File tree

104 files changed

+1930
-596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1930
-596
lines changed

.travis.yml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,48 @@
11
language: cpp
22

3-
os:
4-
- linux
5-
- osx
63
sudo: required
74

5+
matrix:
6+
include:
7+
- os: linux
8+
dist: trusty
9+
compiler: clang
10+
addons:
11+
apt:
12+
sources:
13+
- ubuntu-toolchain-r-test
14+
packages:
15+
# newer g++ version (also pulls libstdc++)
16+
- g++-4.9
17+
- libwww-perl
18+
- os: linux
19+
dist: trusty
20+
compiler: gcc
21+
addons:
22+
apt:
23+
sources:
24+
- ubuntu-toolchain-r-test
25+
packages:
26+
# newer g++ version (also pulls libstdc++)
27+
- g++-4.9
28+
- libwww-perl
29+
before_install:
30+
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 90
31+
- os: osx
32+
compiler: clang
33+
- os: osx
34+
compiler: gcc
35+
836
addons:
937
apt:
1038
packages:
1139
- libwww-perl
1240

13-
compiler:
14-
- gcc
15-
- clang
16-
17-
before_install:
18-
- if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ] ; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get -qq update && sudo apt-get -qq install g++-4.8 gcc-4.8 && sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90 && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 90 ; fi
19-
20-
install:
21-
- chmod a+x regression/failed-tests-printer.pl
22-
- cd src && make minisat2-download
23-
2441
script:
25-
- make CXXFLAGS="-Wall -O2 -g -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare" -j2 && cd ../regression && make test
42+
- make -C src minisat2-download
43+
- make -C src CXXFLAGS="-Wall -O2 -g -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare" -j2 && make -C regression test
2644

2745
matrix:
2846
include:
2947
- env: NAME="CPP-LINT"
30-
script: cd .. && python scripts/cpplint.py `git diff --name-only master HEAD`
48+
script: DIFF=`git diff --name-only master HEAD` && if [ "$DIFF" != "" ]; then python scripts/cpplint.py $DIFF; fi

COMPILING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ We assume that you have a Debian/Ubuntu or Red Hat-like distribution.
3838

3939
yum install gcc gcc-c++ flex bison perl-libwww-perl patch
4040

41+
Note that you need g++ version 4.9 or newer.
42+
4143
1) As a user, get the CBMC source via
4244

4345
git clone https://github.com/diffblue/cbmc cbmc-git

regression/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DIRS = ansi-c cbmc cpp goto-instrument
1+
DIRS = ansi-c cbmc cpp goto-instrument goto-instrument-unwind
22

33
test:
44
$(foreach var,$(DIRS), $(MAKE) -C $(var) test || exit 1;)

regression/cbmc/Float-to-int1/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <assert.h>
2+
3+
double nondet_double();
4+
5+
int main(void)
6+
{
7+
double d = nondet_double();
8+
9+
__CPROVER_assume(d < 0x1.0p+63 && d > 0x1.0p+53);
10+
11+
long long int i = d;
12+
double d1 = i;
13+
14+
assert(d1 != 0x0);
15+
16+
return 0;
17+
}
18+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--floatbv
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/cbmc/Float-to-int2/main.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <assert.h>
2+
3+
int nondet_int();
4+
double nondet_double();
5+
6+
int main(void)
7+
{
8+
int i = nondet_int();
9+
double di = (double)i;
10+
int j = (int)di;
11+
12+
assert(i == j);
13+
14+
return 0;
15+
}
16+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--floatbv
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/cbmc/Float-to-int3/main.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <assert.h>
2+
#include <stdint.h>
3+
4+
int64_t nondet_int64_t();
5+
double nondet_double();
6+
7+
int main(void)
8+
{
9+
int64_t i = nondet_int64_t();
10+
11+
__CPROVER_assume((i & (int64_t)0x7FF) == (int64_t)0);
12+
13+
double di = (double)i;
14+
int64_t j = (int64_t)di;
15+
16+
assert(i == j);
17+
18+
return 0;
19+
}
20+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--floatbv
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/goto-instrument-unwind/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ tests.log: ../test.pl
2121
clean:
2222
@for dir in *; do \
2323
if [ -d "$$dir" ]; then \
24-
rm $$dir/*.txt $$dir/*.dot $$dir/*.gb $$dir/*.out; \
24+
rm -f $$dir/*.txt $$dir/*.dot $$dir/*.gb $$dir/*.out; \
2525
fi; \
26-
done;
26+
done;
27+
rm -f tests.log
2728

2829
show:
2930
@for dir in *; do \
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
int main()
3+
{
4+
int i;
5+
for(i = 0; i < 10; i++) {}
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--unwind 10 --unwinding-assertions
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
int main()
3+
{
4+
int i;
5+
for(i = 0; i < 10; i++) {}
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
--unwind 9 --unwinding-assertions
4+
^SIGNAL=0$
5+
^VERIFICATION FAILED$
6+
--
7+
^warning: ignoring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
int main()
3+
{
4+
int i;
5+
i = 0;
6+
do {
7+
i++;
8+
} while(i < 10);
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--unwind 10 --unwinding-assertions
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
int main()
3+
{
4+
int i;
5+
for(i = 0; i < 10; i++) {}
6+
assert(0);
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+
--unwind 10
4+
^SIGNAL=0$
5+
^VERIFICATION FAILED$
6+
--
7+
^warning: ignoring
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
int main()
3+
{
4+
int i;
5+
for(i = 0; i < 10; i++) {}
6+
assert(0);
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--unwind 9
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/goto-instrument-unwind/break-loop1/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CORE
22
main.c
3-
10
3+
--unwind 10 --partial-loops
4+
^EXIT=0$
45
^SIGNAL=0$
56
^VERIFICATION SUCCESSFUL$
67
--

regression/goto-instrument-unwind/break-loop2/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CORE
22
main.c
3-
100
3+
--unwind 100 --partial-loops
4+
^EXIT=0$
45
^SIGNAL=0$
56
^VERIFICATION SUCCESSFUL$
67
--
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
int main()
3+
{
4+
int i;
5+
for(i = 0; i < 10; i++) {}
6+
assert(i==10);
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--unwind 5 --continue-as-loops
4+
^Unwinding loop.*iteration 5
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
^warning: ignoring
10+
^Unwinding loop.*iteration 6

regression/goto-instrument-unwind/continue-loop1/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CORE
22
main.c
3-
10
3+
--unwind 10 --partial-loops
4+
^EXIT=0$
45
^SIGNAL=0$
56
^VERIFICATION SUCCESSFUL$
67
--

regression/goto-instrument-unwind/continue-loop2/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CORE
22
main.c
3-
100
3+
--unwind 100 --partial-loops
4+
^EXIT=0$
45
^SIGNAL=0$
56
^VERIFICATION SUCCESSFUL$
67
--
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
void f() {}
3+
4+
int main()
5+
{
6+
/**
7+
* This is a test case for the unwind operation of goto-instrument;
8+
* every loop will be unwound K times
9+
**/
10+
const unsigned K=10;
11+
12+
const unsigned n=100;
13+
unsigned c=0, i;
14+
15+
i=1;
16+
do
17+
{
18+
f();
19+
c++;
20+
i++;
21+
} while(i<=n);
22+
23+
unsigned eva=n;
24+
if(K<eva) eva=K;
25+
26+
__CPROVER_assert(c==eva, "do-while loop unwind (1)");
27+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--unwind 10 --partial-loops
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
void f() {}
3+
4+
int main()
5+
{
6+
/**
7+
* This is a test case for the unwind operation of goto-instrument;
8+
* every loop will be unwound K times
9+
**/
10+
const unsigned K=100;
11+
12+
const unsigned n=10;
13+
unsigned c=0, i;
14+
15+
i=1;
16+
do
17+
{
18+
f();
19+
c++;
20+
i++;
21+
} while(i<=n);
22+
23+
unsigned eva=n;
24+
if(K<eva) eva=K;
25+
26+
__CPROVER_assert(c==eva, "do-while loop unwind (1)");
27+
28+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--unwind 100 --partial-loops
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/goto-instrument-unwind/empty-loop1/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CORE
22
main.c
3-
10
3+
--unwind 10 --partial-loops
4+
^EXIT=0$
45
^SIGNAL=0$
56
^VERIFICATION SUCCESSFUL$
67
--

0 commit comments

Comments
 (0)