| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "test/win/win_multiprocess.h" |
| 16 |
| 17 #include "base/basictypes.h" |
| 18 #include "gtest/gtest.h" |
| 19 |
| 20 namespace crashpad { |
| 21 namespace test { |
| 22 namespace { |
| 23 |
| 24 template <int ExitCode> |
| 25 class TestWinMultiprocess final : public WinMultiprocess { |
| 26 public: |
| 27 TestWinMultiprocess() {} |
| 28 |
| 29 private: |
| 30 // WinMultiprocess will have already exercised the pipes. |
| 31 void WinMultiprocessParent() override { SetExpectedChildExitCode(ExitCode); } |
| 32 |
| 33 void WinMultiprocessChild() override { |
| 34 exit(ExitCode); |
| 35 } |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocess); |
| 38 }; |
| 39 |
| 40 class TestWinMultiprocessChildAsserts final : public WinMultiprocess { |
| 41 public: |
| 42 TestWinMultiprocessChildAsserts() {} |
| 43 |
| 44 private: |
| 45 void WinMultiprocessParent() override { SetExpectedChildExitCode(255); } |
| 46 void WinMultiprocessChild() override { |
| 47 ASSERT_FALSE(true); |
| 48 } |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocessChildAsserts); |
| 51 }; |
| 52 |
| 53 class TestWinMultiprocessChildExpects final : public WinMultiprocess { |
| 54 public: |
| 55 TestWinMultiprocessChildExpects() {} |
| 56 |
| 57 private: |
| 58 void WinMultiprocessParent() override { SetExpectedChildExitCode(255); } |
| 59 void WinMultiprocessChild() override { |
| 60 EXPECT_FALSE(true); |
| 61 } |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocessChildExpects); |
| 64 }; |
| 65 |
| 66 TEST(WinMultiprocess, WinMultiprocess) { |
| 67 WinMultiprocess::Run<TestWinMultiprocess<0>>(); |
| 68 } |
| 69 |
| 70 TEST(WinMultiprocess, WinMultiprocessNonSuccessExitCode) { |
| 71 WinMultiprocess::Run<TestWinMultiprocess<100>>(); |
| 72 } |
| 73 |
| 74 TEST(WinMultiprocessChildFails, ChildExpectFailure) { |
| 75 WinMultiprocess::Run<TestWinMultiprocessChildExpects>(); |
| 76 } |
| 77 |
| 78 TEST(WinMultiprocessChildFails, ChildAssertFailure) { |
| 79 WinMultiprocess::Run<TestWinMultiprocessChildAsserts>(); |
| 80 } |
| 81 |
| 82 } // namespace |
| 83 } // namespace test |
| 84 } // namespace crashpad |
| OLD | NEW |