Skip to content

Commit ebcad79

Browse files
committed
Add a test for the new SMT backend that exercises the flag --div-by-zero-check
under signed integer division.
1 parent e831f43 commit ebcad79

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-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.

0 commit comments

Comments
 (0)