aboutsummaryrefslogtreecommitdiff
path: root/brillo/syslog_logging_unittest.cc
blob: e852e506ee8be675172ea40f4373c784884bebcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <base/logging.h>
#include <brillo/syslog_logging.h>
#include <gtest/gtest.h>

namespace brillo {

class SyslogLoggingDeathTest : public ::testing::Test {
 public:
  SyslogLoggingDeathTest() {}
  virtual ~SyslogLoggingDeathTest() {}

 private:
  DISALLOW_COPY_AND_ASSIGN(SyslogLoggingDeathTest);
};

TEST_F(SyslogLoggingDeathTest, FatalLoggingIsFatal) {
  int old_flags = GetLogFlags();
  SetLogFlags(kLogToStderr);
  EXPECT_DEATH({ LOG(FATAL) << "First Fatality!"; }, "First Fatality!");
  // No flags == don't log to syslog, stderr, or accumulated string.
  SetLogFlags(0);
  // Still a fatal log message
  EXPECT_DEATH({ LOG(FATAL) << "Second Fatality!"; }, "Second Fatality!");
  SetLogFlags(old_flags);
}

}  // namespace brillo