Skip to content

Commit

Permalink
[sanitizers][test] Test sanitizer_common and ubsan_minimal on Solaris
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rorth committed Nov 20, 2020
1 parent a89e55c commit 03d593d
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 5 deletions.
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions compiler-rt/test/sanitizer_common/CMakeLists.txt
Expand Up @@ -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 different
# Apple platforms, not just macOS.
Expand Down
2 changes: 2 additions & 0 deletions 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>
Expand Down
4 changes: 4 additions & 0 deletions compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp
Expand Up @@ -2,6 +2,8 @@

// REQUIRES: stable-runtime
// XFAIL: android && asan
// No libutil.
// UNSUPPORTED: solaris

#include <assert.h>
#include <stdio.h>
Expand All @@ -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
Expand Down
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions compiler-rt/test/sanitizer_common/TestCases/Posix/lstat.cpp
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion compiler-rt/test/sanitizer_common/TestCases/Posix/uname.c
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion compiler-rt/test/sanitizer_common/lit.common.cfg.py
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/ubsan_minimal/lit.common.cfg.py
Expand Up @@ -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.
Expand Down

0 comments on commit 03d593d

Please sign in to comment.