diff options
author | Andrew Santosa <santosa_1999@yahoo.com> | 2018-06-21 14:14:08 +0800 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2018-10-26 18:33:00 +0300 |
commit | be340780e6261416320dd099753e17080de69534 (patch) | |
tree | 5b0c252c821117e70d0520211a0eaf53cf4eddce /test | |
parent | 0525bd791318fe0ce2b68a7b4596f34c2770ef53 (diff) | |
download | klee-be340780e6261416320dd099753e17080de69534.tar.gz |
Added gen-bout tool to generate ktest file (file.bout) using specified concrete arguments and files.
* Sample use cases: * Using an interesting input as a seed, such as a crashing input. * Analyzing the path condition of a crashing input. * Also added the test: test/Runtime/POSIX/GenBout.c
Diffstat (limited to 'test')
-rw-r--r-- | test/Runtime/POSIX/GenBout.c | 72 | ||||
-rw-r--r-- | test/lit.cfg | 3 |
2 files changed, 74 insertions, 1 deletions
diff --git a/test/Runtime/POSIX/GenBout.c b/test/Runtime/POSIX/GenBout.c new file mode 100644 index 00000000..44979735 --- /dev/null +++ b/test/Runtime/POSIX/GenBout.c @@ -0,0 +1,72 @@ +// RUN: rm -rf file.bout +// RUN: echo -n aaaa > %t.aaaa.txt +// RUN: echo -n bbbb > %t.bbbb.txt +// RUN: echo -n cccc > %t.cccc.txt +// RUN: %gen-bout -o -p -q file1 --sym-stdin %t.aaaa.txt --sym-file %t.bbbb.txt --sym-stdout %t.cccc.txt +// RUN: %cc %s -O0 -o %t +// RUN: %klee-replay %t file.bout 2>&1 | grep "klee-replay: EXIT STATUS: NORMAL" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +int check_fd(int fd, const int file_size) { + struct stat fs; + + if (fstat(fd, &fs) < 0) + return -1; + + if (fs.st_size != file_size) + return -1; + + return 0; +} + +int check_file(const char *file_name, const int file_size) { + int fd; + + if ((fd = open(file_name, O_RDONLY)) < 0) + return -1; + + if (check_fd(fd, file_size) < 0) + return -1; + + close(fd); + return 0; +} + +int main(int argc, char **argv) { + int i = 0; + + if (argc != 5) + return 1; + + if (strcmp(argv[1], "-o")) + return 1; + + if (strcmp(argv[2], "-p")) + return 1; + + if (strcmp(argv[3], "-q")) + return 1; + + if (strcmp(argv[4], "file1")) + return 1; + + if (check_file("A", 4)) + return 1; + + if (check_fd(0, 4)) + return 1; + + if (check_fd(1, 1024)) + return 1; + + printf("tests passed\n"); + + return 0; +} + diff --git a/test/lit.cfg b/test/lit.cfg index a9982150..4913fa5f 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -138,7 +138,8 @@ if len(kleaver_extra_params) != 0: subs = [ ('%kleaver', 'kleaver', kleaver_extra_params), ('%klee-replay', 'klee-replay', ''), ('%klee','klee', klee_extra_params), - ('%ktest-tool', 'ktest-tool', '') + ('%ktest-tool', 'ktest-tool', ''), + ('%gen-bout', 'gen-bout', '') ] for s,basename,extra_args in subs: config.substitutions.append( |