OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 void WinMultiprocessChild() override { | 35 void WinMultiprocessChild() override { |
36 exit(exit_code_); | 36 exit(exit_code_); |
37 } | 37 } |
38 | 38 |
39 unsigned int exit_code_; | 39 unsigned int exit_code_; |
40 | 40 |
41 DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocess); | 41 DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocess); |
42 }; | 42 }; |
43 | 43 |
| 44 enum class FailureType { |
| 45 kExpect, |
| 46 kAssert, |
| 47 }; |
| 48 |
| 49 class TestWinMultiprocessChildFails final : public WinMultiprocess { |
| 50 public: |
| 51 explicit TestWinMultiprocessChildFails(FailureType failure_type) |
| 52 : WinMultiprocess(), failure_type_(failure_type) {} |
| 53 ~TestWinMultiprocessChildFails() {} |
| 54 |
| 55 private: |
| 56 void WinMultiprocessParent() override {} |
| 57 void WinMultiprocessChild() override { |
| 58 switch (failure_type_) { |
| 59 case FailureType::kExpect: |
| 60 EXPECT_FALSE(true); |
| 61 break; |
| 62 case FailureType::kAssert: |
| 63 ASSERT_FALSE(true); |
| 64 break; |
| 65 } |
| 66 } |
| 67 |
| 68 FailureType failure_type_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocessChildFails); |
| 71 }; |
| 72 |
| 73 |
44 TEST(WinMultiprocess, WinMultiprocess) { | 74 TEST(WinMultiprocess, WinMultiprocess) { |
45 TestWinMultiprocess win_multiprocess(0); | 75 TestWinMultiprocess win_multiprocess(0); |
46 win_multiprocess.Run(); | 76 win_multiprocess.Run(); |
47 } | 77 } |
48 | 78 |
49 TEST(WinMultiprocess, WinMultiprocessNonSuccessExitCode) { | 79 TEST(WinMultiprocess, WinMultiprocessNonSuccessExitCode) { |
50 TestWinMultiprocess win_multiprocess(100); | 80 TestWinMultiprocess win_multiprocess(100); |
51 win_multiprocess.SetExpectedChildExitCode(100); | 81 win_multiprocess.SetExpectedChildExitCode(100); |
52 win_multiprocess.Run(); | 82 win_multiprocess.Run(); |
53 } | 83 } |
54 | 84 |
| 85 TEST(WinMultiprocessChildFails, ChildExpectFailure) { |
| 86 TestWinMultiprocessChildFails multiprocess_failing_child( |
| 87 FailureType::kExpect); |
| 88 multiprocess_failing_child.SetExpectedChildExitCode(255); |
| 89 multiprocess_failing_child.Run(); |
| 90 } |
| 91 |
| 92 TEST(WinMultiprocessChildFails, ChildAssertFailure) { |
| 93 TestWinMultiprocessChildFails multiprocess_failing_child( |
| 94 FailureType::kAssert); |
| 95 multiprocess_failing_child.SetExpectedChildExitCode(255); |
| 96 multiprocess_failing_child.Run(); |
| 97 } |
| 98 |
55 } // namespace | 99 } // namespace |
56 } // namespace test | 100 } // namespace test |
57 } // namespace crashpad | 101 } // namespace crashpad |
OLD | NEW |