From a57662d7c4b76b29cbcde8b58183ff324b3eeba5 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Tue, 25 Dec 2012 13:10:15 +0000 Subject: [PATCH] Add MSan unit tests to check-msan and check-all. llvm-svn: 171065 --- compiler-rt/lib/msan/tests/CMakeLists.txt | 16 ++++++++++-- compiler-rt/lib/msan/tests/lit.cfg | 29 ++++++++++++++++++++++ compiler-rt/lib/msan/tests/lit.site.cfg.in | 9 +++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 compiler-rt/lib/msan/tests/lit.cfg create mode 100644 compiler-rt/lib/msan/tests/lit.site.cfg.in diff --git a/compiler-rt/lib/msan/tests/CMakeLists.txt b/compiler-rt/lib/msan/tests/CMakeLists.txt index f82d5669c73d..6a209e908ef5 100644 --- a/compiler-rt/lib/msan/tests/CMakeLists.txt +++ b/compiler-rt/lib/msan/tests/CMakeLists.txt @@ -7,7 +7,6 @@ include_directories(..) include_directories(../..) # Instrumented libcxx sources and build flags. -# FIXME: only do this if libcxx is checked out. set(MSAN_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/projects/libcxx) file(GLOB MSAN_LIBCXX_SOURCES ${MSAN_LIBCXX_PATH}/src/*.cpp) set(MSAN_LIBCXX_CFLAGS @@ -146,8 +145,21 @@ macro(add_msan_tests_for_arch arch) ${MSAN_INST_LIBCXX} ${MSANDR_TEST_SO}) endmacro() -if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID) +if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID + AND EXISTS ${MSAN_LIBCXX_PATH}/) if(CAN_TARGET_X86_64) add_msan_tests_for_arch(x86_64) endif() endif() + +# Run unittests as a part of lit testsuite. +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ) + +add_lit_testsuite(check-msan "Running MemorySanitizer unittests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS MsanUnitTests + ) +set_target_properties(check-msan PROPERTIES FOLDER "MemorySanitizer unittests") diff --git a/compiler-rt/lib/msan/tests/lit.cfg b/compiler-rt/lib/msan/tests/lit.cfg new file mode 100644 index 000000000000..38aa1380443f --- /dev/null +++ b/compiler-rt/lib/msan/tests/lit.cfg @@ -0,0 +1,29 @@ +# -*- Python -*- + +import os + +def get_required_attr(config, attr_name): + attr_value = getattr(config, attr_name, None) + if not attr_value: + lit.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 attributes common for all compiler-rt projects. +llvm_src_root = get_required_attr(config, 'llvm_src_root') +compiler_rt_lit_unit_cfg = os.path.join(llvm_src_root, "projects", + "compiler-rt", "lib", + "lit.common.unit.cfg") +lit.load_config(config, compiler_rt_lit_unit_cfg) + +# Setup config name. +config.name = 'MemorySanitizer' + +# Setup test source and exec root. For unit tests, we define +# it as build directory with sanitizer_common 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", + "msan", "tests") +config.test_source_root = config.test_exec_root diff --git a/compiler-rt/lib/msan/tests/lit.site.cfg.in b/compiler-rt/lib/msan/tests/lit.site.cfg.in new file mode 100644 index 000000000000..bb9a28d6a6cb --- /dev/null +++ b/compiler-rt/lib/msan/tests/lit.site.cfg.in @@ -0,0 +1,9 @@ +## Autogenerated by LLVM/Clang configuration. +# Do not edit! + +config.build_type = "@CMAKE_BUILD_TYPE@" +config.llvm_obj_root = "@LLVM_BINARY_DIR@" +config.llvm_src_root = "@LLVM_SOURCE_DIR@" + +# Let the main config do the real work. +lit.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")