[compiler-rt] r183735 - [lsan] Fix the unittest makefiles.

Sergey Matveev earthdok at google.com
Tue Jun 11 02:52:02 PDT 2013


Author: smatveev
Date: Tue Jun 11 04:52:02 2013
New Revision: 183735

URL: http://llvm.org/viewvc/llvm-project?rev=183735&view=rev
Log:
[lsan] Fix the unittest makefiles.

Modified:
    compiler-rt/trunk/lib/lsan/lit_tests/CMakeLists.txt
    compiler-rt/trunk/lib/lsan/tests/CMakeLists.txt
    compiler-rt/trunk/lib/lsan/tests/lsan_dummy_unittest.cc

Modified: compiler-rt/trunk/lib/lsan/lit_tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lit_tests/CMakeLists.txt?rev=183735&r1=183734&r2=183735&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lit_tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/lsan/lit_tests/CMakeLists.txt Tue Jun 11 04:52:02 2013
@@ -26,7 +26,7 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT
     list(APPEND LSAN_TEST_DEPS clang_rt.asan-${arch})
   endforeach()
   if(LLVM_INCLUDE_TESTS)
-    list(APPEND LSAN_TEST_DEPS LsanTests)
+    list(APPEND LSAN_TEST_DEPS LsanUnitTests)
   endif()
   add_lit_testsuite(check-lsan "Running the LeakSanitizer tests"
     ${CMAKE_CURRENT_BINARY_DIR}/LsanConfig

Modified: compiler-rt/trunk/lib/lsan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/tests/CMakeLists.txt?rev=183735&r1=183734&r2=183735&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/lsan/tests/CMakeLists.txt Tue Jun 11 04:52:02 2013
@@ -11,11 +11,15 @@ set(LSAN_TESTS_SRC
 set(LSAN_TESTS_CFLAGS
   ${LSAN_CFLAGS}
   ${COMPILER_RT_GTEST_INCLUDE_CFLAGS}
-  -I${COMPILER_RT_SOURCE_DIR}/lib)
+  -I${COMPILER_RT_SOURCE_DIR}/lib
+  -I${LSAN_SRC_DIR})
 
-add_custom_target(LsanTests)
-set_target_properties(LsanTests PROPERTIES
-  FOLDER "LSan unittests")
+set(LSAN_TEST_LINK_FLAGS_COMMON
+  -lstdc++ -ldl -lpthread)
+
+add_custom_target(LsanUnitTests)
+set_target_properties(LsanUnitTests PROPERTIES
+  FOLDER "LSan unit tests")
 
 # Compile source for the given architecture, using compiler
 # options in ${ARGN}, and add it to the object list.
@@ -25,24 +29,27 @@ macro(lsan_compile obj_list source arch)
   get_target_flags_for_arch(${arch} TARGET_CFLAGS)
   clang_compile(${output_obj} ${source}
                 CFLAGS ${ARGN} ${TARGET_CFLAGS}
-                DEPS gtest)
+                DEPS gtest ${LSAN_RUNTIME_LIBRARIES})
   list(APPEND ${obj_list} ${output_obj})
 endmacro()
 
-function(add_lsan_test testname arch)
-  set(testname_arch ${testname}-${arch}-Test)
-  get_target_flags_for_arch(${arch} TARGET_LINKFLAGS)
-  add_unittest(LsanTests ${testname_arch} ${ARGN})
-  target_link_libraries(${testname_arch} "clang_rt.lsan-${arch}")
-  set_target_compile_flags(${testname_arch} ${LSAN_TESTS_CFLAGS})
-  set_target_link_flags(${testname_arch} ${TARGET_LINKFLAGS})
+function(add_lsan_test test_suite test_name arch)
+  get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
+  add_compiler_rt_test(${test_suite} ${test_name}
+                       OBJECTS ${ARGN}
+                       DEPS ${LSAN_RUNTIME_LIBRARIES} ${ARGN}
+                       LINK_FLAGS ${LSAN_TEST_LINK_FLAGS_COMMON}
+                                  ${TARGET_LINK_FLAGS})
 endfunction()
 
 macro(add_lsan_tests_for_arch arch)
   set(LSAN_TESTS_OBJ)
-  lsan_compile(LSAN_TESTS_OBJ ${LSAN_TESTS_SRC} ${arch} ${LSAN_TESTS_CFLAGS}
-      -I${LSAN_SRC_DIR})
-  add_lsan_test(Lsan ${arch} ${LSAN_TESTS_OBJ})
+  set(LSAN_TEST_SOURCES ${LSAN_TESTS_SRC}
+                        ${COMPILER_RT_GTEST_SOURCE})
+  foreach(source ${LSAN_TEST_SOURCES})
+    lsan_compile(LSAN_TESTS_OBJ ${source} ${arch} ${LSAN_TESTS_CFLAGS})
+  endforeach()
+  add_lsan_test(LsanUnitTests Lsan-${arch}-Test ${arch} ${LSAN_TESTS_OBJ})
 endmacro()
 
 # Build tests for 64-bit Linux only.

Modified: compiler-rt/trunk/lib/lsan/tests/lsan_dummy_unittest.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/tests/lsan_dummy_unittest.cc?rev=183735&r1=183734&r2=183735&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/tests/lsan_dummy_unittest.cc (original)
+++ compiler-rt/trunk/lib/lsan/tests/lsan_dummy_unittest.cc Tue Jun 11 04:52:02 2013
@@ -15,3 +15,8 @@
 TEST(LeakSanitizer, EmptyTest) {
   // Empty test to suppress LIT warnings about lack of tests.
 }
+
+int main(int argc, char **argv) {
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}





More information about the llvm-commits mailing list