From 5f1a7589ad4b8c83ac5653038c6328941c5e7cf6 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Wed, 17 Oct 2012 14:04:57 +0000 Subject: [PATCH] [ASan] unit tests: Move main() to a separate file. Fix lint llvm-svn: 166104 --- compiler-rt/lib/asan/tests/CMakeLists.txt | 1 + compiler-rt/lib/asan/tests/asan_noinst_test.cc | 4 ++-- compiler-rt/lib/asan/tests/asan_test.cc | 8 -------- compiler-rt/lib/asan/tests/asan_test_main.cc | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 compiler-rt/lib/asan/tests/asan_test_main.cc diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt index f2c5f39..8c81c4a 100644 --- a/compiler-rt/lib/asan/tests/CMakeLists.txt +++ b/compiler-rt/lib/asan/tests/CMakeLists.txt @@ -104,6 +104,7 @@ endfunction() set(ASAN_NOINST_TEST_SOURCES asan_noinst_test.cc asan_break_optimization.cc + asan_test_main.cc ) set(ASAN_INST_TEST_OBJECTS) diff --git a/compiler-rt/lib/asan/tests/asan_noinst_test.cc b/compiler-rt/lib/asan/tests/asan_noinst_test.cc index c6497d5..5c9608f 100644 --- a/compiler-rt/lib/asan/tests/asan_noinst_test.cc +++ b/compiler-rt/lib/asan/tests/asan_noinst_test.cc @@ -370,7 +370,7 @@ TEST(AddressSanitizerInterface, GetAllocatedSizeAndOwnershipTest) { // We cannot call GetAllocatedSize from the memory we didn't map, // and from the interior pointers (not returned by previous malloc). void *wild_addr = (void*)0x1; - EXPECT_FALSE( __asan_get_ownership(wild_addr)); + EXPECT_FALSE(__asan_get_ownership(wild_addr)); EXPECT_DEATH(__asan_get_allocated_size(wild_addr), kGetAllocatedSizeErrorMsg); EXPECT_FALSE(__asan_get_ownership(array + kArraySize / 2)); EXPECT_DEATH(__asan_get_allocated_size(array + kArraySize / 2), @@ -383,7 +383,7 @@ TEST(AddressSanitizerInterface, GetAllocatedSizeAndOwnershipTest) { // When memory is freed, it's not owned, and call to GetAllocatedSize // is forbidden. free(array); - EXPECT_FALSE( __asan_get_ownership(array)); + EXPECT_FALSE(__asan_get_ownership(array)); EXPECT_DEATH(__asan_get_allocated_size(array), kGetAllocatedSizeErrorMsg); delete int_ptr; diff --git a/compiler-rt/lib/asan/tests/asan_test.cc b/compiler-rt/lib/asan/tests/asan_test.cc index 7f0c04c..5810f8f 100644 --- a/compiler-rt/lib/asan/tests/asan_test.cc +++ b/compiler-rt/lib/asan/tests/asan_test.cc @@ -47,7 +47,6 @@ typedef uint16_t U2; typedef uint32_t U4; typedef uint64_t U8; -static const char *progname; static const int kPageSize = 4096; // Simple stand-alone pseudorandom number generator. @@ -2168,10 +2167,3 @@ TEST(AddressSanitizer, LongDoubleNegativeTest) { memcpy(Ident(&a), Ident(&b), sizeof(long double)); memcpy(Ident(&c), Ident(&b), sizeof(long double)); } - -int main(int argc, char **argv) { - progname = argv[0]; - testing::GTEST_FLAG(death_test_style) = "threadsafe"; - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/compiler-rt/lib/asan/tests/asan_test_main.cc b/compiler-rt/lib/asan/tests/asan_test_main.cc new file mode 100644 index 0000000..1746c5f --- /dev/null +++ b/compiler-rt/lib/asan/tests/asan_test_main.cc @@ -0,0 +1,19 @@ +//===-- asan_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 AddressSanitizer, an address sanity checker. +// +//===----------------------------------------------------------------------===// +#include "asan_test_utils.h" + +int main(int argc, char **argv) { + testing::GTEST_FLAG(death_test_style) = "threadsafe"; + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} -- 2.7.4