summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-03-22 09:01:26 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-03-22 09:01:26 +0000
commit6e5ff89e8980b7c2ca0a39811433fb7ac2c74372 (patch)
tree12b1e52463f188eae62790a68a908f4cf0a89ab3 /lib
parent86b5722bf955261c0f43caae9b8d0ea6faa05055 (diff)
downloadcompiler-rt-6e5ff89e8980b7c2ca0a39811433fb7ac2c74372.tar.gz
compiler-rt-6e5ff89e8980b7c2ca0a39811433fb7ac2c74372.tar.bz2
compiler-rt-6e5ff89e8980b7c2ca0a39811433fb7ac2c74372.tar.xz
[msan] Move test main and gtest include to separate files.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177718 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/msan/tests/CMakeLists.txt9
-rw-r--r--lib/msan/tests/msan_test.cc11
-rw-r--r--lib/msan/tests/msan_test_config.h20
-rw-r--r--lib/msan/tests/msan_test_main.cc21
4 files changed, 51 insertions, 10 deletions
diff --git a/lib/msan/tests/CMakeLists.txt b/lib/msan/tests/CMakeLists.txt
index 813aad02..abfb96a0 100644
--- a/lib/msan/tests/CMakeLists.txt
+++ b/lib/msan/tests/CMakeLists.txt
@@ -31,9 +31,10 @@ set(MSAN_LIBCXX_LINK_FLAGS
-fsanitize=memory)
# Unittest sources and build flags.
-set(MSAN_UNITTEST_SOURCE msan_test.cc)
+set(MSAN_UNITTEST_SOURCES msan_test.cc msan_test_main.cc)
set(MSAN_LOADABLE_SOURCE msan_loadable.cc)
set(MSAN_UNITTEST_HEADERS
+ msan_test_config.h
msandr_test_so.h
../../../include/sanitizer/msan_interface.h
)
@@ -133,8 +134,10 @@ macro(add_msan_tests_for_arch arch)
# Instrumented tests.
set(MSAN_INST_TEST_OBJECTS)
- msan_compile(MSAN_INST_TEST_OBJECTS ${MSAN_UNITTEST_SOURCE} ${arch}
- ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS})
+ foreach (SOURCE ${MSAN_UNITTEST_SOURCES})
+ msan_compile(MSAN_INST_TEST_OBJECTS ${SOURCE} ${arch}
+ ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS})
+ endforeach(SOURCE)
# Instrumented loadable module objects.
set(MSAN_INST_LOADABLE_OBJECTS)
diff --git a/lib/msan/tests/msan_test.cc b/lib/msan/tests/msan_test.cc
index fbd35cb2..2120f0ef 100644
--- a/lib/msan/tests/msan_test.cc
+++ b/lib/msan/tests/msan_test.cc
@@ -12,9 +12,12 @@
// MemorySanitizer unit tests.
//===----------------------------------------------------------------------===//
+#ifndef MSAN_EXTERNAL_TEST_CONFIG
+#include "msan_test_config.h"
+#endif // MSAN_EXTERNAL_TEST_CONFIG
+
#include "sanitizer/msan_interface.h"
#include "msandr_test_so.h"
-#include "gtest/gtest.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -1943,9 +1946,3 @@ TEST(MemorySanitizer, CallocOverflow) {
TEST(MemorySanitizerStress, DISABLED_MallocStackTrace) {
RecursiveMalloc(22);
}
-
-int main(int argc, char **argv) {
- testing::InitGoogleTest(&argc, argv);
- int res = RUN_ALL_TESTS();
- return res;
-}
diff --git a/lib/msan/tests/msan_test_config.h b/lib/msan/tests/msan_test_config.h
new file mode 100644
index 00000000..5404c434
--- /dev/null
+++ b/lib/msan/tests/msan_test_config.h
@@ -0,0 +1,20 @@
+//===-- msan_test_config.h ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of MemorySanitizer.
+//
+// MemorySanitizer unit tests.
+//===----------------------------------------------------------------------===//
+
+#ifndef MSAN_TEST_CONFIG_H
+#define MSAN_TEST_CONFIG_H
+
+#include "gtest/gtest.h"
+
+#endif // MSAN_TEST_CONFIG_H
diff --git a/lib/msan/tests/msan_test_main.cc b/lib/msan/tests/msan_test_main.cc
new file mode 100644
index 00000000..c8c5fefb
--- /dev/null
+++ b/lib/msan/tests/msan_test_main.cc
@@ -0,0 +1,21 @@
+//===-- msan_test_main.cc -------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of MemorySanitizer.
+//
+//===----------------------------------------------------------------------===//
+#ifndef MSAN_EXTERNAL_TEST_CONFIG
+#include "msan_test_config.h"
+#endif // MSAN_EXTERNAL_TEST_CONFIG
+
+int main(int argc, char **argv) {
+ testing::GTEST_FLAG(death_test_style) = "threadsafe";
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}