| 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__));
|
|---|
| 2 | extern void __VERIFIER_assume(int);
|
|---|
| 3 | extern int __VERIFIER_nondet_int();
|
|---|
| 4 |
|
|---|
| 5 | /* This program tests that CIVL can process code like that in
|
|---|
| 6 | * SVCOMP examples with explicit branch direction. This will
|
|---|
| 7 | * be excercising the Directing Transformer as well as code
|
|---|
| 8 | * in CIVL.Slice. A run of
|
|---|
| 9 |
|
|---|
| 10 | `verify -svcomp16 stress_test.c`
|
|---|
| 11 |
|
|---|
| 12 | * followed by
|
|---|
| 13 |
|
|---|
| 14 | `replay -sliceAnalysis -direct=stress_test.direct stress_test.c`
|
|---|
| 15 |
|
|---|
| 16 | * is expected to output an interface (defined in stress_test.oracle)
|
|---|
| 17 | * to another analysis engine that can consume a sliced path
|
|---|
| 18 | * condition with a mapping from the symbolic variables to
|
|---|
| 19 | * their syntactic concrete aliases.
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 | int main () {
|
|---|
| 23 | int x = __VERIFIER_nondet_int();
|
|---|
| 24 | int y = __VERIFIER_nondet_int();
|
|---|
| 25 | int z = 0; /* Will receive symbolic read in loop */
|
|---|
| 26 | int z_0 = 0; /* Will receive symbolic read in loop */
|
|---|
| 27 | int irrelevant = 0;
|
|---|
| 28 |
|
|---|
| 29 | /* Test that different input reads in
|
|---|
| 30 | a loop are correctly transformed */
|
|---|
| 31 | for (int i = 0; i < 2; i++) {
|
|---|
| 32 | z = __VERIFIER_nondet_int();
|
|---|
| 33 | if (i == 0) {
|
|---|
| 34 | z_0 = z;
|
|---|
| 35 | }
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | /* Test that this branch which is independent
|
|---|
| 39 | of hitting the error, gets sliced away */
|
|---|
| 40 | if (y > 0) {
|
|---|
| 41 | irrelevant = 42;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | /* Test that this branch, which contains no
|
|---|
| 45 | symbolic constraints, is not counted as
|
|---|
| 46 | being sliced away */
|
|---|
| 47 | if (irrelevant > 0) {
|
|---|
| 48 | irrelevant = 42;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | if (z < 0) {
|
|---|
| 52 | if (z_0 < 0) {
|
|---|
| 53 | if (x < 0) {
|
|---|
| 54 | /* Test " while (1)" loops work with direction */
|
|---|
| 55 | while (1) {
|
|---|
| 56 | __VERIFIER_error();
|
|---|
| 57 | }
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | }
|
|---|