diff options
-rw-r--r-- | tools/klee-replay/file-creator.c | 3 | ||||
-rw-r--r-- | tools/klee-replay/klee-replay.c | 62 | ||||
-rw-r--r-- | tools/klee-replay/klee-replay.h | 3 |
3 files changed, 41 insertions, 27 deletions
diff --git a/tools/klee-replay/file-creator.c b/tools/klee-replay/file-creator.c index 6440b414..f6a077c2 100644 --- a/tools/klee-replay/file-creator.c +++ b/tools/klee-replay/file-creator.c @@ -478,6 +478,9 @@ int remove_callback(const char *fpath, } void replay_delete_files() { + if (keep_temps) + return; + fprintf(stderr, "KLEE-REPLAY: NOTE: removing %s\n", replay_dir); if (nftw(replay_dir, remove_callback, FOPEN_MAX, diff --git a/tools/klee-replay/klee-replay.c b/tools/klee-replay/klee-replay.c index 9f5acef8..33c28d22 100644 --- a/tools/klee-replay/klee-replay.c +++ b/tools/klee-replay/klee-replay.c @@ -48,6 +48,7 @@ static struct option long_options[] = { {"create-files-only", required_argument, 0, 'f'}, {"chroot-to-dir", required_argument, 0, 'r'}, {"help", no_argument, 0, 'h'}, + {"keep-replay-dir", no_argument, 0, 'k'}, {0, 0, 0, 0}, }; @@ -257,12 +258,16 @@ static void usage(void) { fprintf(stderr, " or: %s --create-files-only <ktest-file>\n", progname); fprintf(stderr, "\n"); fprintf(stderr, "-r, --chroot-to-dir=DIR use chroot jail, requires CAP_SYS_CHROOT\n"); + fprintf(stderr, "-k, --keep-replay-dir do not delete replay directory\n"); fprintf(stderr, "-h, --help display this help and exit\n"); fprintf(stderr, "\n"); fprintf(stderr, "Use KLEE_REPLAY_TIMEOUT environment variable to set a timeout (in seconds).\n"); exit(1); } + +int keep_temps = 0; + int main(int argc, char** argv) { int prg_argc; char ** prg_argv; @@ -273,35 +278,38 @@ int main(int argc, char** argv) { usage(); int c, opt_index; - while ((c = getopt_long(argc, argv, "f:r:", long_options, &opt_index)) != -1) { + while ((c = getopt_long(argc, argv, "f:r:k", long_options, &opt_index)) != -1) { switch (c) { - case 'f': { - /* Special case hack for only creating files and not actually executing - * the program. - */ - if (argc != 3) - usage(); - - char* input_fname = optarg; - - input = kTest_fromFile(input_fname); - if (!input) { - fprintf(stderr, "KLEE-REPLAY: ERROR: input file %s not valid.\n", - input_fname); - exit(1); - } - - prg_argc = input->numArgs; - prg_argv = input->args; - prg_argv[0] = argv[1]; - klee_init_env(&prg_argc, &prg_argv); - - replay_create_files(&__exe_fs); - return 0; + case 'f': { + /* Special case hack for only creating files and not actually executing + * the program. */ + if (argc != 3) + usage(); + + char *input_fname = optarg; + + input = kTest_fromFile(input_fname); + if (!input) { + fprintf(stderr, "KLEE-REPLAY: ERROR: input file %s not valid.\n", input_fname); + exit(1); } - case 'r': - rootdir = optarg; - break; + + prg_argc = input->numArgs; + prg_argv = input->args; + prg_argv[0] = argv[1]; + klee_init_env(&prg_argc, &prg_argv); + + replay_create_files(&__exe_fs); + return 0; + } + + case 'r': + rootdir = optarg; + break; + + case 'k': + keep_temps = 1; + break; } } diff --git a/tools/klee-replay/klee-replay.h b/tools/klee-replay/klee-replay.h index 8dc3b872..5701caa5 100644 --- a/tools/klee-replay/klee-replay.h +++ b/tools/klee-replay/klee-replay.h @@ -21,6 +21,9 @@ // temporary directory used for replay extern char replay_dir[]; +// whether to keep the replay directory or delete it +extern int keep_temps; + void replay_create_files(exe_file_system_t *exe_fs); void replay_delete_files(); |