From fa5367b92e379886eda68d8c754d1abcf1c5aa66 Mon Sep 17 00:00:00 2001 From: Cristian Cadar Date: Fri, 25 Mar 2022 22:29:36 +0000 Subject: Updated tests to use ktest-randgen instead of gen-random-bout --- test/CMakeLists.txt | 2 +- test/Replay/klee-replay/GenRandomBout.c | 93 --------------------------------- test/Replay/klee-replay/KTestRandGen.c | 93 +++++++++++++++++++++++++++++++++ test/lit.cfg | 2 +- 4 files changed, 95 insertions(+), 95 deletions(-) delete mode 100644 test/Replay/klee-replay/GenRandomBout.c create mode 100644 test/Replay/klee-replay/KTestRandGen.c diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 42b28a7c..6a625935 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -151,7 +151,7 @@ file(GENERATE add_custom_target(systemtests COMMAND "${LIT_TOOL}" ${LIT_ARGS} "${CMAKE_CURRENT_BINARY_DIR}" - DEPENDS klee kleaver klee-replay kleeRuntest ktest-gen gen-random-bout + DEPENDS klee kleaver klee-replay kleeRuntest ktest-gen ktest-randgen COMMENT "Running system tests" USES_TERMINAL ) diff --git a/test/Replay/klee-replay/GenRandomBout.c b/test/Replay/klee-replay/GenRandomBout.c deleted file mode 100644 index 9f609a40..00000000 --- a/test/Replay/klee-replay/GenRandomBout.c +++ /dev/null @@ -1,93 +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 -// CHECK: KLEE-REPLAY: NOTE: EXIT STATUS: NORMAL -// -// -- Option error handling tests -// RUN: not %gen-random-bout 2> %t1 -// RUN: FileCheck -check-prefix=CHECK-USAGE -input-file=%t1 %s -// CHECK-USAGE: Usage -// -// RUN: not %gen-random-bout 0 --unexpected-option 2> %t2 -// RUN: FileCheck -check-prefix=CHECK-UNEXPECTED -input-file=%t2 %s -// CHECK-UNEXPECTED: Unexpected -// -// RUN: not %gen-random-bout 100 --sym-args 5 3 2> %t3 -// RUN: FileCheck -check-prefix=CHECK-RANOUT -input-file=%t3 %s -// CHECK-RANOUT: ran out of -// -// RUN: not %gen-random-bout 100 --sym-args 5 3 10 2> %t4 -// RUN: FileCheck -check-prefix=CHECK-NOMORE -input-file=%t4 %s -// CHECK-NOMORE: should be no more - -#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/Replay/klee-replay/KTestRandGen.c b/test/Replay/klee-replay/KTestRandGen.c new file mode 100644 index 00000000..fdb8c15a --- /dev/null +++ b/test/Replay/klee-replay/KTestRandGen.c @@ -0,0 +1,93 @@ +// -- Core testing commands +// RUN: rm -f %t.bout +// RUN: %ktest-randgen 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 +// CHECK: KLEE-REPLAY: NOTE: EXIT STATUS: NORMAL +// +// -- Option error handling tests +// RUN: not %ktest-randgen 2> %t1 +// RUN: FileCheck -check-prefix=CHECK-USAGE -input-file=%t1 %s +// CHECK-USAGE: Usage +// +// RUN: not %ktest-randgen 0 --unexpected-option 2> %t2 +// RUN: FileCheck -check-prefix=CHECK-UNEXPECTED -input-file=%t2 %s +// CHECK-UNEXPECTED: Unexpected +// +// RUN: not %ktest-randgen 100 --sym-args 5 3 2> %t3 +// RUN: FileCheck -check-prefix=CHECK-RANOUT -input-file=%t3 %s +// CHECK-RANOUT: ran out of +// +// RUN: not %ktest-randgen 100 --sym-args 5 3 10 2> %t4 +// RUN: FileCheck -check-prefix=CHECK-NOMORE -input-file=%t4 %s +// CHECK-NOMORE: should be no more + +#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/lit.cfg b/test/lit.cfg index c44575c0..cd56527c 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -135,7 +135,7 @@ subs = [ ('%kleaver', 'kleaver', kleaver_extra_params), ('%klee-zesti', 'klee-zesti', ''), ('%klee','klee', klee_extra_params), ('%ktest-tool', 'ktest-tool', ''), - ('%gen-random-bout', 'gen-random-bout', ''), + ('%ktest-randgen', 'ktest-randgen', ''), ('%ktest-gen', 'ktest-gen', '') ] for s,basename,extra_args in subs: -- cgit 1.4.1