[compiler-rt] r201413 - Move ASan lit-tests under test/asan

Alexey Samsonov samsonov at google.com
Fri Feb 14 06:06:11 PST 2014


Author: samsonov
Date: Fri Feb 14 08:06:10 2014
New Revision: 201413

URL: http://llvm.org/viewvc/llvm-project?rev=201413&view=rev
Log:
Move ASan lit-tests under test/asan

Added:
    compiler-rt/trunk/test/asan/
      - copied from r201412, compiler-rt/trunk/lib/asan/lit_tests/
Removed:
    compiler-rt/trunk/lib/asan/lit_tests/
Modified:
    compiler-rt/trunk/CMakeLists.txt
    compiler-rt/trunk/lib/asan/CMakeLists.txt
    compiler-rt/trunk/test/CMakeLists.txt
    compiler-rt/trunk/test/asan/CMakeLists.txt
    compiler-rt/trunk/test/asan/GenericConfig/lit.site.cfg.in
    compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
    compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c
    compiler-rt/trunk/test/asan/Unit/lit.site.cfg.in
    compiler-rt/trunk/test/asan/lit.cfg

Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=201413&r1=201412&r2=201413&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Fri Feb 14 08:06:10 2014
@@ -231,6 +231,7 @@ 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(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)
@@ -259,6 +260,6 @@ endif()
 add_subdirectory(lib)
 
 if(LLVM_INCLUDE_TESTS)
-  add_subdirectory(test)
   add_subdirectory(unittests)
 endif()
+add_subdirectory(test)

Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=201413&r1=201412&r2=201413&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Fri Feb 14 08:06:10 2014
@@ -46,10 +46,6 @@ if(ANDROID)
     ASAN_LOW_MEMORY=1)
 endif()
 
-# Architectures supported by ASan.
-filter_available_targets(ASAN_SUPPORTED_ARCH
-  x86_64 i386 powerpc64)
-
 # Compile ASan sources into an object library.
 if(APPLE)
   foreach(os ${SANITIZER_COMMON_SUPPORTED_DARWIN_OS})
@@ -145,5 +141,3 @@ add_custom_target(asan_runtime_libraries
 if(LLVM_INCLUDE_TESTS)
   add_subdirectory(tests)
 endif()
-
-add_subdirectory(lit_tests)

Modified: compiler-rt/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/CMakeLists.txt?rev=201413&r1=201412&r2=201413&view=diff
==============================================================================
--- compiler-rt/trunk/test/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/CMakeLists.txt Fri Feb 14 08:06:10 2014
@@ -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(ASAN_SUPPORTED_ARCH)
+    add_subdirectory(asan)
+  endif()
   if(DFSAN_SUPPORTED_ARCH)
     add_subdirectory(dfsan)
   endif()

Modified: compiler-rt/trunk/test/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/CMakeLists.txt?rev=201413&r1=201412&r2=201413&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/asan/CMakeLists.txt Fri Feb 14 08:06:10 2014
@@ -1,65 +1,64 @@
-set(ASAN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
-set(ASAN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/..)
+set(ASAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
-if(COMPILER_RT_CAN_EXECUTE_TESTS)
-  set(ASAN_TESTSUITES)
+set(ASAN_TESTSUITES)
 
-  if(CAN_TARGET_arm_android)
-    # This is only true if we are cross-compiling.
-    # Build all tests with host compiler and use host tools.
-    set(ASAN_TEST_TARGET_CC ${CMAKE_C_COMPILER})
-    get_filename_component(ASAN_TEST_LLVM_TOOLS_DIR ${CMAKE_C_COMPILER} PATH)
-    set(ASAN_TEST_CONFIG_SUFFIX "-arm-android")
-    set(ASAN_TEST_BITS "32")
-    get_target_flags_for_arch(arm_android ASAN_TEST_TARGET_CFLAGS)
-    configure_lit_site_cfg(
-      ${CMAKE_CURRENT_SOURCE_DIR}/GenericConfig/lit.site.cfg.in
-      ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig/lit.site.cfg
-      )
-    list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig)
-  endif()
-  
-  if(CAN_TARGET_x86_64 OR CAN_TARGET_powerpc64)
-    set(ASAN_TEST_CONFIG_SUFFIX "64")
-    set(ASAN_TEST_BITS "64")
-    set(ASAN_TEST_TARGET_CFLAGS ${TARGET_64_BIT_CFLAGS})
-    configure_lit_site_cfg(
-      ${CMAKE_CURRENT_SOURCE_DIR}/GenericConfig/lit.site.cfg.in
-      ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig/lit.site.cfg
-      )
-    list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig)
-  endif()
-  
-  if(CAN_TARGET_i386)
-    set(ASAN_TEST_CONFIG_SUFFIX "32")
-    set(ASAN_TEST_BITS "32")
-    set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS})
-    configure_lit_site_cfg(
-      ${CMAKE_CURRENT_SOURCE_DIR}/GenericConfig/lit.site.cfg.in
-      ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg
-      )
-    list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig)
-  endif()
-  
+if(CAN_TARGET_arm_android)
+  # This is only true if we are cross-compiling.
+  # Build all tests with host compiler and use host tools.
+  set(ASAN_TEST_TARGET_CC ${CMAKE_C_COMPILER})
+  get_filename_component(ASAN_TEST_LLVM_TOOLS_DIR ${CMAKE_C_COMPILER} PATH)
+  set(ASAN_TEST_CONFIG_SUFFIX "-arm-android")
+  set(ASAN_TEST_BITS "32")
+  get_target_flags_for_arch(arm_android ASAN_TEST_TARGET_CFLAGS)
   configure_lit_site_cfg(
-    ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
-    ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
+    ${CMAKE_CURRENT_SOURCE_DIR}/GenericConfig/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig/lit.site.cfg
     )
