summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-09-13 14:04:57 +0000
committerAlexey Samsonov <samsonov@google.com>2012-09-13 14:04:57 +0000
commit484db99999ebadcc62bd5ac5a702d1fdad391111 (patch)
tree65d75e0e6ada7b912234d0b49169f9821ee58fd5 /lib
parentdeb0dd86b99170abfdfb39520064c49b3e91b0cc (diff)
[TSan] support building TSan unittests in CMake
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163797 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/tsan/CMakeLists.txt29
-rw-r--r--lib/tsan/rtl_tests/CMakeLists.txt15
-rw-r--r--lib/tsan/unit_tests/CMakeLists.txt15
3 files changed, 59 insertions, 0 deletions
diff --git a/lib/tsan/CMakeLists.txt b/lib/tsan/CMakeLists.txt
index fc20cd88b..39f3ed346 100644
--- a/lib/tsan/CMakeLists.txt
+++ b/lib/tsan/CMakeLists.txt
@@ -15,4 +15,33 @@ else()
endif()
add_subdirectory(rtl)
+
+if(LLVM_INCLUDE_TESTS)
+ add_custom_target(TsanUnitTests)
+ set_target_properties(TsanUnitTests PROPERTIES
+ FOLDER "TSan unittests")
+
+ function(add_tsan_unittest testname)
+ # Build unit tests only on 64-bit Linux.
+ if(UNIX AND NOT APPLE
+ AND CAN_TARGET_X86_64
+ AND CMAKE_SIZEOF_VOID_P EQUAL 8
+ AND NOT LLVM_BUILD_32_BITS)
+ add_unittest(TsanUnitTests ${testname} ${ARGN})
+ # Link with TSan runtime.
+ target_link_libraries(${testname} clang_rt.tsan-x86_64)
+ # Build tests with PIE and debug info.
+ set_property(TARGET ${testname} APPEND_STRING
+ PROPERTY COMPILE_FLAGS " -fPIE -g")
+ set_property(TARGET ${testname} APPEND_STRING
+ PROPERTY LINK_FLAGS " -pie")
+ endif()
+ endfunction()
+
+ include_directories(rtl)
+ # There are two groups of unit tests: rtl_tests and unit_tests.
+ add_subdirectory(rtl_tests)
+ add_subdirectory(unit_tests)
+endif()
+
# FIXME: Support TSan runtime tests, unit tests and output tests.
diff --git a/lib/tsan/rtl_tests/CMakeLists.txt b/lib/tsan/rtl_tests/CMakeLists.txt
new file mode 100644
index 000000000..b585660e8
--- /dev/null
+++ b/lib/tsan/rtl_tests/CMakeLists.txt
@@ -0,0 +1,15 @@
+set(TSAN_RTL_TESTS
+ tsan_bench.cc
+ tsan_mop.cc
+ tsan_mutex.cc
+ tsan_posix.cc
+ tsan_string.cc
+ tsan_test.cc
+ tsan_thread.cc
+ )
+
+if(UNIX AND NOT APPLE)
+ list(APPEND TSAN_RTL_TESTS tsan_test_util_linux.cc)
+endif()
+
+add_tsan_unittest(TsanRtlTest ${TSAN_RTL_TESTS})
diff --git a/lib/tsan/unit_tests/CMakeLists.txt b/lib/tsan/unit_tests/CMakeLists.txt
new file mode 100644
index 000000000..5608e2461
--- /dev/null
+++ b/lib/tsan/unit_tests/CMakeLists.txt
@@ -0,0 +1,15 @@
+set(TSAN_UNIT_TESTS
+ tsan_clock_test.cc
+ tsan_flags_test.cc
+ tsan_mman_test.cc
+ tsan_mutex_test.cc
+ tsan_platform_test.cc
+ tsan_printf_test.cc
+ tsan_shadow_test.cc
+ tsan_stack_test.cc
+ tsan_suppressions_test.cc
+ tsan_sync_test.cc
+ tsan_vector_test.cc
+ )
+
+add_tsan_unittest(TsanUnitTest ${TSAN_UNIT_TESTS})