Home | History | Annotate | Download | only in brillo
      1 // Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include <base/logging.h>
      6 #include <brillo/syslog_logging.h>
      7 #include <gtest/gtest.h>
      8 
      9 namespace brillo {
     10 
     11 class SyslogLoggingDeathTest : public ::testing::Test {
     12  public:
     13   SyslogLoggingDeathTest() {}
     14   virtual ~SyslogLoggingDeathTest() {}
     15 
     16  private:
     17   DISALLOW_COPY_AND_ASSIGN(SyslogLoggingDeathTest);
     18 };
     19 
     20 TEST_F(SyslogLoggingDeathTest, FatalLoggingIsFatal) {
     21   int old_flags = GetLogFlags();
     22   SetLogFlags(kLogToStderr);
     23   EXPECT_DEATH({ LOG(FATAL) << "First Fatality!"; }, "First Fatality!");
     24   // No flags == don't log to syslog, stderr, or accumulated string.
     25   SetLogFlags(0);
     26   // Still a fatal log message
     27   EXPECT_DEATH({ LOG(FATAL) << "Second Fatality!"; }, "Second Fatality!");
     28   SetLogFlags(old_flags);
     29 }
     30 
     31 }  // namespace brillo
     32