-  
-  # Run ASan tests only if we're sure we may produce working binaries.
-  set(ASAN_TEST_DEPS
-    ${SANITIZER_COMMON_LIT_TEST_DEPS}
-    asan_runtime_libraries)
-  set(ASAN_TEST_PARAMS
-    asan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
-  # FIXME: support unit test in the android test runner
-  if(LLVM_INCLUDE_TESTS AND NOT CAN_TARGET_arm_android)
-    list(APPEND ASAN_TEST_DEPS AsanUnitTests)
-    list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
-  endif()
-  add_lit_testsuite(check-asan "Running the AddressSanitizer tests"
-    ${ASAN_TESTSUITES}
-    PARAMS ${ASAN_TEST_PARAMS}
-    DEPENDS ${ASAN_TEST_DEPS})
-  set_target_properties(check-asan PROPERTIES FOLDER "ASan tests")
+  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig)
 endif()
+
+if(CAN_TARGET_x86_64 OR CAN_TARGET_powerpc64)
+  set(ASAN_TEST_CONFIG_SUFFIX "64")
+  set(ASAN_TEST_BITS "64")
+  set(ASAN_TEST_TARGET_CFLAGS ${TARGET_64_BIT_CFLAGS})
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/GenericConfig/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig/lit.site.cfg
+    )
+  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig)
+endif()
+
+if(CAN_TARGET_i386)
+  set(ASAN_TEST_CONFIG_SUFFIX "32")
+  set(ASAN_TEST_BITS "32")
+  set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS})
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/GenericConfig/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg
+    )
+  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig)
+endif()
+
+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
+  )
+endif()
+
+# Run ASan tests only if we're sure we may produce working binaries.
+set(ASAN_TEST_DEPS
+  ${SANITIZER_COMMON_LIT_TEST_DEPS}
+  asan_runtime_libraries)
+set(ASAN_TEST_PARAMS
+  asan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+# FIXME: support unit test in the android test runner
+if(LLVM_INCLUDE_TESTS AND NOT CAN_TARGET_arm_android)
+  list(APPEND ASAN_TEST_DEPS AsanUnitTests)
+  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
+endif()
+add_lit_testsuite(check-asan "Running the AddressSanitizer tests"
+  ${ASAN_TESTSUITES}
+  PARAMS ${ASAN_TEST_PARAMS}
+  DEPENDS ${ASAN_TEST_DEPS})
+set_target_properties(check-asan PROPERTIES FOLDER "ASan tests")

Modified: compiler-rt/trunk/test/asan/GenericConfig/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/GenericConfig/lit.site.cfg.in?rev=201413&r1=201412&r2=201413&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/GenericConfig/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/asan/GenericConfig/lit.site.cfg.in Fri Feb 14 08:06:10 2014
@@ -3,7 +3,7 @@
 
 # Tool-specific config options.
 config.name_suffix = "@ASAN_TEST_CONFIG_SUFFIX@"
-config.asan_source_dir = "@ASAN_SOURCE_DIR@"
+config.asan_lit_source_dir = "@ASAN_LIT_SOURCE_DIR@"
 config.target_cflags = "@ASAN_TEST_TARGET_CFLAGS@"
 config.clang = "@ASAN_TEST_TARGET_CC@"
 config.llvm_tools_dir = "@ASAN_TEST_LLVM_TOOLS_DIR@"
@@ -14,4 +14,4 @@ config.android = "@CAN_TARGET_arm_androi
 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, "@ASAN_SOURCE_DIR@/lit_tests/lit.cfg")
