Skip to content

Add tests for --div-by-zero and --signed-overflow checks for the new SMT backend #6665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions regression/cbmc-incr-smt2/bitvector-flag-tests/div_by_zero.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
int main()
{
int x = 5;
int y;
int z = 8;

// Negative case
__CPROVER_assert(x / y != 0, "This assertion is falsifiable");

// Positive case
__CPROVER_assert(
x / z != 0, "This assertion is valid under all interpretations");

return 0;
}
14 changes: 14 additions & 0 deletions regression/cbmc-incr-smt2/bitvector-flag-tests/div_by_zero.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CORE
div_by_zero.c
--incremental-smt2-solver 'z3 --smt2 -in' --div-by-zero-check --trace
\[main\.division-by-zero\.1\] line \d division by zero in x / y: FAILURE
\[main\.division-by-zero\.2\] line \d+ division by zero in x / z: SUCCESS
y=0
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
--
This test is designed to drive the `--div-by-zero-check` in both the positive
and the negative case, and show that it's working for our current implementation-in-progress
of the new SMT backend.
12 changes: 12 additions & 0 deletions regression/cbmc-incr-smt2/bitvector-flag-tests/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Flag tests

Up until this point, the tests we have for the new SMT backend focus on getting
simple arithmetic or relational operator verification runs done.

This folder contains a couple of tests that are being run with CBMC flags, adding
extra assertions such as `--div-by-zero` or `--signed-overflow-check`.

Long term the plan is for this folder to be deleted, and the tests that are being
run as part of the old SMT backend (or maybe even the whole of CBMC's regression
test suite) to be run through a label or a flag. But for now, this should do well
enough to allow us to track the progress of our completion of the new backend.
10 changes: 10 additions & 0 deletions regression/cbmc-incr-smt2/bitvector-flag-tests/signed_overflow.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <limits.h>

int main()
{
int x = INT_MAX;
int y;
int z = x + y;

__CPROVER_assert(z < INT_MIN, "This assertion is falsifiable");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
KNOWNBUG
signed_overflow.c
--incremental-smt2-solver 'z3 --smt2 -in' --signed-overflow-check --trace
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
Invariant check failed
Reason: Reached unimplemented Generation of SMT formula for unknown kind of expression: overflow-\+
--
This tests exercise the driving of the `--signed-overflow-check` flag.