Move TSan lit-tests under test/tsan

llvm-svn: 201414
This commit is contained in:
Alexey Samsonov 2014-02-14 14:35:48 +00:00
parent 9f20d67034
commit e6a6183e9b
158 changed files with 51 additions and 112 deletions

View File

@ -235,6 +235,7 @@ filter_available_targets(ASAN_SUPPORTED_ARCH x86_64 i386 powerpc64)
filter_available_targets(DFSAN_SUPPORTED_ARCH x86_64)
filter_available_targets(LSAN_SUPPORTED_ARCH x86_64)
filter_available_targets(MSAN_SUPPORTED_ARCH x86_64)
filter_available_targets(TSAN_SUPPORTED_ARCH x86_64)
filter_available_targets(UBSAN_SUPPORTED_ARCH x86_64 i386)
add_subdirectory(include)

View File

@ -56,7 +56,7 @@ elseif(UNIX)
rtl/tsan_platform_linux.cc)
endif()
set(TSAN_RUNTIME_LIBRARIES)
add_custom_target(tsan)
# TSan is currently supported on 64-bit Linux only.
if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE)
set(TSAN_ASM_SOURCES rtl/tsan_rtl_amd64.S)
@ -72,11 +72,10 @@ if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE)
CFLAGS ${TSAN_RTL_CFLAGS}
DEFS ${TSAN_COMMON_DEFINITIONS})
add_sanitizer_rt_symbols(clang_rt.tsan-${arch} rtl/tsan.syms.extra)
list(APPEND TSAN_RUNTIME_LIBRARIES clang_rt.tsan-${arch}
add_dependencies(tsan clang_rt.tsan-${arch}
clang_rt.tsan-${arch}-symbols)
endif()
if(LLVM_INCLUDE_TESTS)
add_subdirectory(tests)
endif()
add_subdirectory(lit_tests)

View File

@ -31,6 +31,7 @@ RTL_TEST_OBJ=$(patsubst %.cc,%.o,$(RTL_TEST_SRC))
UNIT_TEST_SRC=$(wildcard tests/unit/*_test.cc)
UNIT_TEST_OBJ=$(patsubst %.cc,%.o,$(UNIT_TEST_SRC))
UNIT_TEST_HDR=$(wildcard rtl/*.h) $(wildcard ../sanitizer_common/*.h)
LIT_TESTS_PATH=../../test/tsan
INCLUDES=-Irtl -I.. -I../../include $(GTEST_INCLUDE)
@ -60,7 +61,7 @@ test: libtsan tsan_test
run: all
(ulimit -s 8192; ./tsan_test)
CC=$(CLANG) CXX=$(CLANG)++ FILECHECK=$(FILECHECK) ./lit_tests/test_output.sh
CC=$(CLANG) CXX=$(CLANG)++ FILECHECK=$(FILECHECK) $(LIT_TESTS_PATH)/test_output.sh
presubmit:
../sanitizer_common/scripts/check_lint.sh

View File

@ -5,12 +5,13 @@
set -eu
ROOTDIR=$(dirname $0)
TEST_DIR=$ROOTDIR/../../test/tsan
: ${CXX:=clang++}
CFLAGS="-fsanitize=thread -fPIE -O1 -g"
LDFLAGS="-pie -lpthread -ldl -lrt -lm -Wl,--whole-archive $ROOTDIR/rtl/libtsan.a -Wl,--no-whole-archive"
SRC=$ROOTDIR/lit_tests/simple_race.cc
SRC=$TEST_DIR/simple_race.cc
OBJ=$SRC.o
EXE=$SRC.exe
$CXX $SRC $CFLAGS -c -o $OBJ

View File

@ -1,35 +0,0 @@
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
)
if(COMPILER_RT_CAN_EXECUTE_TESTS AND CAN_TARGET_x86_64)
# Run TSan output tests only if we're sure we can produce working binaries.
set(TSAN_TEST_DEPS
${SANITIZER_COMMON_LIT_TEST_DEPS}
${TSAN_RUNTIME_LIBRARIES})
set(TSAN_TEST_PARAMS
tsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
)
if(LLVM_INCLUDE_TESTS)
list(APPEND TSAN_TEST_DEPS TsanUnitTests)
endif()
add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
${CMAKE_CURRENT_BINARY_DIR}
PARAMS ${TSAN_TEST_PARAMS}
DEPENDS ${TSAN_TEST_DEPS}
)
set_target_properties(check-tsan PROPERTIES FOLDER "TSan unittests")
elseif(LLVM_INCLUDE_TESTS AND CAN_TARGET_x86_64)
# Otherwise run only TSan unit tests (they are linked using the
# host compiler).
add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
${CMAKE_CURRENT_BINARY_DIR}/Unit
DEPENDS TsanUnitTests llvm-symbolizer)
set_target_properties(check-tsan PROPERTIES FOLDER "TSan unittests")
endif()

View File

@ -1,23 +0,0 @@
# -*- Python -*-
import os
def get_required_attr(config, attr_name):
attr_value = getattr(config, attr_name, None)
if not attr_value:
lit_config.fatal(
"No attribute %r in test configuration! You may need to run "
"tests from your build directory or add this attribute "
"to lit.site.cfg " % attr_name)
return attr_value
# Setup config name.
config.name = 'ThreadSanitizer-Unit'
# Setup test source and exec root. For unit tests, we define
# it as build directory with TSan unit tests.
llvm_obj_root = get_required_attr(config, "llvm_obj_root")
config.test_exec_root = os.path.join(llvm_obj_root, "projects",
"compiler-rt", "lib",
"tsan", "tests")
config.test_source_root = config.test_exec_root

View File

@ -1,8 +0,0 @@
## Autogenerated by LLVM/Clang configuration.
# Do not edit!
# Load common config for all compiler-rt unit tests.
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
# Load tool-specific config that would do the real work.
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/Unit/lit.cfg")

View File

@ -18,7 +18,7 @@ macro(tsan_compile obj_list source arch)
get_target_flags_for_arch(${arch} TARGET_CFLAGS)
clang_compile(${output_obj} ${source}
CFLAGS ${TSAN_UNITTEST_CFLAGS} ${TARGET_CFLAGS}
DEPS gtest ${TSAN_RUNTIME_LIBRARIES} ${ARGN})
DEPS gtest tsan ${ARGN})
list(APPEND ${obj_list} ${output_obj})
endmacro()
@ -33,7 +33,7 @@ macro(add_tsan_unittest testname)
get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
add_compiler_rt_test(TsanUnitTests ${testname}
OBJECTS ${TEST_OBJECTS}
DEPS ${TSAN_RUNTIME_LIBRARIES} ${TEST_OBJECTS}
DEPS tsan ${TEST_OBJECTS}
LINK_FLAGS ${TARGET_LINK_FLAGS}
-fsanitize=thread
-lstdc++ -lm)

View File

@ -21,6 +21,9 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS)
if(MSAN_SUPPORTED_ARCH)
add_subdirectory(msan)
endif()
if(TSAN_SUPPORTED_ARCH)
add_subdirectory(tsan)
endif()
if(UBSAN_SUPPORTED_ARCH)
add_subdirectory(ubsan)
endif()

View File

@ -0,0 +1,19 @@
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
set(TSAN_TEST_DEPS
${SANITIZER_COMMON_LIT_TEST_DEPS}
tsan)
if(LLVM_INCLUDE_TESTS)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
list(APPEND TSAN_TEST_DEPS TsanUnitTests)
endif()
add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${TSAN_TEST_DEPS})
set_target_properties(check-tsan PROPERTIES FOLDER "TSan tests")

View File

@ -0,0 +1,14 @@
## Autogenerated by LLVM/Clang configuration.
# Do not edit!
# Load common config for all compiler-rt unit tests.
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
# Setup config name.
config.name = 'ThreadSanitizer-Unit'
# Setup test source and exec root. For unit tests, we define
# it as build directory with ASan unit tests.
# FIXME: De-hardcode this path.
config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/tsan/tests"
config.test_source_root = config.test_exec_root

View File

@ -2,8 +2,6 @@
import os
import lit.util
def get_required_attr(config, attr_name):
attr_value = getattr(config, attr_name, None)
if not attr_value:
@ -19,38 +17,6 @@ config.name = 'ThreadSanitizer'
# Setup source root.
config.test_source_root = os.path.dirname(__file__)
def DisplayNoConfigMessage():
lit_config.fatal("No site specific configuration available! " +
"Try running your test from the build tree or running " +
"make check-tsan")
# Figure out LLVM source root.
llvm_src_root = getattr(config, 'llvm_src_root', None)
if llvm_src_root is None:
# We probably haven't loaded the site-specific configuration: the user
# is likely trying to run a test file directly, and the site configuration
# wasn't created by the build system.
tsan_site_cfg = lit_config.params.get('tsan_site_config', None)
if (tsan_site_cfg) and (os.path.exists(tsan_site_cfg)):
lit_config.load_config(config, tsan_site_cfg)
raise SystemExit
# Try to guess the location of site-specific configuration using llvm-config
# util that can point where the build tree is.
llvm_config = lit.util.which("llvm-config", config.environment["PATH"])
if not llvm_config:
DisplayNoConfigMessage()
# Find out the presumed location of generated site config.
llvm_obj_root = lit.util.capture(["llvm-config", "--obj-root"]).strip()
tsan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt",
"lib", "tsan", "lit_tests", "lit.site.cfg")
if (not tsan_site_cfg) or (not os.path.exists(tsan_site_cfg)):
DisplayNoConfigMessage()
lit_config.load_config(config, tsan_site_cfg)
raise SystemExit
# Setup environment variables for running ThreadSanitizer.
tsan_options = "atexit_sleep_ms=0"

Some files were not shown because too many files have changed in this diff Show More