From e3d84e2888b51f271f53c2b368f76f958b6ff1dc Mon Sep 17 00:00:00 2001 From: Cristian Cadar Date: Tue, 13 Aug 2019 20:58:09 +0100 Subject: Moved Gen*Bout.c tests outside the test/Runtime/POSIX directory, as they don't need POSIX support to run. --- test/Replay/klee-replay/GenBout.c | 76 ++++++++++++++++++++++++++++++ test/Replay/klee-replay/GenRandomBout.c | 83 +++++++++++++++++++++++++++++++++ test/Runtime/POSIX/GenBout.c | 76 ------------------------------ test/Runtime/POSIX/GenRandomBout.c | 83 --------------------------------- 4 files changed, 159 insertions(+), 159 deletions(-) create mode 100644 test/Replay/klee-replay/GenBout.c create mode 100644 test/Replay/klee-replay/GenRandomBout.c delete mode 100644 test/Runtime/POSIX/GenBout.c delete mode 100644 test/Runtime/POSIX/GenRandomBout.c (limited to 'test') diff --git a/test/Replay/klee-replay/GenBout.c b/test/Replay/klee-replay/GenBout.c new file mode 100644 index 00000000..1f60ed0c --- /dev/null +++ b/test/Replay/klee-replay/GenBout.c @@ -0,0 +1,76 @@ +// -- Core testing commands +// RUN: rm -rf %t.out +// RUN: rm -f %t.bout +// RUN: mkdir -p %t.out +// RUN: echo -n aaaa > %t.out/aaaa.txt +// RUN: echo -n bbbb > %t.out/bbbb.txt +// RUN: echo -n cccc > %t.out/cccc.txt +// RUN: %gen-bout -o -p -q file1 --bout-file %t.bout --sym-stdin %t.out/aaaa.txt --sym-file %t.out/bbbb.txt --sym-stdout %t.out/cccc.txt +// RUN: %cc %s -O0 -o %t +// RUN: %klee-replay %t %t.bout 2> %t.out/out.txt +// RUN: FileCheck --input-file=%t.out/out.txt %s + +// CHECK: KLEE-REPLAY: NOTE: EXIT STATUS: NORMAL + +#include +#include +#include +#include +#include +#include + +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) { + 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/Replay/klee-replay/GenRandomBout.c b/test/Replay/klee-replay/GenRandomBout.c new file mode 100644 index 00000000..0620e778 --- /dev/null +++ b/test/Replay/klee-replay/GenRandomBout.c @@ -0,0 +1,83 @@ +// -- Core testing commands +// RUN: rm -f %t.bout +// RUN: %gen-random-bout 100 -sym-arg 4 -sym-files 2 20 -sym-arg 5 -sym-stdin 8 -sym-stdout -sym-arg 6 -sym-args 1 4 5 -bout-file %t.bout +// RUN: %cc %s -O0 -o %t +// RUN: %klee-replay %t %t.bout 2> %t.out +// RUN: FileCheck --input-file=%t.out %s +// +// -- Option error handling tests +// RUN: bash -c '%gen-random-bout || :' 2>&1 | grep "Usage" +// RUN: bash -c '%gen-random-bout 0 --unexpected-option || :' 2>&1 | grep "Unexpected" +// RUN: bash -c '%gen-random-bout 100 --sym-args 5 3 || :' 2>&1 | grep "ran out of" +// RUN: bash -c '%gen-random-bout 100 --sym-args 5 3 10 || :' 2>&1 | grep "should be no more" + +// CHECK: KLEE-REPLAY: NOTE: EXIT STATUS: NORMAL + +#include +#include +#include +#include +#include +#include + +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 < 4 || argc > 7) + return 1; + + if (strlen(argv[1]) > 4) + return 1; + + if (strlen(argv[2]) > 5) + return 1; + + if (strlen(argv[3]) > 6) + return 1; + + for (i = 4; i < argc; ++i) + if (strlen(argv[i]) > 5) + return 1; + + if (check_file("A", 20) < 0) + return 1; + + if (check_file("B", 20) < 0) + return 1; + + if (check_fd(0, 8) < 0) + return 1; + + if (check_fd(1, 1024) < 0) + return 1; + + puts("All size tests passed"); + + return 0; +} diff --git a/test/Runtime/POSIX/GenBout.c b/test/Runtime/POSIX/GenBout.c deleted file mode 100644 index 1f60ed0c..00000000 --- a/test/Runtime/POSIX/GenBout.c +++ /dev/null @@ -1,76 +0,0 @@ -// -- Core testing commands -// RUN: rm -rf %t.out -// RUN: rm -f %t.bout -// RUN: mkdir -p %t.out -// RUN: echo -n aaaa > %t.out/aaaa.txt -// RUN: echo -n bbbb > %t.out/bbbb.txt -// RUN: echo -n cccc > %t.out/cccc.txt -// RUN: %gen-bout -o -p -q file1 --bout-file %t.bout --sym-stdin %t.out/aaaa.txt --sym-file %t.out/bbbb.txt --sym-stdout %t.out/cccc.txt -// RUN: %cc %s -O0 -o %t -// RUN: %klee-replay %t %t.bout 2> %t.out/out.txt -// RUN: FileCheck --input-file=%t.out/out.txt %s - -// CHECK: KLEE-REPLAY: NOTE: EXIT STATUS: NORMAL - -#include -#include -#include -#include -#include -#include - -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) { - 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/Runtime/POSIX/GenRandomBout.c b/test/Runtime/POSIX/GenRandomBout.c deleted file mode 100644 index 0620e778..00000000 --- a/test/Runtime/POSIX/GenRandomBout.c +++ /dev/null @@ -1,83 +0,0 @@ -// -- Core testing commands -// RUN: rm -f %t.bout -// RUN: %gen-random-bout 100 -sym-arg 4 -sym-files 2 20 -sym-arg 5 -sym-stdin 8 -sym-stdout -sym-arg 6 -sym-args 1 4 5 -bout-file %t.bout -// RUN: %cc %s -O0 -o %t -// RUN: %klee-replay %t %t.bout 2> %t.out -// RUN: FileCheck --input-file=%t.out %s -// -// -- Option error handling tests -// RUN: bash -c '%gen-random-bout || :' 2>&1 | grep "Usage" -// RUN: bash -c '%gen-random-bout 0 --unexpected-option || :' 2>&1 | grep "Unexpected" -// RUN: bash -c '%gen-random-bout 100 --sym-args 5 3 || :' 2>&1 | grep "ran out of" -// RUN: bash -c '%gen-random-bout 100 --sym-args 5 3 10 || :' 2>&1 | grep "should be no more" - -// CHECK: KLEE-REPLAY: NOTE: EXIT STATUS: NORMAL - -#include -#include -#include -#include -#include -#include - -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 < 4 || argc > 7) - return 1; - - if (strlen(argv[1]) > 4) - return 1; - - if (strlen(argv[2]) > 5) - return 1; - - if (strlen(argv[3]) > 6) - return 1; - - for (i = 4; i < argc; ++i) - if (strlen(argv[i]) > 5) - return 1; - - if (check_file("A", 20) < 0) - return 1; - - if (check_file("B", 20) < 0) - return 1; - - if (check_fd(0, 8) < 0) - return 1; - - if (check_fd(1, 1024) < 0) - return 1; - - puts("All size tests passed"); - - return 0; -} -- cgit 1.4.1