about summary refs log tree commit diff homepage
path: root/test/Runtime/POSIX/Envp.c
blob: 432aa12cf7876e59ff43b986ed12e55a988dce31 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
}