summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-08-07 08:59:15 +0000
committerAlexey Samsonov <samsonov@google.com>2012-08-07 08:59:15 +0000
commit59c33c0c9a05e4e368af84147b44e38c07f6ad28 (patch)
tree41293b9f390d58ef4b89c3c386a33c17b6041ab2 /compiler-rt
parent147949212542ee52cb207220fe2f6d68e1ceb6c9 (diff)
downloadbcm5719-llvm-59c33c0c9a05e4e368af84147b44e38c07f6ad28.tar.gz
bcm5719-llvm-59c33c0c9a05e4e368af84147b44e38c07f6ad28.zip
[ASan] Add support for running unit tests by lit (as a part of 'make check-asan' command)
llvm-svn: 161406
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/asan/lit_tests/CMakeLists.txt36
-rw-r--r--compiler-rt/lib/asan/lit_tests/Unit/lit.cfg27
-rw-r--r--compiler-rt/lib/asan/lit_tests/Unit/lit.site.cfg.in10
-rw-r--r--compiler-rt/lib/asan/lit_tests/lit.site.cfg.in2
-rw-r--r--compiler-rt/lib/asan/tests/CMakeLists.txt6
-rw-r--r--compiler-rt/lib/lit.common.unit.cfg21
6 files changed, 92 insertions, 10 deletions
diff --git a/compiler-rt/lib/asan/lit_tests/CMakeLists.txt b/compiler-rt/lib/asan/lit_tests/CMakeLists.txt
index e48163cf527..2666a9aa903 100644
--- a/compiler-rt/lib/asan/lit_tests/CMakeLists.txt
+++ b/compiler-rt/lib/asan/lit_tests/CMakeLists.txt
@@ -1,15 +1,39 @@
+set(ASAN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
+set(ASAN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/..)
+
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${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(ASAN_TEST_DEPS
- clang clang-headers FileCheck count not
clang-rt.asan-x86_64 clang-rt.asan-i386
)
+if(LLVM_INCLUDE_TESTS)
+ list(APPEND ASAN_TEST_DEPS AsanUnitTests)
+endif()
-add_lit_testsuite(check-asan "Running the AddressSanitizer tests"
- ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS ${ASAN_TEST_DEPS}
- )
-set_target_properties(check-asan PROPERTIES FOLDER "ASan tests")
+if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}")
+ # Run ASan output tests only if we're not cross-compiling,
+ # and can be sure that clang would produce working binaries.
+ list(APPEND ASAN_TEST_DEPS
+ clang clang-headers FileCheck count not
+ )
+ add_lit_testsuite(check-asan "Running the AddressSanitizer tests"
+ ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${ASAN_TEST_DEPS}
+ )
+ set_target_properties(check-asan PROPERTIES FOLDER "ASan tests")
+elseif(LLVM_INCLUDE_TESTS)
+ # Otherwise run only ASan unit tests.
+ add_lit_testsuite(check-asan "Running the AddressSanitizer unit tests"
+ ${CMAKE_CURRENT_BINARY_DIR}/Unit
+ DEPENDS ${ASAN_TEST_DEPS}
+ )
+ set_target_properties(check-asan PROPERTIES FOLDER "ASan unit tests")
+endif()
diff --git a/compiler-rt/lib/asan/lit_tests/Unit/lit.cfg b/compiler-rt/lib/asan/lit_tests/Unit/lit.cfg
new file mode 100644
index 00000000000..243eb7fbeec
--- /dev/null
+++ b/compiler-rt/lib/asan/lit_tests/Unit/lit.cfg
@@ -0,0 +1,27 @@
+# -*- 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 = 'AddressSanitizer-Unit'
+
+# Setup test source and exec root. For unit tests, we define
+# it as build directory with ASan unit tests.
+asan_binary_dir = get_required_attr(config, "asan_binary_dir")
+config.test_exec_root = os.path.join(asan_binary_dir, "tests")
+config.test_source_root = config.test_exec_root
diff --git a/compiler-rt/lib/asan/lit_tests/Unit/lit.site.cfg.in b/compiler-rt/lib/asan/lit_tests/Unit/lit.site.cfg.in
new file mode 100644
index 00000000000..401c3a8cc2e
--- /dev/null
+++ b/compiler-rt/lib/asan/lit_tests/Unit/lit.site.cfg.in
@@ -0,0 +1,10 @@
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+
+config.target_triple = "@TARGET_TRIPLE@"
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.build_type = "@CMAKE_BUILD_TYPE@"
+config.asan_binary_dir = "@ASAN_BINARY_DIR@"
+
+# Let the main config do the real work.
+lit.load_config(config, "@ASAN_SOURCE_DIR@/lit_tests/Unit/lit.cfg")
diff --git a/compiler-rt/lib/asan/lit_tests/lit.site.cfg.in b/compiler-rt/lib/asan/lit_tests/lit.site.cfg.in
index b4ae829b481..2eb9615d199 100644
--- a/compiler-rt/lib/asan/lit_tests/lit.site.cfg.in
+++ b/compiler-rt/lib/asan/lit_tests/lit.site.cfg.in
@@ -6,4 +6,4 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.clang = "@LLVM_BINARY_DIR@/bin/clang"
# Let the main config do the real work.
-lit.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
+lit.load_config(config, "@ASAN_SOURCE_DIR@/lit_tests/lit.cfg")
diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt
index d409d50b995..a17b811c434 100644
--- a/compiler-rt/lib/asan/tests/CMakeLists.txt
+++ b/compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -47,10 +47,10 @@ set(ASAN_UNITTEST_INSTRUMENTED_CFLAGS
-DASAN_UAR=0
)
-add_custom_target(AsanTests)
-set_target_properties(AsanTests PROPERTIES FOLDER "ASan tests")
+add_custom_target(AsanUnitTests)
+set_target_properties(AsanUnitTests PROPERTIES FOLDER "ASan unit tests")
function(add_asan_test testname)
- add_unittest(AsanTests ${testname} ${ARGN})
+ add_unittest(AsanUnitTests ${testname} ${ARGN})
if(LLVM_BUILD_32_BITS)
target_link_libraries(${testname} clang_rt.asan-i386)
else()
diff --git a/compiler-rt/lib/lit.common.unit.cfg b/compiler-rt/lib/lit.common.unit.cfg
new file mode 100644
index 00000000000..8250b4a829c
--- /dev/null
+++ b/compiler-rt/lib/lit.common.unit.cfg
@@ -0,0 +1,21 @@
+# -*- Python -*-
+
+# Configuration file for 'lit' test runner.
+# This file contains common config setup rules for unit tests in various
+# compiler-rt testsuites.
+
+import os
+
+# Setup test format
+build_type = getattr(config, "build_type", "Debug")
+config.test_format = lit.formats.GoogleTest(build_type, "Test")
+
+# Setup test suffixes.
+config.suffixes = []
+
+# Propagate the temp directory. Windows requires this because it uses \Windows\
+# if none of these are present.
+if 'TMP' in os.environ:
+ config.environment['TMP'] = os.environ['TMP']
+if 'TEMP' in os.environ:
+ config.environment['TEMP'] = os.environ['TEMP']
OpenPOWER on IntegriCloud