OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 class ScopedTaskSuspendTest final : public MachMultiprocess { | 45 class ScopedTaskSuspendTest final : public MachMultiprocess { |
46 public: | 46 public: |
47 ScopedTaskSuspendTest() : MachMultiprocess() {} | 47 ScopedTaskSuspendTest() : MachMultiprocess() {} |
48 ~ScopedTaskSuspendTest() {} | 48 ~ScopedTaskSuspendTest() {} |
49 | 49 |
50 private: | 50 private: |
51 // MachMultiprocess: | 51 // MachMultiprocess: |
52 | 52 |
53 virtual void MachMultiprocessParent() override { | 53 void MachMultiprocessParent() override { |
54 task_t child_task = ChildTask(); | 54 task_t child_task = ChildTask(); |
55 | 55 |
56 EXPECT_EQ(0, SuspendCount(child_task)); | 56 EXPECT_EQ(0, SuspendCount(child_task)); |
57 | 57 |
58 { | 58 { |
59 ScopedTaskSuspend suspend(child_task); | 59 ScopedTaskSuspend suspend(child_task); |
60 EXPECT_EQ(1, SuspendCount(child_task)); | 60 EXPECT_EQ(1, SuspendCount(child_task)); |
61 | 61 |
62 { | 62 { |
63 ScopedTaskSuspend suspend_again(child_task); | 63 ScopedTaskSuspend suspend_again(child_task); |
64 EXPECT_EQ(2, SuspendCount(child_task)); | 64 EXPECT_EQ(2, SuspendCount(child_task)); |
65 } | 65 } |
66 | 66 |
67 EXPECT_EQ(1, SuspendCount(child_task)); | 67 EXPECT_EQ(1, SuspendCount(child_task)); |
68 } | 68 } |
69 | 69 |
70 EXPECT_EQ(0, SuspendCount(child_task)); | 70 EXPECT_EQ(0, SuspendCount(child_task)); |
71 } | 71 } |
72 | 72 |
73 virtual void MachMultiprocessChild() override { | 73 void MachMultiprocessChild() override { |
74 CheckedReadFDAtEOF(ReadPipeFD()); | 74 CheckedReadFDAtEOF(ReadPipeFD()); |
75 } | 75 } |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(ScopedTaskSuspendTest); | 77 DISALLOW_COPY_AND_ASSIGN(ScopedTaskSuspendTest); |
78 }; | 78 }; |
79 | 79 |
80 TEST(ScopedTaskSuspend, ScopedTaskSuspend) { | 80 TEST(ScopedTaskSuspend, ScopedTaskSuspend) { |
81 ScopedTaskSuspendTest scoped_task_suspend_test; | 81 ScopedTaskSuspendTest scoped_task_suspend_test; |
82 scoped_task_suspend_test.Run(); | 82 scoped_task_suspend_test.Run(); |
83 } | 83 } |
84 | 84 |
85 } // namespace | 85 } // namespace |
86 } // namespace test | 86 } // namespace test |
87 } // namespace crashpad | 87 } // namespace crashpad |
OLD | NEW |