Fix regression of r23.
[platform/upstream/glog.git] / src / logging_unittest.cc
index 14c9789..0e25478 100644 (file)
@@ -1,6 +1,31 @@
+// Copyright (c) 2002, Google Inc.
+// All rights reserved.
 //
-// Copyright 2002 Google, Inc.
-// All Rights Reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 //
 // Author: Ray Sidney
 
@@ -23,6 +48,9 @@
 #include <string>
 #include <vector>
 
+#include <stdio.h>
+#include <stdlib.h>
+
 #include "base/commandlineflags.h"
 #include "glog/logging.h"
 #include "glog/raw_logging.h"
 
 DECLARE_string(log_backtrace_at);  // logging.cc
 
+#ifdef HAVE_LIB_GFLAGS
+#include <gflags/gflags.h>
+#endif
+
 #ifdef HAVE_LIB_GMOCK
 #include <gmock/gmock.h>
 #include "mock-log.h"
@@ -140,6 +172,10 @@ static void BM_vlog(int n) {
 BENCHMARK(BM_vlog);
 
 int main(int argc, char **argv) {
+#ifdef HAVE_LIB_GFLAGS
+  ParseCommandLineFlags(&argc, &argv, true);
+#endif
+
   // Test some basics before InitGoogleLogging:
   CaptureTestStderr();
   LogWithLevels(FLAGS_v, FLAGS_stderrthreshold,
@@ -154,7 +190,7 @@ int main(int argc, char **argv) {
   FLAGS_logtostderr = true;
 
   InitGoogleTest(&argc, argv);
-#ifdef HAVE_LIB_GTEST
+#ifdef HAVE_LIB_GMOCK
   InitGoogleMock(&argc, argv);
 #endif
 
@@ -1092,10 +1128,12 @@ TEST(TestExitOnDFatal, ToBeOrNotToBe) {
   base::internal::SetExitOnDFatal(true);
   EXPECT_TRUE(base::internal::GetExitOnDFatal());
 
+#ifdef GTEST_HAS_DEATH_TEST
   // Death comes on little cats' feet.
   EXPECT_DEBUG_DEATH({
       LOG(DFATAL) << "This should be fatal in debug mode";
     }, "This should be fatal in debug mode");
+#endif
 }
 
 #ifdef HAVE_STACKTRACE