blob: 982b83a1bddc996c0dbc6f542fa362ca6e7d2220 [file] [log] [blame]
Christopher Wileya6b3fcd2012-08-10 10:44:03 -07001// 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 <chromeos/syslog_logging.h>
7#include <gtest/gtest.h>
8
9namespace chromeos {
10
11class SyslogLoggingDeathTest : public ::testing::Test {
12 public:
Alex Vakulenko05d29042015-01-13 09:39:25 -080013 SyslogLoggingDeathTest() {}
14 virtual ~SyslogLoggingDeathTest() {}
Christopher Wileya6b3fcd2012-08-10 10:44:03 -070015
16 private:
17 DISALLOW_COPY_AND_ASSIGN(SyslogLoggingDeathTest);
18};
19
20TEST_F(SyslogLoggingDeathTest, FatalLoggingIsFatal) {
21 int old_flags = GetLogFlags();
22 SetLogFlags(kLogToStderr);
Alex Vakulenko05d29042015-01-13 09:39:25 -080023 EXPECT_DEATH({ LOG(FATAL) << "First Fatality!"; }, "First Fatality!");
Christopher Wileya6b3fcd2012-08-10 10:44:03 -070024 // No flags == don't log to syslog, stderr, or accumulated string.
25 SetLogFlags(0);
26 // Still a fatal log message
Alex Vakulenko05d29042015-01-13 09:39:25 -080027 EXPECT_DEATH({ LOG(FATAL) << "Second Fatality!"; }, "Second Fatality!");
Christopher Wileya6b3fcd2012-08-10 10:44:03 -070028 SetLogFlags(old_flags);
29}
30
Bertrand SIMONNETb54b6dc2014-07-02 12:13:56 -070031} // namespace chromeos