|
| 1 | +// RUN: %clang -Wno-everything %s -emit-llvm %O0opt -g -c -o %t1.bc |
| 2 | +// RUN: rm -rf %t.klee-out |
| 3 | +// RUN: %klee --output-dir=%t.klee-out --optimize-aggressive=false --track-coverage=all --max-cycles=2 --optimize=true --emit-all-errors --delete-dead-loops=false --use-forked-solver=false -max-memory=6008 --cex-cache-validity-cores --only-output-states-covering-new=true --dump-states-on-halt=true --use-sym-size-alloc=true --symbolic-allocation-threshold=8192 %t1.bc 2>&1 |
| 4 | + |
| 5 | +// RUN: rm -f %t*.gcda %t*.gcno %t*.gcov |
| 6 | +// RUN: %cc -DGCOV %s %libkleeruntest -Wl,-rpath %libkleeruntestdir -o %t_runner --coverage |
| 7 | +// RUN: %replay %t.klee-out %t_runner |
| 8 | +// RUN: gcov -b %t_runner-%basename_t > %t.cov.log |
| 9 | + |
| 10 | +// RUN: FileCheck --input-file=%t.cov.log --check-prefix=CHECK-COV %s |
| 11 | + |
| 12 | +// Branch coverage is greater 80%: |
| 13 | +// CHECK-COV: Lines executed:9{{([0-9]\.[0-9][0-9])}}% of 24 |
| 14 | +// CHECK-COV-NEXT: Branches executed:100.00% of 16 |
| 15 | +// CHECK-COV-NEXT: Taken at least once:{{([8-9][0-9]\.[0-9][0-9])}}% of 16 |
| 16 | + |
| 17 | +#include "klee-test-comp.c" |
| 18 | + |
| 19 | +extern void exit(int); |
| 20 | +extern void abort(void); |
| 21 | +#ifdef GCOV |
| 22 | +extern void __gcov_dump(void); |
| 23 | +#endif |
| 24 | + |
| 25 | +void dump() { |
| 26 | +#ifdef GCOV |
| 27 | + __gcov_dump(); |
| 28 | + exit(0); |
| 29 | +#endif |
| 30 | +} |
| 31 | + |
| 32 | +extern void __assert_fail(const char *, const char *, unsigned int, const char *) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); |
| 33 | +void reach_error() { dump(); __assert_fail("0", "matrix-2-2.c", 3, "reach_error"); } |
| 34 | + |
| 35 | +void __VERIFIER_assert(int cond) { |
| 36 | + if (!(cond)) { |
| 37 | + ERROR: {reach_error();abort();} |
| 38 | + } |
| 39 | + return; |
| 40 | +} |
| 41 | +extern unsigned int __VERIFIER_nondet_uint(); |
| 42 | +extern int __VERIFIER_nondet_int(); |
| 43 | + |
| 44 | +int main() |
| 45 | +{ |
| 46 | + unsigned int N_LIN=__VERIFIER_nondet_uint(); |
| 47 | + unsigned int N_COL=__VERIFIER_nondet_uint(); |
| 48 | + if (N_LIN >= 4000000000 / sizeof(int) || N_COL >= 4000000000 / sizeof(int)) { |
| 49 | + return 0; |
| 50 | + } |
| 51 | + unsigned int j,k; |
| 52 | + int matriz[N_COL][N_LIN], maior; |
| 53 | + |
| 54 | + maior = __VERIFIER_nondet_int(); |
| 55 | + for(j=0;j<N_COL;j++) |
| 56 | + for(k=0;k<N_LIN;k++) |
| 57 | + { |
| 58 | + matriz[j][k] = __VERIFIER_nondet_int(); |
| 59 | + |
| 60 | + if(matriz[j][k]>maior) |
| 61 | + maior = matriz[j][k]; |
| 62 | + } |
| 63 | + |
| 64 | + for(j=0;j<N_COL;j++) |
| 65 | + for(k=0;k<N_LIN;k++) |
| 66 | + __VERIFIER_assert(matriz[j][k]<maior); |
| 67 | +} |
| 68 | + |
0 commit comments