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 #ifndef CRASHPAD_UTIL_TEST_MULTIPROCESS_H_ | 15 #ifndef CRASHPAD_UTIL_TEST_MULTIPROCESS_H_ |
16 #define CRASHPAD_UTIL_TEST_MULTIPROCESS_H_ | 16 #define CRASHPAD_UTIL_TEST_MULTIPROCESS_H_ |
17 | 17 |
18 #include <unistd.h> | 18 #include <sys/types.h> |
19 | 19 |
20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
21 #include "util/file/file_io.h" | |
21 | 22 |
22 namespace crashpad { | 23 namespace crashpad { |
23 namespace test { | 24 namespace test { |
24 | 25 |
25 namespace internal { | 26 namespace internal { |
26 struct MultiprocessInfo; | 27 struct MultiprocessInfo; |
27 }; | 28 }; |
28 | 29 |
29 //! \brief Manages a multiprocess test. | 30 //! \brief Manages a multiprocess test. |
30 //! | 31 //! |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 //! | 102 //! |
102 //! Subclass implementations may signal failure by raising their own fatal | 103 //! Subclass implementations may signal failure by raising their own fatal |
103 //! gtest assertions. | 104 //! gtest assertions. |
104 virtual void PreFork(); | 105 virtual void PreFork(); |
105 | 106 |
106 //! \brief Returns the child process’ process ID. | 107 //! \brief Returns the child process’ process ID. |
107 //! | 108 //! |
108 //! This method may only be called by the parent process. | 109 //! This method may only be called by the parent process. |
109 pid_t ChildPID() const; | 110 pid_t ChildPID() const; |
110 | 111 |
111 //! \brief Returns the read pipe’s file descriptor. | 112 //! \brief Returns the read pipe’s file handle. |
112 //! | 113 //! |
113 //! This method may be called by either the parent or the child process. | 114 //! This method may be called by either the parent or the child process. |
114 //! Anything written to the write pipe in the partner process will appear | 115 //! Anything written to the write pipe in the partner process will appear |
115 //! on the this file descriptor in this process. | 116 //! on this file handle in this process. |
116 //! | 117 //! |
117 //! It is an error to call this after CloseReadPipe() has been called. | 118 //! It is an error to call this after CloseReadPipe() has been called. |
118 //! | 119 //! |
119 //! \return The read pipe’s file descriptor. | 120 //! \return The read pipe’s file handle. |
120 int ReadPipeFD() const; | 121 FileHandle ReadPipeHandle() const; |
121 | 122 |
122 //! \brief Returns the write pipe’s file descriptor. | 123 //! \brief Returns the write pipe’s file handle. |
123 //! | 124 //! |
124 //! This method may be called by either the parent or the child process. | 125 //! This method may be called by either the parent or the child process. |
125 //! Anything written to this file descriptor in this process will appear on | 126 //! Anything written to this file handle in this process will appear on |
126 //! the read pipe in the partner process. | 127 //! the read pipe in the partner process. |
127 //! | 128 //! |
128 //! It is an error to call this after CloseWritePipe() has been called. | 129 //! It is an error to call this after CloseWritePipe() has been called. |
129 //! | 130 //! |
130 //! \return The write pipe’s file descriptor. | 131 //! \return The write pipe’s file handle. |
131 int WritePipeFD() const; | 132 FileHandle WritePipeHandle() const; |
132 | 133 |
133 //! \brief Closes the read pipe. | 134 //! \brief Closes the read pipe. |
134 //! | 135 //! |
135 //! This method may be called by either the parent or the child process. An | 136 //! This method may be called by either the parent or the child process. An |
136 //! attempt to write to the write pipe in the partner process will fail with | 137 //! attempt to write to the write pipe in the partner process will fail with |
137 //! `EPIPE` or `SIGPIPE`. ReadPipeFD() must not be called after this. | 138 //! `EPIPE` or `SIGPIPE`. ReadPipeHandle() must not be called after this. |
138 void CloseReadPipe(); | 139 void CloseReadPipe(); |
139 | 140 |
140 //! \brief Closes the write pipe. | 141 //! \brief Closes the write pipe. |
141 //! | 142 //! |
142 //! This method may be called by either the parent or the child process. An | 143 //! This method may be called by either the parent or the child process. An |
143 //! attempt to read from the read pipe in the partner process will indicate | 144 //! attempt to read from the read pipe in the partner process will indicate |
144 //! end-of-file. WritePipeFD() must not be called after this. | 145 //! end-of-file. WritePipeHandle() must not be called after this. |
145 void CloseWritePipe(); | 146 void CloseWritePipe(); |
146 | 147 |
148 void set_info(internal::MultiprocessInfo* info) { info_ = info; } | |
149 internal::MultiprocessInfo* info() { return info_; } | |
Mark Mentovai
2015/01/28 19:58:27
This should be const.
scottmg
2015/01/28 22:14:57
Done. It still has to return a non-const* though a
Mark Mentovai
2015/01/28 22:32:54
scottmg wrote:
| |
150 | |
147 private: | 151 private: |
148 //! \brief Runs the parent side of the test. | 152 //! \brief Runs the parent side of the test. |
149 //! | 153 //! |
150 //! This method establishes the parent’s environment and calls | 154 //! This method establishes the parent’s environment and calls |
151 //! MultiprocessParent(). | 155 //! MultiprocessParent(). |
152 void RunParent(); | 156 void RunParent(); |
153 | 157 |
154 //! \brief Runs the child side of the test. | 158 //! \brief Runs the child side of the test. |
155 //! | 159 //! |
156 //! This method establishes the child’s environment, calls | 160 //! This method establishes the child’s environment, calls |
(...skipping 25 matching lines...) Expand all Loading... | |
182 int code_; | 186 int code_; |
183 TerminationReason reason_; | 187 TerminationReason reason_; |
184 | 188 |
185 DISALLOW_COPY_AND_ASSIGN(Multiprocess); | 189 DISALLOW_COPY_AND_ASSIGN(Multiprocess); |
186 }; | 190 }; |
187 | 191 |
188 } // namespace test | 192 } // namespace test |
189 } // namespace crashpad | 193 } // namespace crashpad |
190 | 194 |
191 #endif // CRASHPAD_UTIL_TEST_MULTIPROCESS_H_ | 195 #endif // CRASHPAD_UTIL_TEST_MULTIPROCESS_H_ |
OLD | NEW |