From f6cf6ab53b7f218f7ce8934b5e0ce2481acde4ee Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Fri, 14 Feb 2014 12:05:41 +0000 Subject: [PATCH] Move DFSan test suite under test/ llvm-svn: 201403 --- compiler-rt/CMakeLists.txt | 4 +- compiler-rt/lib/dfsan/CMakeLists.txt | 14 ++--- compiler-rt/lib/dfsan/lit_tests/CMakeLists.txt | 21 ------- compiler-rt/lib/dfsan/lit_tests/lit.cfg | 69 ---------------------- .../lib/dfsan/scripts/check_custom_wrappers.sh | 2 +- compiler-rt/test/CMakeLists.txt | 3 + compiler-rt/test/dfsan/CMakeLists.txt | 13 ++++ .../dfsan}/Inputs/flags_abilist.txt | 0 .../{lib/dfsan/lit_tests => test/dfsan}/basic.c | 0 .../{lib/dfsan/lit_tests => test/dfsan}/custom.c | 0 .../{lib/dfsan/lit_tests => test/dfsan}/flags.c | 0 .../{lib/dfsan/lit_tests => test/dfsan}/fncall.c | 0 compiler-rt/test/dfsan/lit.cfg | 26 ++++++++ .../dfsan/lit_tests => test/dfsan}/lit.site.cfg.in | 2 +- .../dfsan/lit_tests => test/dfsan}/propagate.c | 0 15 files changed, 51 insertions(+), 103 deletions(-) delete mode 100644 compiler-rt/lib/dfsan/lit_tests/CMakeLists.txt delete mode 100644 compiler-rt/lib/dfsan/lit_tests/lit.cfg create mode 100644 compiler-rt/test/dfsan/CMakeLists.txt rename compiler-rt/{lib/dfsan/lit_tests => test/dfsan}/Inputs/flags_abilist.txt (100%) rename compiler-rt/{lib/dfsan/lit_tests => test/dfsan}/basic.c (100%) rename compiler-rt/{lib/dfsan/lit_tests => test/dfsan}/custom.c (100%) rename compiler-rt/{lib/dfsan/lit_tests => test/dfsan}/flags.c (100%) rename compiler-rt/{lib/dfsan/lit_tests => test/dfsan}/fncall.c (100%) create mode 100644 compiler-rt/test/dfsan/lit.cfg rename compiler-rt/{lib/dfsan/lit_tests => test/dfsan}/lit.site.cfg.in (73%) rename compiler-rt/{lib/dfsan/lit_tests => test/dfsan}/propagate.c (100%) diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index c8aa9c8..19a4a34 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -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) diff --git a/compiler-rt/lib/dfsan/CMakeLists.txt b/compiler-rt/lib/dfsan/CMakeLists.txt index e23f94e..8de7498 100644 --- a/compiler-rt/lib/dfsan/CMakeLists.txt +++ b/compiler-rt/lib/dfsan/CMakeLists.txt @@ -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}) $ 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() diff --git a/compiler-rt/lib/dfsan/lit_tests/CMakeLists.txt b/compiler-rt/lib/dfsan/lit_tests/CMakeLists.txt deleted file mode 100644 index d7c5c82..0000000 --- a/compiler-rt/lib/dfsan/lit_tests/CMakeLists.txt +++ /dev/null @@ -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() diff --git a/compiler-rt/lib/dfsan/lit_tests/lit.cfg b/compiler-rt/lib/dfsan/lit_tests/lit.cfg deleted file mode 100644 index 19bc976..0000000 --- a/compiler-rt/lib/dfsan/lit_tests/lit.cfg +++ /dev/null @@ -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 diff --git a/compiler-rt/lib/dfsan/scripts/check_custom_wrappers.sh b/compiler-rt/lib/dfsan/scripts/check_custom_wrappers.sh index cf0d6e4..59f96da 100755 --- a/compiler-rt/lib/dfsan/scripts/check_custom_wrappers.sh +++ b/compiler-rt/lib/dfsan/scripts/check_custom_wrappers.sh @@ -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 diff --git a/compiler-rt/test/CMakeLists.txt b/compiler-rt/test/CMakeLists.txt index b497550..5b8c59a 100644 --- a/compiler-rt/test/CMakeLists.txt +++ b/compiler-rt/test/CMakeLists.txt @@ -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() diff --git a/compiler-rt/test/dfsan/CMakeLists.txt b/compiler-rt/test/dfsan/CMakeLists.txt new file mode 100644 index 0000000..24b9ddf --- /dev/null +++ b/compiler-rt/test/dfsan/CMakeLists.txt @@ -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") diff --git a/compiler-rt/lib/dfsan/lit_tests/Inputs/flags_abilist.txt b/compiler-rt/test/dfsan/Inputs/flags_abilist.txt similarity index 100% rename from compiler-rt/lib/dfsan/lit_tests/Inputs/flags_abilist.txt rename to compiler-rt/test/dfsan/Inputs/flags_abilist.txt diff --git a/compiler-rt/lib/dfsan/lit_tests/basic.c b/compiler-rt/test/dfsan/basic.c similarity index 100% rename from compiler-rt/lib/dfsan/lit_tests/basic.c rename to compiler-rt/test/dfsan/basic.c diff --git a/compiler-rt/lib/dfsan/lit_tests/custom.c b/compiler-rt/test/dfsan/custom.c similarity index 100% rename from compiler-rt/lib/dfsan/lit_tests/custom.c rename to compiler-rt/test/dfsan/custom.c diff --git a/compiler-rt/lib/dfsan/lit_tests/flags.c b/compiler-rt/test/dfsan/flags.c similarity index 100% rename from compiler-rt/lib/dfsan/lit_tests/flags.c rename to compiler-rt/test/dfsan/flags.c diff --git a/compiler-rt/lib/dfsan/lit_tests/fncall.c b/compiler-rt/test/dfsan/fncall.c similarity index 100% rename from compiler-rt/lib/dfsan/lit_tests/fncall.c rename to compiler-rt/test/dfsan/fncall.c diff --git a/compiler-rt/test/dfsan/lit.cfg b/compiler-rt/test/dfsan/lit.cfg new file mode 100644 index 0000000..a704637 --- /dev/null +++ b/compiler-rt/test/dfsan/lit.cfg @@ -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 diff --git a/compiler-rt/lib/dfsan/lit_tests/lit.site.cfg.in b/compiler-rt/test/dfsan/lit.site.cfg.in similarity index 73% rename from compiler-rt/lib/dfsan/lit_tests/lit.site.cfg.in rename to compiler-rt/test/dfsan/lit.site.cfg.in index 7c366a0..859284e 100644 --- a/compiler-rt/lib/dfsan/lit_tests/lit.site.cfg.in +++ b/compiler-rt/test/dfsan/lit.site.cfg.in @@ -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") diff --git a/compiler-rt/lib/dfsan/lit_tests/propagate.c b/compiler-rt/test/dfsan/propagate.c similarity index 100% rename from compiler-rt/lib/dfsan/lit_tests/propagate.c rename to compiler-rt/test/dfsan/propagate.c -- 2.7.4