[compiler-rt] 03d593d - [sanitizers][test] Test sanitizer_common and ubsan_minimal on Solaris

Rainer Orth via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 20 05:07:04 PST 2020


Author: Rainer Orth
Date: 2020-11-20T14:06:25+01:00
New Revision: 03d593dd7e6de269381ac71d0269a207f4dd1eeb

URL: https://github.com/llvm/llvm-project/commit/03d593dd7e6de269381ac71d0269a207f4dd1eeb
DIFF: https://github.com/llvm/llvm-project/commit/03d593dd7e6de269381ac71d0269a207f4dd1eeb.diff

LOG: [sanitizers][test] Test sanitizer_common and ubsan_minimal on Solaris

During the initial Solaris sanitizer port, I missed to enable the
`sanitizer_common` and `ubsan_minimal` testsuites.  This patch fixes this,
correcting a few unportabilities:

- `Posix/getpass.cpp` failed to link since Solaris lacks `libutil`.
  Omitting the library lets the test `PASS`, but I thought adding `%libutil`
  along the lines of `%librt` to be overkill.
- One subtest of `Posix/getpw_getgr.cpp` is disabled because Solaris
  `getpwent_r` has a different signature than expected.
- `/dev/null` is a symlink on Solaris.
- XPG7 specifies that `uname` returns a non-negative value on success.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D91606

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
    compiler-rt/test/sanitizer_common/CMakeLists.txt
    compiler-rt/test/sanitizer_common/TestCases/Posix/fgetln.cpp
    compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp
    compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
    compiler-rt/test/sanitizer_common/TestCases/Posix/lstat.cpp
    compiler-rt/test/sanitizer_common/TestCases/Posix/uname.c
    compiler-rt/test/sanitizer_common/lit.common.cfg.py
    compiler-rt/test/ubsan_minimal/lit.common.cfg.py

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
index 18bab346ce6e..ec33317da761 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -456,7 +456,7 @@
 #define SANITIZER_INTERCEPT_CTERMID_R (SI_MAC || SI_FREEBSD || SI_SOLARIS)
 
 #define SANITIZER_INTERCEPTOR_HOOKS \
-  (SI_LINUX || SI_MAC || SI_WINDOWS || SI_NETBSD)
+  (SI_LINUX || SI_MAC || SI_WINDOWS || SI_NETBSD || SI_SOLARIS)
 #define SANITIZER_INTERCEPT_RECV_RECVFROM SI_POSIX
 #define SANITIZER_INTERCEPT_SEND_SENDTO SI_POSIX
 #define SANITIZER_INTERCEPT_EVENTFD_READ_WRITE SI_LINUX

diff  --git a/compiler-rt/test/sanitizer_common/CMakeLists.txt b/compiler-rt/test/sanitizer_common/CMakeLists.txt
index 3d17c008e01d..7f1b0f257716 100644
--- a/compiler-rt/test/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/test/sanitizer_common/CMakeLists.txt
@@ -65,6 +65,9 @@ foreach(tool ${SUPPORTED_TOOLS})
   if(${tool} STREQUAL "asan")
     list(REMOVE_ITEM TEST_ARCH sparc sparcv9)
   endif()
+  if(OS_NAME MATCHES "SunOS" AND ${tool} STREQUAL "asan")
+    list(REMOVE_ITEM TEST_ARCH x86_64)
+  endif()
 
   # TODO(dliew): We should iterate over the 
diff erent
   # Apple platforms, not just macOS.

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/fgetln.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/fgetln.cpp
index b1b4665389a3..1db9099b57a2 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/fgetln.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fgetln.cpp
@@ -1,5 +1,7 @@
 // RUN: %clangxx -O0 -g %s -o %t && %run %t
 // UNSUPPORTED: linux
+// fgetln is BSD-only.
+// UNSUPPORTED: solaris
 
 #include <assert.h>
 #include <stdio.h>

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp
index bf198eff91d2..c65bcbd1d03a 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp
@@ -2,6 +2,8 @@
 
 // REQUIRES: stable-runtime
 // XFAIL: android && asan
+// No libutil.
+// UNSUPPORTED: solaris
 
 #include <assert.h>
 #include <stdio.h>
@@ -14,6 +16,8 @@
 #include <sys/ioctl.h>
 #include <sys/termios.h>
 #include <sys/types.h>
+#elif defined(__sun__) && defined(__svr4__)
+#include <termios.h>
 #else
 #include <util.h>
 #endif

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
index f4f431e7eb31..848774a8909b 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
@@ -81,7 +81,7 @@ int main(int argc, const char *argv[]) {
   setgrent();
   test<group>(&getgrent);
 
-#if !defined(__APPLE__)
+#if !defined(__APPLE__) && !(defined(__sun__) && defined(__svr4__))
   setpwent();
   test_r<passwd>(&getpwent_r);
   setgrent();

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/lstat.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/lstat.cpp
index 01c2ea83d9c1..75b196183ce0 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/lstat.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/lstat.cpp
@@ -8,7 +8,11 @@ int main(void) {
   struct stat st;
 
   assert(!lstat("/dev/null", &st));
+#if defined(__sun__) && defined(__svr4__)
+  assert(S_ISLNK(st.st_mode));
+#else
   assert(S_ISCHR(st.st_mode));
+#endif
 
   return 0;
 }

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/uname.c b/compiler-rt/test/sanitizer_common/TestCases/Posix/uname.c
index 0bf7e0fd98e3..1c595ef20ad7 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/uname.c
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/uname.c
@@ -7,7 +7,7 @@
 int main() {
   struct utsname buf;
   int err = uname(&buf);
-  assert(err == 0);
+  assert(err >= 0);
   printf("%s %s %s %s %s\n", buf.sysname, buf.nodename, buf.release,
          buf.version, buf.machine);
 }

diff  --git a/compiler-rt/test/sanitizer_common/lit.common.cfg.py b/compiler-rt/test/sanitizer_common/lit.common.cfg.py
index ac99c0d2d1c6..b4f0670f9959 100644
--- a/compiler-rt/test/sanitizer_common/lit.common.cfg.py
+++ b/compiler-rt/test/sanitizer_common/lit.common.cfg.py
@@ -70,7 +70,7 @@ def build_invocation(compile_flags):
 
 config.suffixes = ['.c', '.cpp']
 
-if config.host_os not in ['Linux', 'Darwin', 'NetBSD', 'FreeBSD']:
+if config.host_os not in ['Linux', 'Darwin', 'NetBSD', 'FreeBSD', 'SunOS']:
   config.unsupported = True
 
 if not config.parallelism_group:

diff  --git a/compiler-rt/test/ubsan_minimal/lit.common.cfg.py b/compiler-rt/test/ubsan_minimal/lit.common.cfg.py
index d9d203ca8ece..39800c968dbf 100644
--- a/compiler-rt/test/ubsan_minimal/lit.common.cfg.py
+++ b/compiler-rt/test/ubsan_minimal/lit.common.cfg.py
@@ -30,7 +30,7 @@ def build_invocation(compile_flags):
 config.suffixes = ['.c', '.cpp']
 
 # Check that the host supports UndefinedBehaviorSanitizerMinimal tests
-if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD']: # TODO: Windows
+if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD', 'SunOS']: # TODO: Windows
   config.unsupported = True
 
 # Don't target x86_64h if the test machine can't execute x86_64h binaries.


        


More information about the llvm-commits mailing list