summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/tests
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-11-02 15:39:08 +0000
committerReid Kleckner <rnk@google.com>2016-11-02 15:39:08 +0000
commit3501fdcb30510fd5b280cf3910aaa56cc259d556 (patch)
tree4c66ca2844799f9d0c422bf92b645992afb98a82 /compiler-rt/lib/asan/tests
parent2bc03590f6647ab94b8866869b1f417f78fd7274 (diff)
downloadbcm5719-llvm-3501fdcb30510fd5b280cf3910aaa56cc259d556.tar.gz
bcm5719-llvm-3501fdcb30510fd5b280cf3910aaa56cc259d556.zip
[asan] Add more dynamic CRT mode tests
Only tests using %clang_cl_asan were using the dynamic CRT before this. The unit tests and lit tests using %clangxx_asan were using the static CRT. Many cross-platform tests fail with the dynamic CRT, so I had to add win32-(static|dynamic)-asan lit features. Also deletes some redundant tests in TestCases/Windows that started failing with this switch. llvm-svn: 285821
Diffstat (limited to 'compiler-rt/lib/asan/tests')
-rw-r--r--compiler-rt/lib/asan/tests/CMakeLists.txt19
-rw-r--r--compiler-rt/lib/asan/tests/asan_str_test.cc10
2 files changed, 27 insertions, 2 deletions
diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt
index 94febc0c72a..3e56763a804 100644
--- a/compiler-rt/lib/asan/tests/CMakeLists.txt
+++ b/compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -222,6 +222,23 @@ macro(add_asan_tests_for_arch_and_kind arch kind)
${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} -ObjC ${ARGN})
endif()
+ if (MSVC)
+ # With the MSVC CRT, the choice between static and dynamic CRT is made at
+ # compile time with a macro. Simulate the effect of passing /MD to clang-cl.
+ set(ASAN_INST_DYNAMIC_TEST_OBJECTS)
+ foreach(src ${ASAN_INST_TEST_SOURCES})
+ asan_compile(ASAN_INST_DYNAMIC_TEST_OBJECTS ${src} ${arch} ${kind}
+ ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} -D_MT -D_DLL ${ARGN})
+ endforeach()
+ # Clang links the static CRT by default. Override that to use the dynamic
+ # CRT.
+ set(ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINKFLAGS
+ ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINKFLAGS}
+ -Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames)
+ else()
+ set(ASAN_INST_DYNAMIC_TEST_OBJECTS ${ASAN_INST_TEST_OBJECTS})
+ endif()
+
# Create the 'default' folder where ASAN tests are produced.
if(CMAKE_CONFIGURATION_TYPES)
foreach(build_mode ${CMAKE_CONFIGURATION_TYPES})
@@ -247,7 +264,7 @@ macro(add_asan_tests_for_arch_and_kind arch kind)
add_asan_test(AsanDynamicUnitTests "Asan-${arch}${kind}-Dynamic-Test"
${arch} ${kind} SUBDIR "dynamic"
- OBJECTS ${ASAN_INST_TEST_OBJECTS}
+ OBJECTS ${ASAN_INST_DYNAMIC_TEST_OBJECTS}
LINKFLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINKFLAGS})
endif()
diff --git a/compiler-rt/lib/asan/tests/asan_str_test.cc b/compiler-rt/lib/asan/tests/asan_str_test.cc
index 0b86702c4ae..c790088f8f9 100644
--- a/compiler-rt/lib/asan/tests/asan_str_test.cc
+++ b/compiler-rt/lib/asan/tests/asan_str_test.cc
@@ -127,7 +127,15 @@ TEST(AddressSanitizer, StrNLenOOBTest) {
}
#endif // SANITIZER_TEST_HAS_STRNLEN
-TEST(AddressSanitizer, StrDupOOBTest) {
+// This test fails with the WinASan dynamic runtime because we fail to intercept
+// strdup.
+#if defined(_MSC_VER) && defined(_DLL)
+#define MAYBE_StrDupOOBTest DISABLED_StrDupOOBTest
+#else
+#define MAYBE_StrDupOOBTest StrDupOOBTest
+#endif
+
+TEST(AddressSanitizer, MAYBE_StrDupOOBTest) {
size_t size = Ident(42);
char *str = MallocAndMemsetString(size);
char *new_str;
OpenPOWER on IntegriCloud