2014-05-09 08:28:18 +08:00
|
|
|
set(SANITIZER_COMMON_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
|
|
|
set(SANITIZER_COMMON_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
|
|
|
|
set(SANITIZER_COMMON_TESTSUITES)
|
|
|
|
|
2014-05-13 06:48:29 +08:00
|
|
|
set(SUPPORTED_TOOLS)
|
[Sanitizers, test] Fix sanitizer tests on Solaris (PR 33274)
Summary:
This patch (on top of the previous two (https://reviews.llvm.org/D40898 and
https://reviews.llvm.org/D40899) complete the compiler-rt side of the the Solaris
sanitizer port.
It contains the following sets of changes:
* For the time being, the port is for 32-bit x86 only, so reject the various tests on
x86_64.
* When compiling as C++, <setjmp.h> resp. <iso/setjmp_iso.h> only declares
_setjmp and _longjmp inside namespace std.
* MAP_FILE is a Windows feature. While e.g. Linux <sys/mman.h> provides a
no-op compat define, Solaris does not.
* test/asan/TestCases/Posix/coverage.cc was initially failing like this:
/vol/gcc/src/llvm/llvm/local/projects/compiler-rt/lib/sanitizer_common/scripts/sancov.py: 4 files merged; 2 PCs total
rm: cannot remove '/var/gcc/llvm/local/projects/compiler-rt/test/asan/I386SunOSConfig/TestCases/Posix/Output/coverage': Invalid argument
Further digging revealed that the rm was trying to remove the running test's working
directory which failed as observed. cd'ing out of the dir before let the test pass.
* Two tests needed a declaration of alloca. I've now copied the existing code from
test/asan/TestCases/alloca_constant_size.cc, but it may be more profitable and
maintainable to have a common testsuite header where such code is collected.
* Similarly, Solaris' printf %p format doesn't include the leading 0x.
* In test/asan/TestCases/malloc-no-intercept.c, I had to undef __EXTENSIONS__
(predefined by clang for no apparent reason) to avoid conflicting declarations
for memalign.
* test/ubsan/TestCases/Float/cast-overflow.cpp has different platform dependent
ways to define BYTE_ORDER and friends. Why not just use __BYTE_ORDER__ and
friends as predefined by clang and gcc?
Patch by Rainer Orth.
Reviewers: kcc, alekseyshl
Reviewed By: alekseyshl
Subscribers: srhines, kubamracek, mgorny, krytarowski, fedor.sergeev, JDevlieghere, llvm-commits, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D40900
llvm-svn: 322635
2018-01-17 20:26:04 +08:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|SunOS")
|
2014-05-13 06:48:29 +08:00
|
|
|
list(APPEND SUPPORTED_TOOLS asan)
|
|
|
|
endif()
|
2018-01-18 19:49:45 +08:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD" OR (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID))
|
2014-05-13 06:48:29 +08:00
|
|
|
list(APPEND SUPPORTED_TOOLS tsan)
|
|
|
|
list(APPEND SUPPORTED_TOOLS msan)
|
2017-09-09 14:10:58 +08:00
|
|
|
list(APPEND SUPPORTED_TOOLS ubsan)
|
2014-05-13 06:48:29 +08:00
|
|
|
endif()
|
2018-01-18 19:49:45 +08:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID)
|
|
|
|
list(APPEND SUPPORTED_TOOLS lsan)
|
|
|
|
endif()
|
2014-05-13 06:48:29 +08:00
|
|
|
|
2018-12-21 19:57:31 +08:00
|
|
|
# FIXME(dliew): Remove this.
|
|
|
|
# Temporary helper for https://reviews.llvm.org/D55740
|
|
|
|
message(
|
|
|
|
STATUS
|
|
|
|
"sanitizer_common tests on \"${CMAKE_SYSTEM_NAME}\" will run against "
|
|
|
|
"\"${SUPPORTED_TOOLS}\"")
|
|
|
|
|
2014-05-09 08:28:18 +08:00
|
|
|
# Create a separate config for each tool we support.
|
2014-05-13 06:48:29 +08:00
|
|
|
foreach(tool ${SUPPORTED_TOOLS})
|
2014-05-09 08:28:18 +08:00
|
|
|
string(TOUPPER ${tool} tool_toupper)
|
2015-03-03 06:03:52 +08:00
|
|
|
if(${tool_toupper}_SUPPORTED_ARCH AND NOT COMPILER_RT_STANDALONE_BUILD)
|
|
|
|
list(APPEND SANITIZER_COMMON_TEST_DEPS ${tool})
|
|
|
|
endif()
|
2015-08-21 01:32:06 +08:00
|
|
|
set(TEST_ARCH ${${tool_toupper}_SUPPORTED_ARCH})
|
|
|
|
if(APPLE)
|
|
|
|
darwin_filter_host_archs(${tool_toupper}_SUPPORTED_ARCH TEST_ARCH)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(arch ${TEST_ARCH})
|
2014-05-09 08:28:18 +08:00
|
|
|
set(SANITIZER_COMMON_LIT_TEST_MODE ${tool})
|
2015-03-03 06:03:52 +08:00
|
|
|
set(SANITIZER_COMMON_TEST_TARGET_ARCH ${arch})
|
2016-11-30 03:25:53 +08:00
|
|
|
get_test_cc_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CC SANITIZER_COMMON_TEST_TARGET_CFLAGS)
|
2015-03-03 06:03:52 +08:00
|
|
|
set(CONFIG_NAME ${tool}-${arch}-${OS_NAME})
|
2014-05-09 08:28:18 +08:00
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
2015-03-03 06:03:52 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
|
|
|
|
list(APPEND SANITIZER_COMMON_TESTSUITES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
|
|
|
|
endforeach()
|
2014-05-09 08:28:18 +08:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# Unit tests.
|
2014-02-20 20:18:08 +08:00
|
|
|
if(COMPILER_RT_INCLUDE_TESTS)
|
|
|
|
configure_lit_site_cfg(
|
2014-05-09 07:53:02 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
|
2017-09-16 13:14:05 +08:00
|
|
|
# FIXME: support unit test in the android test runner
|
|
|
|
if (NOT ANDROID)
|
|
|
|
list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
|
|
|
|
list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerUnitTests)
|
|
|
|
endif()
|
2014-05-09 08:28:18 +08:00
|
|
|
endif()
|
|
|
|
|
2016-07-23 01:14:31 +08:00
|
|
|
if(SANITIZER_COMMON_TESTSUITES)
|
2014-05-09 08:28:18 +08:00
|
|
|
add_lit_testsuite(check-sanitizer "Running sanitizer_common tests"
|
|
|
|
${SANITIZER_COMMON_TESTSUITES}
|
|
|
|
DEPENDS ${SANITIZER_COMMON_TEST_DEPS})
|
|
|
|
set_target_properties(check-sanitizer PROPERTIES FOLDER
|
2016-07-12 05:51:56 +08:00
|
|
|
"Compiler-RT Misc")
|
2014-02-20 20:18:08 +08:00
|
|
|
endif()
|