Move DFSan test suite under test/

llvm-svn: 201403
This commit is contained in:
Alexey Samsonov 2014-02-14 12:05:41 +00:00
parent f335bd9c69
commit f6cf6ab53b
15 changed files with 51 additions and 103 deletions

View File

@ -231,8 +231,8 @@ endif()
# support only subset of these (e.g. TSan works on x86_64 only).
filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
x86_64 i386 powerpc64 arm)
filter_available_targets(UBSAN_SUPPORTED_ARCH
x86_64 i386)
filter_available_targets(DFSAN_SUPPORTED_ARCH x86_64)
filter_available_targets(UBSAN_SUPPORTED_ARCH x86_64 i386)
add_subdirectory(include)

View File

@ -10,10 +10,8 @@ set(DFSAN_RTL_CFLAGS
# Prevent clang from generating libc calls.
-ffreestanding)
filter_available_targets(DFSAN_SUPPORTED_ARCH x86_64)
# Static runtime library.
set(DFSAN_RUNTIME_LIBRARIES)
add_custom_target(dfsan)
set(arch "x86_64")
if(CAN_TARGET_${arch})
add_compiler_rt_static_runtime(clang_rt.dfsan-${arch} ${arch}
@ -27,8 +25,9 @@ if(CAN_TARGET_${arch})
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
CFLAGS ${DFSAN_RTL_CFLAGS} -fPIC -DDFSAN_NOLIBC)
add_sanitizer_rt_symbols(clang_rt.dfsan-${arch} dfsan.syms.extra)
list(APPEND DFSAN_RUNTIME_LIBRARIES clang_rt.dfsan-${arch}
clang_rt.dfsan-${arch}-symbols)
add_dependencies(dfsan
clang_rt.dfsan-${arch}
clang_rt.dfsan-${arch}-symbols)
endif()
add_custom_target(dfsan_abilist ALL
@ -40,9 +39,6 @@ add_custom_command(OUTPUT ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt
${CMAKE_CURRENT_SOURCE_DIR}/libc_ubuntu1204_abilist.txt
> ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt
DEPENDS done_abilist.txt libc_ubuntu1204_abilist.txt)
add_dependencies(dfsan dfsan_abilist)
install(FILES ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt
DESTINATION ${LIBCLANG_INSTALL_PATH})
if(DFSAN_SUPPORTED_ARCH)
add_subdirectory(lit_tests)
endif()

View File

@ -1,21 +0,0 @@
set(DFSAN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
set(DFSAN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/..)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
if(COMPILER_RT_CAN_EXECUTE_TESTS)
# Run DFSan tests only if we're sure we may produce working binaries.
set(DFSAN_TEST_DEPS
${SANITIZER_COMMON_LIT_TEST_DEPS}
${DFSAN_RUNTIME_LIBRARIES}
dfsan_abilist)
set(DFSAN_TEST_PARAMS
dfsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
add_lit_testsuite(check-dfsan "Running the DataFlowSanitizer tests"
${CMAKE_CURRENT_BINARY_DIR}
PARAMS ${DFSAN_TEST_PARAMS}
DEPENDS ${DFSAN_TEST_DEPS})
set_target_properties(check-dfsan PROPERTIES FOLDER "DFSan tests")
endif()

View File

@ -1,69 +0,0 @@
# -*- Python -*-
import os
import lit.util
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 = 'DataFlowSanitizer'
# 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-dfsan")
# 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.
dfsan_site_cfg = lit_config.params.get('dfsan_site_config', None)
if (dfsan_site_cfg) and (os.path.exists(dfsan_site_cfg)):
lit_config.load_config(config, dfsan_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()
dfsan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt",
"lib", "dfsan", "lit_tests", "lit.site.cfg")
if (not dfsan_site_cfg) or (not os.path.exists(dfsan_site_cfg)):
DisplayNoConfigMessage()
lit_config.load_config(config, dfsan_site_cfg)
raise SystemExit
# Setup default compiler flags used with -fsanitize=dataflow option.
clang_dfsan_cflags = ["-fsanitize=dataflow"]
clang_dfsan_cxxflags = ["--driver-mode=g++ "] + clang_dfsan_cflags
config.substitutions.append( ("%clang_dfsan ",
" ".join([config.clang] + clang_dfsan_cflags) +
" ") )
config.substitutions.append( ("%clangxx_dfsan ",
" ".join([config.clang] + clang_dfsan_cxxflags) +
" ") )
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
# DataFlowSanitizer tests are currently supported on Linux only.
if config.host_os not in ['Linux']:
config.unsupported = True

View File

@ -1,7 +1,7 @@
#!/bin/bash
DFSAN_DIR=$(dirname "$0")/../
DFSAN_CUSTOM_TESTS=${DFSAN_DIR}/lit_tests/custom.c
DFSAN_CUSTOM_TESTS=${DFSAN_DIR}/../../test/dfsan/custom.c
DFSAN_CUSTOM_WRAPPERS=${DFSAN_DIR}/dfsan_custom.cc
DFSAN_ABI_LIST=${DFSAN_DIR}/done_abilist.txt

View File

@ -9,6 +9,9 @@ configure_lit_site_cfg(
# Run sanitizer tests only if we're sure that clang would produce
# working binaries.
if(COMPILER_RT_CAN_EXECUTE_TESTS)
if(DFSAN_SUPPORTED_ARCH)
add_subdirectory(dfsan)
endif()
if(UBSAN_SUPPORTED_ARCH)
add_subdirectory(ubsan)
endif()

View File

@ -0,0 +1,13 @@
set(DFSAN_LIT_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
set(DFSAN_TEST_DEPS
${SANITIZER_COMMON_LIT_TEST_DEPS}
dfsan)
add_lit_testsuite(check-dfsan "Running the DataFlowSanitizer tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${DFSAN_TEST_DEPS})
set_target_properties(check-dfsan PROPERTIES FOLDER "DFSan tests")

View File

@ -0,0 +1,26 @@
# -*- Python -*-
import os
# Setup config name.
config.name = 'DataFlowSanitizer'
# Setup source root.
config.test_source_root = os.path.dirname(__file__)
# Setup default compiler flags used with -fsanitize=dataflow option.
clang_dfsan_cflags = ["-fsanitize=dataflow"]
clang_dfsan_cxxflags = ["--driver-mode=g++ "] + clang_dfsan_cflags
config.substitutions.append( ("%clang_dfsan ",
" ".join([config.clang] + clang_dfsan_cflags) +
" ") )
config.substitutions.append( ("%clangxx_dfsan ",
" ".join([config.clang] + clang_dfsan_cxxflags) +
" ") )
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
# DataFlowSanitizer tests are currently supported on Linux only.
if config.host_os not in ['Linux']:
config.unsupported = True

View File

@ -2,4 +2,4 @@
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
# Load tool-specific config that would do the real work.
lit_config.load_config(config, "@DFSAN_SOURCE_DIR@/lit_tests/lit.cfg")
lit_config.load_config(config, "@DFSAN_LIT_TESTS_DIR@/lit.cfg")