From 5c148a6184adfed5438534b97a88fe10bc1cde37 Mon Sep 17 00:00:00 2001 From: Cristian Cadar Date: Wed, 6 Nov 2019 22:16:09 +0000 Subject: Added test for 3-argument main. --- test/Runtime/POSIX/Envp.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/Runtime/POSIX/Envp.c 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 +#include +#include +#include + +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; +} -- cgit 1.4.1