Skip to content

Commit

Permalink
[msan] Move test main and gtest include to separate files.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177718 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
eugenis committed Mar 22, 2013
1 parent 86b5722 commit 6e5ff89
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
9 changes: 6 additions & 3 deletions lib/msan/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions lib/msan/tests/msan_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
}
20 changes: 20 additions & 0 deletions lib/msan/tests/msan_test_config.h
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions lib/msan/tests/msan_test_main.cc
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 6e5ff89

Please sign in to comment.