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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class MachMultiprocess : public Multiprocess { | 42 class MachMultiprocess : public Multiprocess { |
43 public: | 43 public: |
44 MachMultiprocess(); | 44 MachMultiprocess(); |
45 | 45 |
46 void Run(); | 46 void Run(); |
47 | 47 |
48 protected: | 48 protected: |
49 ~MachMultiprocess(); | 49 ~MachMultiprocess(); |
50 | 50 |
51 // Multiprocess: | 51 // Multiprocess: |
52 virtual void PreFork() override; | 52 void PreFork() override; |
53 | 53 |
54 //! \brief Returns a receive right for the local port. | 54 //! \brief Returns a receive right for the local port. |
55 //! | 55 //! |
56 //! This method may be called by either the parent or the child process. It | 56 //! This method may be called by either the parent or the child process. It |
57 //! returns a receive right, with a corresponding send right held in the | 57 //! returns a receive right, with a corresponding send right held in the |
58 //! opposing process. | 58 //! opposing process. |
59 mach_port_t LocalPort() const; | 59 mach_port_t LocalPort() const; |
60 | 60 |
61 //! \brief Returns a send right for the remote port. | 61 //! \brief Returns a send right for the remote port. |
62 //! | 62 //! |
63 //! This method may be called by either the parent or the child process. It | 63 //! This method may be called by either the parent or the child process. It |
64 //! returns a send right, with the corresponding receive right held in the | 64 //! returns a send right, with the corresponding receive right held in the |
65 //! opposing process. | 65 //! opposing process. |
66 mach_port_t RemotePort() const; | 66 mach_port_t RemotePort() const; |
67 | 67 |
68 //! \brief Returns a send right for the child’s task port. | 68 //! \brief Returns a send right for the child’s task port. |
69 //! | 69 //! |
70 //! This method may only be called by the parent process. | 70 //! This method may only be called by the parent process. |
71 task_t ChildTask() const; | 71 task_t ChildTask() const; |
72 | 72 |
73 private: | 73 private: |
74 // Multiprocess: | 74 // Multiprocess: |
75 | 75 |
76 //! \brief Runs the parent side of the test. | 76 //! \brief Runs the parent side of the test. |
77 //! | 77 //! |
78 //! This method establishes the parent’s environment and calls | 78 //! This method establishes the parent’s environment and calls |
79 //! MachMultiprocessParent(). | 79 //! MachMultiprocessParent(). |
80 //! | 80 //! |
81 //! Subclasses must override MachMultiprocessParent() instead of this method. | 81 //! Subclasses must override MachMultiprocessParent() instead of this method. |
82 virtual void MultiprocessParent() override final; | 82 void MultiprocessParent() final; |
83 | 83 |
84 //! \brief Runs the child side of the test. | 84 //! \brief Runs the child side of the test. |
85 //! | 85 //! |
86 //! This method establishes the child’s environment and calls | 86 //! This method establishes the child’s environment and calls |
87 //! MachMultiprocessChild(). If any failure (via fatal or nonfatal gtest | 87 //! MachMultiprocessChild(). If any failure (via fatal or nonfatal gtest |
88 //! assertion) is detected, the child will exit with a failure status. | 88 //! assertion) is detected, the child will exit with a failure status. |
89 //! | 89 //! |
90 //! Subclasses must override MachMultiprocessChild() instead of this method. | 90 //! Subclasses must override MachMultiprocessChild() instead of this method. |
91 virtual void MultiprocessChild() override final; | 91 void MultiprocessChild() final; |
92 | 92 |
93 //! \brief The subclass-provided parent routine. | 93 //! \brief The subclass-provided parent routine. |
94 //! | 94 //! |
95 //! Test failures should be reported via gtest: `EXPECT_*()`, `ASSERT_*()`, | 95 //! Test failures should be reported via gtest: `EXPECT_*()`, `ASSERT_*()`, |
96 //! `FAIL()`, etc. | 96 //! `FAIL()`, etc. |
97 //! | 97 //! |
98 //! This method must not use a `wait()`-family system call to wait for the | 98 //! This method must not use a `wait()`-family system call to wait for the |
99 //! child process to exit, as this is handled by the superclass. | 99 //! child process to exit, as this is handled by the superclass. |
100 //! | 100 //! |
101 //! Subclasses must implement this method to define how the parent operates. | 101 //! Subclasses must implement this method to define how the parent operates. |
102 virtual void MachMultiprocessParent() = 0; | 102 virtual void MachMultiprocessParent() = 0; |
103 | 103 |
104 //! \brief The subclass-provided child routine. | 104 //! \brief The subclass-provided child routine. |
105 //! | 105 //! |
106 //! Test failures should be reported via gtest: `EXPECT_*()`, `ASSERT_*()`, | 106 //! Test failures should be reported via gtest: `EXPECT_*()`, `ASSERT_*()`, |
107 //! `FAIL()`, etc. | 107 //! `FAIL()`, etc. |
108 //! | 108 //! |
109 //! Subclasses must implement this method to define how the child operates. | 109 //! Subclasses must implement this method to define how the child operates. |
110 virtual void MachMultiprocessChild() = 0; | 110 virtual void MachMultiprocessChild() = 0; |
111 | 111 |
112 internal::MachMultiprocessInfo* info_; | 112 internal::MachMultiprocessInfo* info_; |
113 | 113 |
114 DISALLOW_COPY_AND_ASSIGN(MachMultiprocess); | 114 DISALLOW_COPY_AND_ASSIGN(MachMultiprocess); |
115 }; | 115 }; |
116 | 116 |
117 } // namespace test | 117 } // namespace test |
118 } // namespace crashpad | 118 } // namespace crashpad |
119 | 119 |
120 #endif // CRASHPAD_UTIL_TEST_MAC_MACH_MULTIPROCESS_H_ | 120 #endif // CRASHPAD_UTIL_TEST_MAC_MACH_MULTIPROCESS_H_ |
OLD | NEW |