[ASan] unit tests: Move main() to a separate file. Fix lint
authorAlexey Samsonov <samsonov@google.com>
Wed, 17 Oct 2012 14:04:57 +0000 (14:04 +0000)
committerAlexey Samsonov <samsonov@google.com>
Wed, 17 Oct 2012 14:04:57 +0000 (14:04 +0000)
llvm-svn: 166104

compiler-rt/lib/asan/tests/CMakeLists.txt
compiler-rt/lib/asan/tests/asan_noinst_test.cc
compiler-rt/lib/asan/tests/asan_test.cc
compiler-rt/lib/asan/tests/asan_test_main.cc [new file with mode: 0644]

index f2c5f39..8c81c4a 100644 (file)
@@ -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)
index c6497d5..5c9608f 100644 (file)
@@ -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;
index 7f0c04c..5810f8f 100644 (file)
@@ -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 (file)
index 0000000..1746c5f
--- /dev/null
@@ -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();
+}