Chromium Code Reviews| 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_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_ | 5 #ifndef MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_ |
| 6 #define MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_ | 6 #define MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| (below). | 29 // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| (below). |
| 30 void StartChild(const std::string& test_child_name); | 30 void StartChild(const std::string& test_child_name); |
| 31 // Wait for the child process to terminate. | 31 // Wait for the child process to terminate. |
| 32 // Returns the exit code of the child process. Note that, though it's declared | 32 // Returns the exit code of the child process. Note that, though it's declared |
| 33 // to be an |int|, the exit code is subject to mangling by the OS. E.g., we | 33 // to be an |int|, the exit code is subject to mangling by the OS. E.g., we |
| 34 // usually return -1 on error in the child (e.g., if |test_child_name| was not | 34 // usually return -1 on error in the child (e.g., if |test_child_name| was not |
| 35 // found), but this is mangled to 255 on Linux. You should only rely on codes | 35 // found), but this is mangled to 255 on Linux. You should only rely on codes |
| 36 // 0-127 being preserved, and -1 being outside the range 0-127. | 36 // 0-127 being preserved, and -1 being outside the range 0-127. |
| 37 int WaitForChildShutdown(); | 37 int WaitForChildShutdown(); |
| 38 | 38 |
| 39 // This returns a non-const reference to the scoped pointer, so that tests can | |
| 40 // take ownership if they want. | |
| 41 scoped_ptr<system::PlatformServerChannel>& platform_server_channel() { | |
|
darin (slow to review)
2013/12/03 22:36:02
per style guide, shouldn't this be a pointer type?
| |
| 42 return platform_server_channel_; | |
| 43 } | |
| 44 | |
| 39 // For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only: | 45 // For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only: |
| 40 static void ChildSetup(); | 46 static void ChildSetup(); |
| 41 | 47 |
| 42 system::PlatformServerChannel* platform_server_channel() { | 48 // For use in the child process: |
| 43 return platform_server_channel_.get(); | 49 static scoped_ptr<system::PlatformClientChannel> platform_client_channel; |
| 44 } | |
| 45 | 50 |
| 46 private: | 51 private: |
| 47 virtual CommandLine MakeCmdLine(const std::string& procname, | 52 virtual CommandLine MakeCmdLine(const std::string& procname, |
| 48 bool debug_on_start) OVERRIDE; | 53 bool debug_on_start) OVERRIDE; |
| 49 | 54 |
| 50 // Valid after |StartChild()| and before |WaitForChildShutdown()|. | 55 // Valid after |StartChild()| and before |WaitForChildShutdown()|. |
| 51 base::ProcessHandle test_child_handle_; | 56 base::ProcessHandle test_child_handle_; |
| 52 | 57 |
| 53 scoped_ptr<system::PlatformServerChannel> platform_server_channel_; | 58 scoped_ptr<system::PlatformServerChannel> platform_server_channel_; |
| 54 | 59 |
| 55 DISALLOW_COPY_AND_ASSIGN(MultiprocessTestBase); | 60 DISALLOW_COPY_AND_ASSIGN(MultiprocessTestBase); |
| 56 }; | 61 }; |
| 57 | 62 |
| 58 // Use this to declare the child process's "main()" function for tests using | 63 // Use this to declare the child process's "main()" function for tests using |
| 59 // |MultiprocessTestBase|. It returns an |int|, which will be the process's exit | 64 // |MultiprocessTestBase|. It returns an |int|, which will be the process's exit |
| 60 // code (but see the comment about |WaitForChildShutdown()|). | 65 // code (but see the comment about |WaitForChildShutdown()|). |
| 61 #define MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) \ | 66 #define MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) \ |
| 62 MULTIPROCESS_TEST_MAIN_WITH_SETUP( \ | 67 MULTIPROCESS_TEST_MAIN_WITH_SETUP( \ |
| 63 test_child_name ## TestChildMain, \ | 68 test_child_name ## TestChildMain, \ |
| 64 ::mojo::test::MultiprocessTestBase::ChildSetup) | 69 ::mojo::test::MultiprocessTestBase::ChildSetup) |
| 65 | 70 |
| 66 } // namespace test | 71 } // namespace test |
| 67 } // namespace mojo | 72 } // namespace mojo |
| 68 | 73 |
| 69 #endif // MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_ | 74 #endif // MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_ |
| OLD | NEW |