diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2019-11-06 22:16:09 +0000 |
---|---|---|
committer | MartinNowack <martin.nowack@gmail.com> | 2019-11-07 09:20:49 +0000 |
commit | 5c148a6184adfed5438534b97a88fe10bc1cde37 (patch) | |
tree | fb20e9d2ad51462a2a7311a6a6372d583997faa5 | |
parent | 968721e74fb48331af90446419b703a717954fa9 (diff) | |
download | klee-5c148a6184adfed5438534b97a88fe10bc1cde37.tar.gz |
Added test for 3-argument main.
-rw-r--r-- | test/Runtime/POSIX/Envp.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Runtime/POSIX/Envp.c b/test/Runtime/POSIX/Envp.c new file mode 100644 index 00000000..432aa12c --- /dev/null +++ b/test/Runtime/POSIX/Envp.c @@ -0,0 +1,27 @@ +// RUN: %clang %s -emit-llvm %O0opt -c -o %t.bc +// RUN: rm -rf %t.klee-out +// RUN: %klee --output-dir=%t.klee-out --exit-on-error --posix-runtime --libc=uclibc %t.bc >%t.log + +/* This test checks that main() with 3 arguments is supported, and that the data in envp for $HOME is consistent with getenv("HOME") */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <assert.h> + +int main(int argcPtr, char **argvPtr, char** envp) { + + char* home1 = getenv("HOME"); + printf("home1 = %s\n", home1); + + char* home2 = "invalid$home"; + while (*envp) { + if (strncmp(*envp, "HOME", 4) == 0) + home2 = *envp + 5; + envp++; + } + printf("home2 = %s\n", home2); + assert(strcmp(home1, home2) == 0); + + return 0; +} |