| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ | 5 #ifndef MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ |
| 6 #define MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ | 6 #define MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // usually return -1 on error in the child (e.g., if |test_child_name| was not | 73 // usually return -1 on error in the child (e.g., if |test_child_name| was not |
| 74 // found), but this is mangled to 255 on Linux. You should only rely on codes | 74 // found), but this is mangled to 255 on Linux. You should only rely on codes |
| 75 // 0-127 being preserved, and -1 being outside the range 0-127. | 75 // 0-127 being preserved, and -1 being outside the range 0-127. |
| 76 int WaitForChildShutdown(); | 76 int WaitForChildShutdown(); |
| 77 | 77 |
| 78 // Like |WaitForChildShutdown()|, but returns true on success (exit code of 0) | 78 // Like |WaitForChildShutdown()|, but returns true on success (exit code of 0) |
| 79 // and false otherwise. You probably want to do something like | 79 // and false otherwise. You probably want to do something like |
| 80 // |EXPECT_TRUE(WaitForChildTestShutdown());|. | 80 // |EXPECT_TRUE(WaitForChildTestShutdown());|. |
| 81 bool WaitForChildTestShutdown(); | 81 bool WaitForChildTestShutdown(); |
| 82 | 82 |
| 83 const base::Process& test_child() const { return test_child_; } | 83 const base::Process& test_child() const { return test_child_.process; } |
| 84 | 84 |
| 85 // Used by macros in mojo/edk/test/mojo_test_base.h to support multiprocess | 85 // Used by macros in mojo/edk/test/mojo_test_base.h to support multiprocess |
| 86 // test client initialization. | 86 // test client initialization. |
| 87 static void ChildSetup(); | 87 static void ChildSetup(); |
| 88 static int RunClientMain(const base::Callback<int(MojoHandle)>& main); | 88 static int RunClientMain(const base::Callback<int(MojoHandle)>& main); |
| 89 static int RunClientTestMain(const base::Callback<void(MojoHandle)>& main); | 89 static int RunClientTestMain(const base::Callback<void(MojoHandle)>& main); |
| 90 | 90 |
| 91 // For use (and only valid) in the child process: | 91 // For use (and only valid) in the child process: |
| 92 static mojo::ScopedMessagePipeHandle primordial_pipe; | 92 static mojo::ScopedMessagePipeHandle primordial_pipe; |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 // Valid after |StartChild()| and before |WaitForChildShutdown()|. | 95 // Valid after |StartChild()| and before |WaitForChildShutdown()|. |
| 96 base::Process test_child_; | 96 base::SpawnChildResult test_child_; |
| 97 | 97 |
| 98 ProcessErrorCallback process_error_callback_; | 98 ProcessErrorCallback process_error_callback_; |
| 99 | 99 |
| 100 std::string peer_token_; | 100 std::string peer_token_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(MultiprocessTestHelper); | 102 DISALLOW_COPY_AND_ASSIGN(MultiprocessTestHelper); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 } // namespace test | 105 } // namespace test |
| 106 } // namespace edk | 106 } // namespace edk |
| 107 } // namespace mojo | 107 } // namespace mojo |
| 108 | 108 |
| 109 #endif // MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ | 109 #endif // MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ |
| OLD | NEW |