about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--runtime/POSIX/fd.c16
-rw-r--r--test/Runtime/POSIX/SymFileConsistency.c9
2 files changed, 22 insertions, 3 deletions
diff --git a/runtime/POSIX/fd.c b/runtime/POSIX/fd.c
index 240e589e..cfd2622f 100644
--- a/runtime/POSIX/fd.c
+++ b/runtime/POSIX/fd.c
@@ -38,6 +38,22 @@ static exe_disk_file_t *__get_sym_file(const char *pathname) {
   if (!pathname)
     return NULL;
 
+  // Handle the case where symbolic file is given as an absolute path, ie.
+  // /current/work/dir/A
+  if (pathname[0] == '/') {
+    char cwd[1024] = {0};
+    if (getcwd(cwd, 1024)) {
+      size_t cwd_len = strlen(cwd);
+      // strip trailing / if present
+      if (cwd_len > 0 && cwd[cwd_len - 1] == '/') {
+        cwd[--cwd_len] = '\0';
+      }
+      if (strncmp(pathname, cwd, cwd_len) == 0) {
+        if (pathname[cwd_len] != '\0')
+          pathname += cwd_len + 1;
+      }
+    }
+  }
   char c = pathname[0];
   unsigned i;
 
diff --git a/test/Runtime/POSIX/SymFileConsistency.c b/test/Runtime/POSIX/SymFileConsistency.c
index 7a28232f..0d4501d6 100644
--- a/test/Runtime/POSIX/SymFileConsistency.c
+++ b/test/Runtime/POSIX/SymFileConsistency.c
@@ -1,8 +1,7 @@
 // REQUIRES: posix-runtime
 // RUN: %clang %s -emit-llvm %O0opt -c -g -o %t.bc
 // RUN: rm -rf %t.klee-out-tmp
-// RUN: %gentmp %t.klee-out-tmp
-// RUN: %klee --run-in-dir=%t.klee-out-tmp --libc=uclibc --posix-runtime --exit-on-error %t.bc --sym-files 1 1 > %t1.log
+// RUN: %klee --output-dir=%t.klee-out-tmp --libc=uclibc --posix-runtime --exit-on-error %t.bc --sym-files 1 1 > %t1.log
 
 // This test checks that symbolic files can be resolved both with a relatve path 
 // ie. 'A' or by its full path ie. '/full/path/to/cwd/A'
@@ -17,10 +16,14 @@
 #include <unistd.h>
 
 int main(int argc, char **argv) {
-  struct stat s, s1;
+  struct stat s, s1, s2;
   int res = stat("A", &s);
   char cwd[1024];
   getcwd(cwd, 1024);
+  char *smallest_cwd = malloc(strlen(cwd) + 1);
+  strcpy(smallest_cwd, cwd);
+  stat(smallest_cwd, &s2);
+  free(smallest_cwd);
 
   char fullName[1024];
   snprintf(fullName, 1024, "%s/%s", cwd, "A");