diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2019-08-09 17:58:38 +0100 |
---|---|---|
committer | MartinNowack <martin.nowack@gmail.com> | 2019-08-14 16:26:48 +0100 |
commit | 8426b2913e650970d46be9a4d088bf3945f41453 (patch) | |
tree | 38e758dfe3abcf9d93fc96c438d6aab72c3ff92b | |
parent | d50698f1b543b520af1cea0218e6ea8571faaa10 (diff) | |
download | klee-8426b2913e650970d46be9a4d088bf3945f41453.tar.gz |
Create all files in the replay directory and chdir to this directory before executing the program.
-rw-r--r-- | test/Runtime/POSIX/Replay.c | 3 | ||||
-rw-r--r-- | tools/klee-replay/file-creator.c | 18 | ||||
-rw-r--r-- | tools/klee-replay/klee-replay.c | 5 |
3 files changed, 16 insertions, 10 deletions
diff --git a/test/Runtime/POSIX/Replay.c b/test/Runtime/POSIX/Replay.c index 851b5a1e..61862c5f 100644 --- a/test/Runtime/POSIX/Replay.c +++ b/test/Runtime/POSIX/Replay.c @@ -3,9 +3,6 @@ // 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 diff --git a/tools/klee-replay/file-creator.c b/tools/klee-replay/file-creator.c index f6a077c2..6e32630f 100644 --- a/tools/klee-replay/file-creator.c +++ b/tools/klee-replay/file-creator.c @@ -295,6 +295,8 @@ static int create_reg_file(const char *fname, exe_disk_file_t *dfile, unsigned flen = dfile->size; unsigned mode = s->st_mode & 0777; + fprintf(stderr, "KLEE-REPLAY: NOTE: Creating file %s of length %d\n", fname, flen); + // Open in RDWR just in case we have to end up using this fd. if (__exe_env.version == 0 && mode == 0) mode = 0644; @@ -375,12 +377,11 @@ static void create_file(int target_fd, assert((target_fd == -1) ^ (target_name == NULL)); - if (target_name) { - target = target_name; - } else { - sprintf(tmpname, "%s/fd%d", tmpdir, target_fd); - target = tmpname; - } + if (target_name) + sprintf(tmpname, "%s/%s", tmpdir, target_name); + else sprintf(tmpname, "%s/fd%d", tmpdir, target_fd); + + target = tmpname; delete_file(target, 1); @@ -494,6 +495,7 @@ static void check_file(int index, exe_disk_file_t *dfile) { struct stat s; int res; char name[32]; + char fullname[PATH_MAX]; switch (index) { case __STDIN: @@ -507,7 +509,9 @@ static void check_file(int index, exe_disk_file_t *dfile) { default: name[0] = 'A' + index; name[1] = '\0'; - res = stat(name, &s); + sprintf(fullname, "%s/%s", replay_dir, name); + res = stat(fullname, &s); + break; } diff --git a/tools/klee-replay/klee-replay.c b/tools/klee-replay/klee-replay.c index 33c28d22..f285ebf9 100644 --- a/tools/klee-replay/klee-replay.c +++ b/tools/klee-replay/klee-replay.c @@ -191,6 +191,11 @@ static void run_monitored(char *executable, int argc, char **argv) { #endif if (!rootdir) { + if (chdir(replay_dir) != 0) { + perror("chdir"); + _exit(66); + } + execv(executable, argv); perror("execv"); _exit(66); |