[compiler-rt] r201414 - Move TSan lit-tests under test/tsan

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


Author: samsonov
Date: Fri Feb 14 08:35:48 2014
New Revision: 201414

URL: http://llvm.org/viewvc/llvm-project?rev=201414&view=rev
Log:
Move TSan lit-tests under test/tsan

Added:
    compiler-rt/trunk/test/tsan/
      - copied from r201412, compiler-rt/trunk/lib/tsan/lit_tests/
Removed:
    compiler-rt/trunk/lib/tsan/lit_tests/
    compiler-rt/trunk/test/tsan/Unit/lit.cfg
Modified:
    compiler-rt/trunk/CMakeLists.txt
    compiler-rt/trunk/lib/tsan/CMakeLists.txt
    compiler-rt/trunk/lib/tsan/Makefile.old
    compiler-rt/trunk/lib/tsan/check_memcpy.sh
    compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt
    compiler-rt/trunk/test/CMakeLists.txt
    compiler-rt/trunk/test/tsan/CMakeLists.txt
    compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.in
    compiler-rt/trunk/test/tsan/lit.cfg
    compiler-rt/trunk/test/tsan/test_output.sh

Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=201414&r1=201413&r2=201414&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Fri Feb 14 08:35:48 2014
@@ -235,6 +235,7 @@ filter_available_targets(ASAN_SUPPORTED_
 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)

Modified: compiler-rt/trunk/lib/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/CMakeLists.txt?rev=201414&r1=201413&r2=201414&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/CMakeLists.txt Fri Feb 14 08:35:48 2014
@@ -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 AP
     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)

Modified: compiler-rt/trunk/lib/tsan/Makefile.old
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/Makefile.old?rev=201414&r1=201413&r2=201414&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/Makefile.old (original)
+++ compiler-rt/trunk/lib/tsan/Makefile.old Fri Feb 14 08:35:48 2014
@@ -31,6 +31,7 @@ RTL_TEST_OBJ=$(patsubst %.cc,%.o,$(RTL_T
 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

Modified: compiler-rt/trunk/lib/tsan/check_memcpy.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/check_memcpy.sh?rev=201414&r1=201413&r2=201414&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/check_memcpy.sh (original)
+++ compiler-rt/trunk/lib/tsan/check_memcpy.sh Fri Feb 14 08:35:48 2014
@@ -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

Modified: compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt?rev=201414&r1=201413&r2=201414&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt Fri Feb 14 08:35:48 2014
@@ -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)

Modified: compiler-rt/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/CMakeLists.txt?rev=201414&r1=201413&r2=201414&view=diff
==============================================================================
--- compiler-rt/trunk/test/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/CMakeLists.txt Fri Feb 14 08:35:48 2014
@@ -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()

Modified: compiler-rt/trunk/test/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/CMakeLists.txt?rev=201414&r1=201412&r2=201414&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/tsan/CMakeLists.txt Fri Feb 14 08:35:48 2014
@@ -1,35 +1,19 @@
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-  )
+  ${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
-  )
+set(TSAN_TEST_DEPS
+  ${SANITIZER_COMMON_LIT_TEST_DEPS}
+  tsan)
 
-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")
+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")

Removed: compiler-rt/trunk/test/tsan/Unit/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/Unit/lit.cfg?rev=201412&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Unit/lit.cfg (original)
+++ compiler-rt/trunk/test/tsan/Unit/lit.cfg (removed)
@@ -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

Modified: compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.in?rev=201414&r1=201412&r2=201414&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.in Fri Feb 14 08:35:48 2014
@@ -4,5 +4,11 @@
 # 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")
+# 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

Modified: compiler-rt/trunk/test/tsan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/lit.cfg?rev=201414&r1=201412&r2=201414&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/lit.cfg (original)
+++ compiler-rt/trunk/test/tsan/lit.cfg Fri Feb 14 08:35:48 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 = '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"
 

Modified: compiler-rt/trunk/test/tsan/test_output.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/test_output.sh?rev=201414&r1=201412&r2=201414&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/test_output.sh (original)
+++ compiler-rt/trunk/test/tsan/test_output.sh Fri Feb 14 08:35:48 2014
@@ -3,8 +3,9 @@
 ulimit -s 8192
 set -e # fail on any error
 
-ROOTDIR=$(dirname $0)/..
-BLACKLIST=$ROOTDIR/lit_tests/Helpers/blacklist.txt
+HERE=$(dirname $0)
+TSAN_DIR=$(dirname $0)/../../lib/tsan
+BLACKLIST=$HERE/Helpers/blacklist.txt
 
 # Assume clang and clang++ are in path.
 : ${CC:=clang}
@@ -13,7 +14,7 @@ BLACKLIST=$ROOTDIR/lit_tests/Helpers/bla
 
 # TODO: add testing for all of -O0...-O3
 CFLAGS="-fsanitize=thread -fsanitize-blacklist=$BLACKLIST -fPIE -O1 -g -Wall"
-LDFLAGS="-pie -lpthread -ldl -lrt -lm -Wl,--whole-archive $ROOTDIR/rtl/libtsan.a -Wl,--no-whole-archive"
+LDFLAGS="-pie -lpthread -ldl -lrt -lm -Wl,--whole-archive $TSAN_DIR/rtl/libtsan.a -Wl,--no-whole-archive"
 
 test_file() {
   SRC=$1
@@ -31,7 +32,7 @@ test_file() {
 }
 
 if [ "$1" == "" ]; then
-  for c in $ROOTDIR/lit_tests/*.{c,cc}; do
+  for c in $HERE/*.{c,cc}; do
     if [[ $c == */failing_* ]]; then
       echo SKIPPING FAILING TEST $c
       continue
@@ -54,5 +55,5 @@ if [ "$1" == "" ]; then
     wait $job || exit 1
   done
 else
-  test_file $ROOTDIR/lit_tests/$1 $CXX "DUMP"
+  test_file $HERE/$1 $CXX "DUMP"
 fi





More information about the llvm-commits mailing list