Move DFSan test suite under test/
authorAlexey Samsonov <samsonov@google.com>
Fri, 14 Feb 2014 12:05:41 +0000 (12:05 +0000)
committerAlexey Samsonov <samsonov@google.com>
Fri, 14 Feb 2014 12:05:41 +0000 (12:05 +0000)
llvm-svn: 201403

15 files changed:
compiler-rt/CMakeLists.txt
compiler-rt/lib/dfsan/CMakeLists.txt
compiler-rt/lib/dfsan/lit_tests/CMakeLists.txt [deleted file]
compiler-rt/lib/dfsan/lit_tests/lit.cfg [deleted file]
compiler-rt/lib/dfsan/scripts/check_custom_wrappers.sh
compiler-rt/test/CMakeLists.txt
compiler-rt/test/dfsan/CMakeLists.txt [new file with mode: 0644]
compiler-rt/test/dfsan/Inputs/flags_abilist.txt [moved from compiler-rt/lib/dfsan/lit_tests/Inputs/flags_abilist.txt with 100% similarity]
compiler-rt/test/dfsan/basic.c [moved from compiler-rt/lib/dfsan/lit_tests/basic.c with 100% similarity]
compiler-rt/test/dfsan/custom.c [moved from compiler-rt/lib/dfsan/lit_tests/custom.c with 100% similarity]
compiler-rt/test/dfsan/flags.c [moved from compiler-rt/lib/dfsan/lit_tests/flags.c with 100% similarity]
compiler-rt/test/dfsan/fncall.c [moved from compiler-rt/lib/dfsan/lit_tests/fncall.c with 100% similarity]
compiler-rt/test/dfsan/lit.cfg [new file with mode: 0644]
compiler-rt/test/dfsan/lit.site.cfg.in [moved from compiler-rt/lib/dfsan/lit_tests/lit.site.cfg.in with 73% similarity]
compiler-rt/test/dfsan/propagate.c [moved from compiler-rt/lib/dfsan/lit_tests/propagate.c with 100% similarity]

index c8aa9c8..19a4a34 100644 (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)
 
index e23f94e..8de7498 100644 (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()
diff --git a/compiler-rt/lib/dfsan/lit_tests/CMakeLists.txt b/compiler-rt/lib/dfsan/lit_tests/CMakeLists.txt
deleted file mode 100644 (file)
index d7c5c82..0000000
+++ /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 (file)
index 19bc976..0000000
+++ /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
index cf0d6e4..59f96da 100755 (executable)
@@ -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
 
index b497550..5b8c59a 100644 (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()
diff --git a/compiler-rt/test/dfsan/CMakeLists.txt b/compiler-rt/test/dfsan/CMakeLists.txt
new file mode 100644 (file)
index 0000000..24b9ddf
--- /dev/null
@@ -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/test/dfsan/lit.cfg b/compiler-rt/test/dfsan/lit.cfg
new file mode 100644 (file)
index 0000000..a704637
--- /dev/null
@@ -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
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 (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")