Christopher Wiley | a6b3fcd | 2012-08-10 10:44:03 -0700 | [diff] [blame] | 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 <chromeos/syslog_logging.h> |
| 7 | #include <gtest/gtest.h> |
| 8 | |
| 9 | namespace chromeos { |
| 10 | |
| 11 | class SyslogLoggingDeathTest : public ::testing::Test { |
| 12 | public: |
Alex Vakulenko | 05d2904 | 2015-01-13 09:39:25 -0800 | [diff] [blame] | 13 | SyslogLoggingDeathTest() {} |
| 14 | virtual ~SyslogLoggingDeathTest() {} |
Christopher Wiley | a6b3fcd | 2012-08-10 10:44:03 -0700 | [diff] [blame] | 15 | |
| 16 | private: |
| 17 | DISALLOW_COPY_AND_ASSIGN(SyslogLoggingDeathTest); |
| 18 | }; |
| 19 | |
| 20 | TEST_F(SyslogLoggingDeathTest, FatalLoggingIsFatal) { |
| 21 | int old_flags = GetLogFlags(); |
| 22 | SetLogFlags(kLogToStderr); |
Alex Vakulenko | 05d2904 | 2015-01-13 09:39:25 -0800 | [diff] [blame] | 23 | EXPECT_DEATH({ LOG(FATAL) << "First Fatality!"; }, "First Fatality!"); |
Christopher Wiley | a6b3fcd | 2012-08-10 10:44:03 -0700 | [diff] [blame] | 24 | // No flags == don't log to syslog, stderr, or accumulated string. |
| 25 | SetLogFlags(0); |
| 26 | // Still a fatal log message |
Alex Vakulenko | 05d2904 | 2015-01-13 09:39:25 -0800 | [diff] [blame] | 27 | EXPECT_DEATH({ LOG(FATAL) << "Second Fatality!"; }, "Second Fatality!"); |
Christopher Wiley | a6b3fcd | 2012-08-10 10:44:03 -0700 | [diff] [blame] | 28 | SetLogFlags(old_flags); |
| 29 | } |
| 30 | |
Bertrand SIMONNET | b54b6dc | 2014-07-02 12:13:56 -0700 | [diff] [blame] | 31 | } // namespace chromeos |