diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2017-08-09 18:31:04 +0100 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2017-08-10 19:57:32 +0100 |
commit | 4083373b5ae3d8a22b3e5672f95075477c8ae328 (patch) | |
tree | 2afd2a664bca87250c460e4dcaa6a6a1a910acc7 /test/Runtime | |
parent | 01346d9e7c4199a704c26df2a86f7d4ee26fbd2b (diff) | |
download | klee-4083373b5ae3d8a22b3e5672f95075477c8ae328.tar.gz |
Added a basic test for klee-replay
Diffstat (limited to 'test/Runtime')
-rw-r--r-- | test/Runtime/POSIX/Replay.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/Runtime/POSIX/Replay.c b/test/Runtime/POSIX/Replay.c new file mode 100644 index 00000000..ba11f05f --- /dev/null +++ b/test/Runtime/POSIX/Replay.c @@ -0,0 +1,45 @@ +// RUN: %llvmgcc -DKLEE_EXECUTION %s -emit-llvm -O0 -c -o %t.bc +// RUN: rm -rf %t.klee-out +// RUN: %klee --output-dir=%t.klee-out --posix-runtime %t.bc --sym-files 1 3 +// RUN: %klee-replay --create-files-only %t.klee-out/test000001.ktest + +// RUN: FileCheck --input-file=A --check-prefix=CREATE_FILES_ONLY %s +// CREATE_FILES_ONLY: abc + +// RUN: %cc %s -O0 -o %t2 +// RUN: %klee-replay %t2 %t.klee-out/test000001.ktest | FileCheck --check-prefix=REPLAY %s +// REPLAY: Yes + +#ifdef KLEE_EXECUTION +#define EXIT klee_silent_exit +#else +#define EXIT exit +#endif + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <assert.h> +#include <stdio.h> + +int main(int argc, char** argv) { + int fd, n; + char buf[1024]; + + fd = open("A", O_RDONLY); + assert(fd != -1); + n = read(fd, buf, 3); + assert(n == 3); + + /* Generate a single test, with the first three chars + in the file 'abc' */ + if (buf[0] == 'a' && buf[1] == 'b' && buf[2] == 'c') + printf("Yes\n"); + else + EXIT(0); + + return 0; +} + + |