|
| 1 | +// RUN: %clang %s -emit-llvm %O0opt -c -o %t2.bc |
| 2 | +// RUN: rm -rf %t.klee-out |
| 3 | +// RUN: %klee --output-dir=%t.klee-out %t2.bc |
| 4 | +// RUN: rm -rf %t.klee-out |
| 5 | +// RUN: %klee --output-dir=%t.klee-out --memory-backend=fixed %t2.bc |
| 6 | +// RUN: rm -rf %t.klee-out |
| 7 | +// RUN: %klee --output-dir=%t.klee-out --memory-backend=dynamic %t2.bc |
| 8 | +// RUN: rm -rf %t.klee-out |
| 9 | +// RUN: %klee --output-dir=%t.klee-out --memory-backend=persistent %t2.bc |
| 10 | +// RUN: rm -rf %t.klee-out |
| 11 | +// RUN: %klee --output-dir=%t.klee-out --memory-backend=mixed %t2.bc |
| 12 | + |
| 13 | +/* this test is basically just for coverage and doesn't really do any |
| 14 | + correctness check (aside from testing that the various combinations |
| 15 | + don't crash) */ |
| 16 | + |
| 17 | +#include <stdlib.h> |
| 18 | + |
| 19 | +int validate(char *buf, int N) { |
| 20 | + |
| 21 | + int i; |
| 22 | + |
| 23 | + for (i = 0; i < N; i++) { |
| 24 | + if (buf[i] == 0) { |
| 25 | + return 0; |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + return 1; |
| 30 | +} |
| 31 | + |
| 32 | +#ifndef SYMBOLIC_SIZE |
| 33 | +#define SYMBOLIC_SIZE 15 |
| 34 | +#endif |
| 35 | +int main(int argc, char **argv) { |
| 36 | + int N = SYMBOLIC_SIZE; |
| 37 | + unsigned char *buf = malloc(N); |
| 38 | + int i; |
| 39 | + |
| 40 | + klee_make_symbolic(buf, N, "buf"); |
| 41 | + if (validate(buf, N)) |
| 42 | + return buf[0]; |
| 43 | + return 0; |
| 44 | +} |
| 45 | + |
| 46 | +int other_main(int argc, char **argv) { |
| 47 | + int N = SYMBOLIC_SIZE; |
| 48 | + unsigned char *buf = malloc(N); |
| 49 | + int i; |
| 50 | + |
| 51 | + klee_make_symbolic(buf, N, "buf"); |
| 52 | + if (validate(buf, N + 1)) |
| 53 | + return buf[0]; |
| 54 | + return 0; |
| 55 | +} |
0 commit comments