[compiler-rt] r323834 - [sanitizer] Fix tests on Android and Darwin

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 15:51:44 PST 2018


Author: vitalybuka
Date: Tue Jan 30 15:51:44 2018
New Revision: 323834

URL: http://llvm.org/viewvc/llvm-project?rev=323834&view=rev
Log:
[sanitizer] Fix tests on Android and Darwin

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
    compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/name_to_handle_at.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/readlinkat.c
    compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/readlink.c

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h?rev=323834&r1=323833&r2=323834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Tue Jan 30 15:51:44 2018
@@ -442,10 +442,17 @@
 #define SANITIZER_INTERCEPT_FACCESSAT SI_NETBSD
 #define SANITIZER_INTERCEPT_GETGROUPLIST SI_NETBSD
 
-#define SANITIZER_INTERCEPT_NAME_TO_HANDLE_AT SI_LINUX
-#define SANITIZER_INTERCEPT_OPEN_BY_HANDLE_AT SI_LINUX
+#define SANITIZER_INTERCEPT_NAME_TO_HANDLE_AT SI_LINUX_NOT_ANDROID
+#define SANITIZER_INTERCEPT_OPEN_BY_HANDLE_AT SI_LINUX_NOT_ANDROID
 
 #define SANITIZER_INTERCEPT_READLINK SI_POSIX
-#define SANITIZER_INTERCEPT_READLINKAT SI_POSIX
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101000
+# define SI_MAC_DEPLOYMENT_BELOW_10_10 1
+#else
+# define SI_MAC_DEPLOYMENT_BELOW_10_10 0
+#endif
+#define SANITIZER_INTERCEPT_READLINKAT \
+  (SI_POSIX && !SI_MAC_DEPLOYMENT_BELOW_10_10)
 
 #endif  // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/name_to_handle_at.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/name_to_handle_at.cc?rev=323834&r1=323833&r2=323834&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/name_to_handle_at.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/name_to_handle_at.cc Tue Jan 30 15:51:44 2018
@@ -1,4 +1,5 @@
 // RUN: %clangxx -O0 %s -o %t && %run %t
+// UNSUPPORTED: android
 
 #include <assert.h>
 #include <fcntl.h>

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/readlinkat.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/readlinkat.c?rev=323834&r1=323833&r2=323834&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/readlinkat.c (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/readlinkat.c Tue Jan 30 15:51:44 2018
@@ -2,19 +2,19 @@
 
 #include <assert.h>
 #include <fcntl.h>
-#include <linux/limits.h>
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 
 int main(int argc, char **argv) {
-  char symlink_path[PATH_MAX];
+  char symlink_path[NAME_MAX];
   snprintf(symlink_path, sizeof(symlink_path), "%s_%d.symlink", argv[0],
            getpid());
   int res = symlink(argv[0], symlink_path);
   assert(!res);
 
-  char readlinkat_path[PATH_MAX];
+  char readlinkat_path[NAME_MAX];
   int res2 = readlinkat(AT_FDCWD, symlink_path, readlinkat_path,
                         sizeof(readlinkat_path));
   assert(res2 >= 0);

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/readlink.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/readlink.c?rev=323834&r1=323833&r2=323834&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/readlink.c (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/readlink.c Tue Jan 30 15:51:44 2018
@@ -2,26 +2,26 @@
 
 #include <assert.h>
 #include <fcntl.h>
-#include <linux/limits.h>
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
 
 int main(int argc, char **argv) {
-  char symlink_path[PATH_MAX];
+  char symlink_path[NAME_MAX];
   snprintf(symlink_path, sizeof(symlink_path), "%s_%d.symlink", argv[0],
            getpid());
   int res = symlink(argv[0], symlink_path);
   assert(!res);
 
-  char readlink_path[PATH_MAX];
+  char readlink_path[NAME_MAX];
   ssize_t res2 = readlink(symlink_path, readlink_path, sizeof(readlink_path));
   assert(res2 >= 0);
   readlink_path[res2] = '\0';
   assert(!strcmp(readlink_path, argv[0]));
 
-  char readlinkat_path[PATH_MAX];
+  char readlinkat_path[NAME_MAX];
   res2 = readlinkat(AT_FDCWD, symlink_path, readlinkat_path,
                     sizeof(readlink_path));
   assert(res2 >= 0);




More information about the llvm-commits mailing list