[sanitizers] Basic realpath test
authorVitaly Buka <vitalybuka@google.com>
Wed, 25 Aug 2021 21:24:02 +0000 (14:24 -0700)
committerVitaly Buka <vitalybuka@google.com>
Wed, 25 Aug 2021 21:32:15 +0000 (14:32 -0700)
compiler-rt/test/sanitizer_common/TestCases/Posix/realpath.cpp [new file with mode: 0644]

diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/realpath.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/realpath.cpp
new file mode 100644 (file)
index 0000000..76b428b
--- /dev/null
@@ -0,0 +1,21 @@
+// RUN: %clangxx -O0 %s -o %t && %run %t m1 2>&1 | FileCheck %s
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+char buff[1 << 12];
+int main(int argc, char *argv[]) {
+  printf("REALPATH %s\n", realpath(argv[0], buff));
+  // CHECK: REALPATH /{{.+}}/realpath.cpp
+
+  char *buff2 = realpath(argv[0], nullptr);
+  printf("REALPATH %s\n", buff2);
+  // CHECK: REALPATH /{{.+}}/realpath.cpp
+  free(buff2);
+
+  buff2 = realpath(".", nullptr);
+  printf("REALPATH %s\n", buff2);
+  // CHECK: REALPATH /{{.+}}
+  free(buff2);
+}
\ No newline at end of file