forked from OSchip/llvm-project
parent
c1d119ed6e
commit
5129c5e56f
|
@ -26,7 +26,7 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT APPLE AND NOT ANDROID)
|
|||
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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue