OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <gtest/gtest.h> | 5 #include <gtest/gtest.h> |
6 #include <gtest/gtest-spi.h> | 6 #include <gtest/gtest-spi.h> |
7 | 7 |
8 #include "update_engine/terminator.h" | 8 #include "update_engine/terminator.h" |
9 | 9 |
10 using std::string; | 10 using std::string; |
11 using testing::ExitedWithCode; | 11 using testing::ExitedWithCode; |
12 | 12 |
13 namespace chromeos_update_engine { | 13 namespace chromeos_update_engine { |
14 | 14 |
15 class TerminatorTest : public ::testing::Test { | 15 class TerminatorTest : public ::testing::Test { |
16 protected: | 16 protected: |
17 virtual void SetUp() { | 17 virtual void SetUp() { |
18 Terminator::Init(); | 18 Terminator::Init(); |
19 ASSERT_FALSE(Terminator::exit_blocked()); | 19 ASSERT_FALSE(Terminator::exit_blocked()); |
20 ASSERT_FALSE(Terminator::exit_requested()); | 20 ASSERT_FALSE(Terminator::exit_requested()); |
21 } | 21 } |
| 22 virtual void TearDown() { |
| 23 // Makes sure subsequent non-Terminator tests don't get accidentally |
| 24 // terminated. |
| 25 Terminator::Init(); |
| 26 } |
22 }; | 27 }; |
23 | 28 |
24 typedef TerminatorTest TerminatorDeathTest; | 29 typedef TerminatorTest TerminatorDeathTest; |
25 | 30 |
26 namespace { | 31 namespace { |
27 void UnblockExitThroughUnblocker() { | 32 void UnblockExitThroughUnblocker() { |
28 ScopedTerminatorExitUnblocker unblocker = ScopedTerminatorExitUnblocker(); | 33 ScopedTerminatorExitUnblocker unblocker = ScopedTerminatorExitUnblocker(); |
29 } | 34 } |
30 | 35 |
31 void RaiseSIGTERM() { | 36 void RaiseSIGTERM() { |
(...skipping 28 matching lines...) Expand all Loading... |
60 EXPECT_FATAL_FAILURE(RaiseSIGTERM(), ""); | 65 EXPECT_FATAL_FAILURE(RaiseSIGTERM(), ""); |
61 } | 66 } |
62 | 67 |
63 TEST_F(TerminatorDeathTest, ScopedTerminatorExitUnblockerExitTest) { | 68 TEST_F(TerminatorDeathTest, ScopedTerminatorExitUnblockerExitTest) { |
64 Terminator::set_exit_blocked(true); | 69 Terminator::set_exit_blocked(true); |
65 Terminator::exit_requested_ = 1; | 70 Terminator::exit_requested_ = 1; |
66 ASSERT_EXIT(UnblockExitThroughUnblocker(), ExitedWithCode(0), ""); | 71 ASSERT_EXIT(UnblockExitThroughUnblocker(), ExitedWithCode(0), ""); |
67 } | 72 } |
68 | 73 |
69 } // namespace chromeos_update_engine | 74 } // namespace chromeos_update_engine |
OLD | NEW |