+lit_config.load_config(config, "@ASAN_LIT_SOURCE_DIR@/lit.cfg")

Modified: compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c?rev=201413&r1=201412&r2=201413&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c Fri Feb 14 08:06:10 2014
@@ -15,7 +15,7 @@
 // RUN:   | grep -v "__asan_default_options" \
 // RUN:   | grep -v "__asan_on_error" > %t.symbols
 
-// RUN: cat %p/../../../asan_interface_internal.h \
+// RUN: cat %p/../../../../lib/asan/asan_interface_internal.h \
 // RUN:    | sed "s/\/\/.*//" | sed "s/typedef.*//" \
 // RUN:    | grep -v "OPTIONAL" \
 // RUN:    | grep "__asan_.*(" | sed "s/.* __asan_/__asan_/;s/(.*//" \

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c?rev=201413&r1=201412&r2=201413&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c Fri Feb 14 08:06:10 2014
@@ -8,7 +8,7 @@
 // RUN:    | grep -v "__asan_default_options" \
 // RUN:    | grep -v "__asan_stack_" \
 // RUN:    | grep -v "__asan_on_error" > %t.symbols
-// RUN: cat %p/../../../asan_interface_internal.h \
+// RUN: cat %p/../../../../lib/asan/asan_interface_internal.h \
 // RUN:    | sed "s/\/\/.*//" | sed "s/typedef.*//" \
 // RUN:    | grep -v "OPTIONAL" \
 // RUN:    | grep "__asan_.*(" | sed "s/.* __asan_/__asan_/;s/(.*//" \

Modified: compiler-rt/trunk/test/asan/Unit/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/Unit/lit.site.cfg.in?rev=201413&r1=201412&r2=201413&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/Unit/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/asan/Unit/lit.site.cfg.in Fri Feb 14 08:06:10 2014
@@ -9,7 +9,8 @@ config.name = 'AddressSanitizer-Unit'
 
 # Setup test source and exec root. For unit tests, we define
 # it as build directory with ASan unit tests.
-config.test_exec_root = "@ASAN_BINARY_DIR@/tests"
+# FIXME: De-hardcode this path.
+config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/asan/tests"
 config.test_source_root = config.test_exec_root
 
 # Enable leak detection in ASan unit tests on x86_64-linux.

Modified: compiler-rt/trunk/test/asan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/lit.cfg?rev=201413&r1=201412&r2=201413&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/lit.cfg (original)
+++ compiler-rt/trunk/test/asan/lit.cfg Fri Feb 14 08:06:10 2014
@@ -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 = 'AddressSanitizer' + confi
 # 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-asan")
-
-# 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.
-  asan_site_cfg = lit_config.params.get('asan_site_config', None)
-  if (asan_site_cfg) and (os.path.exists(asan_site_cfg)):
-    lit_config.load_config(config, asan_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()
-  asan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt",
-                               "lib", "asan", "lit_tests", "lit.site.cfg")
-  if (not asan_site_cfg) or (not os.path.exists(asan_site_cfg)):
-    DisplayNoConfigMessage()
-
-  lit_config.load_config(config, asan_site_cfg)
-  raise SystemExit
-
 # Setup default compiler flags used with -fsanitize=address option.
 # FIXME: Review the set of required flags and check if it can be reduced.
 target_cflags = " " + config.target_cflags
@@ -62,9 +28,10 @@ clang_asan_cflags = (" -fsanitize=addres
                    + target_cflags)
 clang_asan_cxxflags = " --driver-mode=g++" + clang_asan_cflags
 
+asan_lit_source_dir = get_required_attr(config, "asan_lit_source_dir")
 if config.android == "TRUE":
   config.available_features.add('android')
-  clang_wrapper = os.path.join(config.asan_source_dir, "lit_tests",
+  clang_wrapper = os.path.join(asan_lit_source_dir,
                                "android_commands", "android_compile.py") + " "
 else:
   clang_wrapper = ""
@@ -79,8 +46,10 @@ config.substitutions.append( ("%clangxx_
                                                 clang_asan_cxxflags + " ")) )
 
 
+# FIXME: De-hardcode this path.
+asan_source_dir = os.path.join(
+  get_required_attr(config, "compiler_rt_src_root"), "lib", "asan")
 # Setup path to asan_symbolize.py script.
-asan_source_dir = get_required_attr(config, "asan_source_dir")
 asan_symbolize = os.path.join(asan_source_dir, "scripts", "asan_symbolize.py")
 if not os.path.exists(asan_symbolize):
   lit_config.fatal("Can't find script on path %r" % asan_symbolize)





More information about the llvm-commits mailing list