Skip to content

Commit 1fd7a56

Browse files
authored
Merge pull request #6665 from NlightNFotis/flag_tests_smt_arithop
Add tests for `--div-by-zero` and `--signed-overflow` checks for the new SMT backend
2 parents c1d59c9 + 73c3952 commit 1fd7a56

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
int main()
2+
{
3+
int x = 5;
4+
int y;
5+
int z = 8;
6+
7+
// Negative case
8+
__CPROVER_assert(x / y != 0, "This assertion is falsifiable");
9+
10+
// Positive case
11+
__CPROVER_assert(
12+
x / z != 0, "This assertion is valid under all interpretations");
13+
14+
return 0;
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CORE
2+
div_by_zero.c
3+
--incremental-smt2-solver 'z3 --smt2 -in' --div-by-zero-check --trace
4+
\[main\.division-by-zero\.1\] line \d division by zero in x / y: FAILURE
5+
\[main\.division-by-zero\.2\] line \d+ division by zero in x / z: SUCCESS
6+
y=0
7+
^VERIFICATION FAILED$
8+
^EXIT=10$
9+
^SIGNAL=0$
10+
--
11+
--
12+
This test is designed to drive the `--div-by-zero-check` in both the positive
13+
and the negative case, and show that it's working for our current implementation-in-progress
14+
of the new SMT backend.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Flag tests
2+
3+
Up until this point, the tests we have for the new SMT backend focus on getting
4+
simple arithmetic or relational operator verification runs done.
5+
6+
This folder contains a couple of tests that are being run with CBMC flags, adding
7+
extra assertions such as `--div-by-zero` or `--signed-overflow-check`.
8+
9+
Long term the plan is for this folder to be deleted, and the tests that are being
10+
run as part of the old SMT backend (or maybe even the whole of CBMC's regression
11+
test suite) to be run through a label or a flag. But for now, this should do well
12+
enough to allow us to track the progress of our completion of the new backend.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <limits.h>
2+
3+
int main()
4+
{
5+
int x = INT_MAX;
6+
int y;
7+
int z = x + y;
8+
9+
__CPROVER_assert(z < INT_MIN, "This assertion is falsifiable");
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
KNOWNBUG
2+
signed_overflow.c
3+
--incremental-smt2-solver 'z3 --smt2 -in' --signed-overflow-check --trace
4+
^VERIFICATION FAILED$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
--
8+
Invariant check failed
9+
Reason: Reached unimplemented Generation of SMT formula for unknown kind of expression: overflow-\+
10+
--
11+
This tests exercise the driving of the `--signed-overflow-check` flag.

0 commit comments

Comments
 (0)