Chromium Code Reviews| Index: base/test/multiprocess_test.h |
| diff --git a/base/test/multiprocess_test.h b/base/test/multiprocess_test.h |
| index a5565cc07f4e737fbee4fdce80bccffade96e212..df35cdd32f2490323c80d53b7693eb600fa491e7 100644 |
| --- a/base/test/multiprocess_test.h |
| +++ b/base/test/multiprocess_test.h |
| @@ -17,6 +17,59 @@ class CommandLine; |
| namespace base { |
| +// Helpers to spawn a child for a multiprocess test and execute a designated |
| +// function. Use these when you already have another base class for your test |
| +// fixture, but you want (some) of your tests to be multiprocess (otherwise you |
| +// may just want to derive your fixture from |MultiProcessTest|, below). |
| +// |
| +// Use these helpers as follows: |
| +// |
| +// TEST_F(MyTest, ATest) { |
| +// CommandLine command_line( |
| +// base::GetMultiProcessTestChildBaseCommandLine()); |
| +// // Maybe add our own switches to |command_line|.... |
| +// |
| +// LaunchOptions options; |
| +// // Maybe set some options (e.g., |start_hidden| on Windows).... |
| +// |
| +// // Start a child process and run |a_test_func|. |
| +// base::ProcessHandle test_child_handle = |
| +// base::SpawnMultiProcessTestChild("a_test_func", command_line, |
| +// options, false); |
| +// |
| +// // Do stuff involving |test_child_handle| and the child process.... |
| +// |
| +// int rv = -1; |
| +// CHECK(base::WaitForExitCodeWithTimeout(test_child_handle, &rv, |
|
Paweł Hajdan Jr.
2014/03/07 02:08:01
Please change this to ASSERT_TRUE.
viettrungluu
2014/03/07 04:42:44
Done, though note that it's debatable whether it s
|
| +// base::TimeDelta::FromSeconds(5))); |
|
Paweł Hajdan Jr.
2014/03/07 02:08:01
This should be using base/test/test_timeouts. Idea
viettrungluu
2014/03/07 04:42:44
Done.
|
| +// base::CloseProcessHandle(test_child_handle); |
| +// EXPECT_EQ(0, rv); |
| +// } |
| +// |
| +// // Note: |MULTIPROCESS_TEST_MAIN()| is defined in |
| +// // testing/multi_process_function_list.h. |
| +// MULTIPROCESS_TEST_MAIN(a_test_func) { |
| +// // Code here runs in a child process.... |
| +// return 0; |
| +// } |
| + |
| +// Spawns a child process and executes the function |procname| declared using |
| +// |MULTIPROCESS_TEST_MAIN()| or |MULTIPROCESS_TEST_MAIN_WITH_SETUP()|. |
| +// |command_line| should be as provided by |
| +// |GetMultiProcessTestChildBaseCommandLine()| (below), possibly with arguments |
| +// added. Note: On Windows, you probably want to set |options.start_hidden|. |
| +ProcessHandle SpawnMultiProcessTestChild( |
| + const std::string& procname, |
| + const CommandLine& command_line, |
| + const LaunchOptions& options, |
| + bool debug_on_start); |
|
Paweł Hajdan Jr.
2014/03/07 02:08:01
Is the debug_on_start parameter useful/needed.
viettrungluu
2014/03/07 04:42:44
I'll investigate and remove it separately if appro
|
| + |
| +// Gets the base command line for |SpawnMultiProcessTestChild()|. To this, you |
| +// may add any flags needed for your child process. |
| +CommandLine GetMultiProcessTestChildBaseCommandLine(); |
| + |
| +// MultiProcessTest ------------------------------------------------------------ |
| + |
| // A MultiProcessTest is a test class which makes it easier to |
| // write a test which requires code running out of process. |
| // |
| @@ -64,6 +117,10 @@ class MultiProcessTest : public PlatformTest { |
| bool debug_on_start); |
| // Set up the command line used to spawn the child process. |
| + // Override this to add things to the command line (calling this first in the |
| + // override). |
| + // TODO(viettrungluu): Remove this and add a virtual |
| + // |ModifyChildCommandLine()|. |
| virtual CommandLine MakeCmdLine(const std::string& procname, |
| bool debug_on_start); |