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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "util/test/multiprocess.h" | 15 #include "util/test/multiprocess.h" |
16 | 16 |
17 #include <signal.h> | 17 #include <signal.h> |
18 #include <stdlib.h> | 18 #include <stdlib.h> |
19 #include <sys/wait.h> | 19 #include <sys/wait.h> |
| 20 #include <unistd.h> |
20 | 21 |
21 #include <string> | 22 #include <string> |
22 | 23 |
23 #include "base/auto_reset.h" | 24 #include "base/auto_reset.h" |
24 #include "base/files/scoped_file.h" | 25 #include "base/files/scoped_file.h" |
25 #include "base/logging.h" | 26 #include "base/logging.h" |
26 #include "base/memory/scoped_ptr.h" | 27 #include "base/memory/scoped_ptr.h" |
27 #include "base/posix/eintr_wrapper.h" | 28 #include "base/posix/eintr_wrapper.h" |
28 #include "base/strings/stringprintf.h" | 29 #include "base/strings/stringprintf.h" |
29 #include "gtest/gtest.h" | 30 #include "gtest/gtest.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 147 |
147 info_->pipe_p2c_read.reset(pipe_fds_p2c[0]); | 148 info_->pipe_p2c_read.reset(pipe_fds_p2c[0]); |
148 info_->pipe_p2c_write.reset(pipe_fds_p2c[1]); | 149 info_->pipe_p2c_write.reset(pipe_fds_p2c[1]); |
149 } | 150 } |
150 | 151 |
151 pid_t Multiprocess::ChildPID() const { | 152 pid_t Multiprocess::ChildPID() const { |
152 EXPECT_NE(0, info_->child_pid); | 153 EXPECT_NE(0, info_->child_pid); |
153 return info_->child_pid; | 154 return info_->child_pid; |
154 } | 155 } |
155 | 156 |
156 int Multiprocess::ReadPipeFD() const { | 157 FileHandle Multiprocess::ReadPipeHandle() const { |
157 int fd = info_->child_pid ? info_->pipe_c2p_read.get() | 158 int fd = info_->child_pid ? info_->pipe_c2p_read.get() |
158 : info_->pipe_p2c_read.get(); | 159 : info_->pipe_p2c_read.get(); |
159 CHECK_NE(fd, -1); | 160 CHECK_NE(fd, -1); |
160 return fd; | 161 return fd; |
161 } | 162 } |
162 | 163 |
163 int Multiprocess::WritePipeFD() const { | 164 FileHandle Multiprocess::WritePipeHandle() const { |
164 int fd = info_->child_pid ? info_->pipe_p2c_write.get() | 165 int fd = info_->child_pid ? info_->pipe_p2c_write.get() |
165 : info_->pipe_c2p_write.get(); | 166 : info_->pipe_c2p_write.get(); |
166 CHECK_NE(fd, -1); | 167 CHECK_NE(fd, -1); |
167 return fd; | 168 return fd; |
168 } | 169 } |
169 | 170 |
170 void Multiprocess::CloseReadPipe() { | 171 void Multiprocess::CloseReadPipe() { |
171 if (info_->child_pid) { | 172 if (info_->child_pid) { |
172 info_->pipe_c2p_read.reset(); | 173 info_->pipe_c2p_read.reset(); |
173 } else { | 174 } else { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 if (testing::Test::HasFailure()) { | 210 if (testing::Test::HasFailure()) { |
210 // Trigger the ScopedForbidReturn destructor. | 211 // Trigger the ScopedForbidReturn destructor. |
211 return; | 212 return; |
212 } | 213 } |
213 | 214 |
214 exit(0); | 215 exit(0); |
215 } | 216 } |
216 | 217 |
217 } // namespace test | 218 } // namespace test |
218 } // namespace crashpad | 219 } // namespace crashpad |
OLD | NEW |