Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: base/test/multiprocess_test.h

Issue 843113003: MultiProcessTest: Update SpawnChild* to return a Process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/process/process_util_unittest.cc ('k') | base/test/multiprocess_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 BASE_TEST_MULTIPROCESS_TEST_H_ 5 #ifndef BASE_TEST_MULTIPROCESS_TEST_H_
6 #define BASE_TEST_MULTIPROCESS_TEST_H_ 6 #define BASE_TEST_MULTIPROCESS_TEST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/process/launch.h" 11 #include "base/process/launch.h"
12 #include "base/process/process_handle.h" 12 #include "base/process/process.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "testing/platform_test.h" 14 #include "testing/platform_test.h"
15 15
16 namespace base { 16 namespace base {
17 17
18 class CommandLine; 18 class CommandLine;
19 19
20 // Helpers to spawn a child for a multiprocess test and execute a designated 20 // Helpers to spawn a child for a multiprocess test and execute a designated
21 // function. Use these when you already have another base class for your test 21 // function. Use these when you already have another base class for your test
22 // fixture, but you want (some) of your tests to be multiprocess (otherwise you 22 // fixture, but you want (some) of your tests to be multiprocess (otherwise you
(...skipping 28 matching lines...) Expand all
51 // MULTIPROCESS_TEST_MAIN(a_test_func) { 51 // MULTIPROCESS_TEST_MAIN(a_test_func) {
52 // // Code here runs in a child process.... 52 // // Code here runs in a child process....
53 // return 0; 53 // return 0;
54 // } 54 // }
55 55
56 // Spawns a child process and executes the function |procname| declared using 56 // Spawns a child process and executes the function |procname| declared using
57 // |MULTIPROCESS_TEST_MAIN()| or |MULTIPROCESS_TEST_MAIN_WITH_SETUP()|. 57 // |MULTIPROCESS_TEST_MAIN()| or |MULTIPROCESS_TEST_MAIN_WITH_SETUP()|.
58 // |command_line| should be as provided by 58 // |command_line| should be as provided by
59 // |GetMultiProcessTestChildBaseCommandLine()| (below), possibly with arguments 59 // |GetMultiProcessTestChildBaseCommandLine()| (below), possibly with arguments
60 // added. Note: On Windows, you probably want to set |options.start_hidden|. 60 // added. Note: On Windows, you probably want to set |options.start_hidden|.
61 ProcessHandle SpawnMultiProcessTestChild( 61 Process SpawnMultiProcessTestChild(
62 const std::string& procname, 62 const std::string& procname,
63 const CommandLine& command_line, 63 const CommandLine& command_line,
64 const LaunchOptions& options); 64 const LaunchOptions& options);
65 65
66 // Gets the base command line for |SpawnMultiProcessTestChild()|. To this, you 66 // Gets the base command line for |SpawnMultiProcessTestChild()|. To this, you
67 // may add any flags needed for your child process. 67 // may add any flags needed for your child process.
68 CommandLine GetMultiProcessTestChildBaseCommandLine(); 68 CommandLine GetMultiProcessTestChildBaseCommandLine();
69 69
70 // MultiProcessTest ------------------------------------------------------------ 70 // MultiProcessTest ------------------------------------------------------------
71 71
(...skipping 26 matching lines...) Expand all
98 // Run a child process. 98 // Run a child process.
99 // 'procname' is the name of a function which the child will 99 // 'procname' is the name of a function which the child will
100 // execute. It must be exported from this library in order to 100 // execute. It must be exported from this library in order to
101 // run. 101 // run.
102 // 102 //
103 // Example signature: 103 // Example signature:
104 // extern "C" int __declspec(dllexport) FooBar() { 104 // extern "C" int __declspec(dllexport) FooBar() {
105 // // do client work here 105 // // do client work here
106 // } 106 // }
107 // 107 //
108 // Returns the handle to the child, or NULL on failure 108 // Returns the child process.
109 ProcessHandle SpawnChild(const std::string& procname); 109 Process SpawnChild(const std::string& procname);
110 110
111 // Run a child process using the given launch options. 111 // Run a child process using the given launch options.
112 // 112 //
113 // Note: On Windows, you probably want to set |options.start_hidden|. 113 // Note: On Windows, you probably want to set |options.start_hidden|.
114 ProcessHandle SpawnChildWithOptions(const std::string& procname, 114 Process SpawnChildWithOptions(const std::string& procname,
115 const LaunchOptions& options); 115 const LaunchOptions& options);
116 116
117 // Set up the command line used to spawn the child process. 117 // Set up the command line used to spawn the child process.
118 // Override this to add things to the command line (calling this first in the 118 // Override this to add things to the command line (calling this first in the
119 // override). 119 // override).
120 // Note that currently some tests rely on this providing a full command line, 120 // Note that currently some tests rely on this providing a full command line,
121 // which they then use directly with |LaunchProcess()|. 121 // which they then use directly with |LaunchProcess()|.
122 // TODO(viettrungluu): Remove this and add a virtual 122 // TODO(viettrungluu): Remove this and add a virtual
123 // |ModifyChildCommandLine()|; make the two divergent uses more sane. 123 // |ModifyChildCommandLine()|; make the two divergent uses more sane.
124 virtual CommandLine MakeCmdLine(const std::string& procname); 124 virtual CommandLine MakeCmdLine(const std::string& procname);
125 125
126 private: 126 private:
127 DISALLOW_COPY_AND_ASSIGN(MultiProcessTest); 127 DISALLOW_COPY_AND_ASSIGN(MultiProcessTest);
128 }; 128 };
129 129
130 } // namespace base 130 } // namespace base
131 131
132 #endif // BASE_TEST_MULTIPROCESS_TEST_H_ 132 #endif // BASE_TEST_MULTIPROCESS_TEST_H_
OLDNEW
« no previous file with comments | « base/process/process_util_unittest.cc ('k') | base/test/multiprocess_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698