Skip to content

Commit 03d593d

Browse files
committed
[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
1 parent a89e55c commit 03d593d

File tree

9 files changed

+18
-5
lines changed

9 files changed

+18
-5
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@
456456
#define SANITIZER_INTERCEPT_CTERMID_R (SI_MAC || SI_FREEBSD || SI_SOLARIS)
457457

458458
#define SANITIZER_INTERCEPTOR_HOOKS \
459-
(SI_LINUX || SI_MAC || SI_WINDOWS || SI_NETBSD)
459+
(SI_LINUX || SI_MAC || SI_WINDOWS || SI_NETBSD || SI_SOLARIS)
460460
#define SANITIZER_INTERCEPT_RECV_RECVFROM SI_POSIX
461461
#define SANITIZER_INTERCEPT_SEND_SENDTO SI_POSIX
462462
#define SANITIZER_INTERCEPT_EVENTFD_READ_WRITE SI_LINUX

compiler-rt/test/sanitizer_common/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ foreach(tool ${SUPPORTED_TOOLS})
6565
if(${tool} STREQUAL "asan")
6666
list(REMOVE_ITEM TEST_ARCH sparc sparcv9)
6767
endif()
68+
if(OS_NAME MATCHES "SunOS" AND ${tool} STREQUAL "asan")
69+
list(REMOVE_ITEM TEST_ARCH x86_64)
70+
endif()
6871

6972
# TODO(dliew): We should iterate over the different
7073
# Apple platforms, not just macOS.

compiler-rt/test/sanitizer_common/TestCases/Posix/fgetln.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %clangxx -O0 -g %s -o %t && %run %t
22
// UNSUPPORTED: linux
3+
// fgetln is BSD-only.
4+
// UNSUPPORTED: solaris
35

46
#include <assert.h>
57
#include <stdio.h>

compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
// REQUIRES: stable-runtime
44
// XFAIL: android && asan
5+
// No libutil.
6+
// UNSUPPORTED: solaris
57

68
#include <assert.h>
79
#include <stdio.h>
@@ -14,6 +16,8 @@
1416
#include <sys/ioctl.h>
1517
#include <sys/termios.h>
1618
#include <sys/types.h>
19+
#elif defined(__sun__) && defined(__svr4__)
20+
#include <termios.h>
1721
#else
1822
#include <util.h>
1923
#endif

compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ int main(int argc, const char *argv[]) {
8181
setgrent();
8282
test<group>(&getgrent);
8383

84-
#if !defined(__APPLE__)
84+
#if !defined(__APPLE__) && !(defined(__sun__) && defined(__svr4__))
8585
setpwent();
8686
test_r<passwd>(&getpwent_r);
8787
setgrent();

compiler-rt/test/sanitizer_common/TestCases/Posix/lstat.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ int main(void) {
88
struct stat st;
99

1010
assert(!lstat("/dev/null", &st));
11+
#if defined(__sun__) && defined(__svr4__)
12+
assert(S_ISLNK(st.st_mode));
13+
#else
1114
assert(S_ISCHR(st.st_mode));
15+
#endif
1216

1317
return 0;
1418
}

compiler-rt/test/sanitizer_common/TestCases/Posix/uname.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
int main() {
88
struct utsname buf;
99
int err = uname(&buf);
10-
assert(err == 0);
10+
assert(err >= 0);
1111
printf("%s %s %s %s %s\n", buf.sysname, buf.nodename, buf.release,
1212
buf.version, buf.machine);
1313
}

compiler-rt/test/sanitizer_common/lit.common.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def build_invocation(compile_flags):
7070

7171
config.suffixes = ['.c', '.cpp']
7272

73-
if config.host_os not in ['Linux', 'Darwin', 'NetBSD', 'FreeBSD']:
73+
if config.host_os not in ['Linux', 'Darwin', 'NetBSD', 'FreeBSD', 'SunOS']:
7474
config.unsupported = True
7575

7676
if not config.parallelism_group:

compiler-rt/test/ubsan_minimal/lit.common.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def build_invocation(compile_flags):
3030
config.suffixes = ['.c', '.cpp']
3131

3232
# Check that the host supports UndefinedBehaviorSanitizerMinimal tests
33-
if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD']: # TODO: Windows
33+
if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD', 'SunOS']: # TODO: Windows
3434
config.unsupported = True
3535

3636
# Don't target x86_64h if the test machine can't execute x86_64h binaries.

0 commit comments

Comments
 (0)