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

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

Issue 2613183002: Revert of Multiprocess test client: Android child process launcher rework. (Closed)
Patch Set: Created 3 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/test/main_stub.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/macros.h" 10 #include "base/macros.h"
(...skipping 22 matching lines...) Expand all
33 // // Maybe set some options (e.g., |start_hidden| on Windows).... 33 // // Maybe set some options (e.g., |start_hidden| on Windows)....
34 // 34 //
35 // // Start a child process and run |a_test_func|. 35 // // Start a child process and run |a_test_func|.
36 // base::Process test_child_process = 36 // base::Process test_child_process =
37 // base::SpawnMultiProcessTestChild("a_test_func", command_line, 37 // base::SpawnMultiProcessTestChild("a_test_func", command_line,
38 // options); 38 // options);
39 // 39 //
40 // // Do stuff involving |test_child_process| and the child process.... 40 // // Do stuff involving |test_child_process| and the child process....
41 // 41 //
42 // int rv = -1; 42 // int rv = -1;
43 // ASSERT_TRUE(base::WaitForMultiprocessTestChildExit(test_child_process, 43 // ASSERT_TRUE(test_child_process.WaitForExitWithTimeout(
44 // TestTimeouts::action_timeout(), &rv)); 44 // TestTimeouts::action_timeout(), &rv));
45 // EXPECT_EQ(0, rv); 45 // EXPECT_EQ(0, rv);
46 // } 46 // }
47 // 47 //
48 // // Note: |MULTIPROCESS_TEST_MAIN()| is defined in 48 // // Note: |MULTIPROCESS_TEST_MAIN()| is defined in
49 // // testing/multi_process_function_list.h. 49 // // testing/multi_process_function_list.h.
50 // MULTIPROCESS_TEST_MAIN(a_test_func) { 50 // MULTIPROCESS_TEST_MAIN(a_test_func) {
51 // // Code here runs in a child process.... 51 // // Code here runs in a child process....
52 // return 0; 52 // return 0;
53 // } 53 // }
54 //
55 // If you need to terminate the child process, use the
56 // TerminateMultiProcessTestChild method to ensure that test will work on
57 // Android.
58 54
59 // Spawns a child process and executes the function |procname| declared using 55 // Spawns a child process and executes the function |procname| declared using
60 // |MULTIPROCESS_TEST_MAIN()| or |MULTIPROCESS_TEST_MAIN_WITH_SETUP()|. 56 // |MULTIPROCESS_TEST_MAIN()| or |MULTIPROCESS_TEST_MAIN_WITH_SETUP()|.
61 // |command_line| should be as provided by 57 // |command_line| should be as provided by
62 // |GetMultiProcessTestChildBaseCommandLine()| (below), possibly with arguments 58 // |GetMultiProcessTestChildBaseCommandLine()| (below), possibly with arguments
63 // added. Note: On Windows, you probably want to set |options.start_hidden|. 59 // added. Note: On Windows, you probably want to set |options.start_hidden|.
64 Process SpawnMultiProcessTestChild( 60 Process SpawnMultiProcessTestChild(
65 const std::string& procname, 61 const std::string& procname,
66 const CommandLine& command_line, 62 const CommandLine& command_line,
67 const LaunchOptions& options); 63 const LaunchOptions& options);
68 64
69 // Gets the base command line for |SpawnMultiProcessTestChild()|. To this, you 65 // Gets the base command line for |SpawnMultiProcessTestChild()|. To this, you
70 // may add any flags needed for your child process. 66 // may add any flags needed for your child process.
71 CommandLine GetMultiProcessTestChildBaseCommandLine(); 67 CommandLine GetMultiProcessTestChildBaseCommandLine();
72 68
73 // Waits for the child process to exit. Returns true if the process exited 69 #if defined(OS_ANDROID)
74 // within |timeout| and sets |exit_code| if non null.
75 bool WaitForMultiprocessTestChildExit(const Process& process,
76 TimeDelta timeout,
77 int* exit_code);
78 70
79 // Terminates |process| with |exit_code|. If |wait| is true, this call blocks 71 // Enable the alternate test child implementation which support spawning a child
80 // until the process actually terminates. 72 // after threads have been created. If used, this MUST be the first line of
81 bool TerminateMultiProcessTestChild(const Process& process, 73 // main(). The main function is passed in to avoid a link-time dependency in
82 int exit_code, 74 // component builds.
83 bool wait); 75 void InitAndroidMultiProcessTestHelper(int (*main)(int, char**));
76
77 // Returns true if the current process is a test child.
78 bool AndroidIsChildProcess();
79
80 // Wait for a test child to exit if the alternate test child implementation is
81 // being used.
82 bool AndroidWaitForChildExitWithTimeout(
83 const Process& process, TimeDelta timeout, int* exit_code)
84 WARN_UNUSED_RESULT;
85
86 #endif // defined(OS_ANDROID)
84 87
85 // MultiProcessTest ------------------------------------------------------------ 88 // MultiProcessTest ------------------------------------------------------------
86 89
87 // A MultiProcessTest is a test class which makes it easier to 90 // A MultiProcessTest is a test class which makes it easier to
88 // write a test which requires code running out of process. 91 // write a test which requires code running out of process.
89 // 92 //
90 // To create a multiprocess test simply follow these steps: 93 // To create a multiprocess test simply follow these steps:
91 // 94 //
92 // 1) Derive your test from MultiProcessTest. Example: 95 // 1) Derive your test from MultiProcessTest. Example:
93 // 96 //
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // |ModifyChildCommandLine()|; make the two divergent uses more sane. 141 // |ModifyChildCommandLine()|; make the two divergent uses more sane.
139 virtual CommandLine MakeCmdLine(const std::string& procname); 142 virtual CommandLine MakeCmdLine(const std::string& procname);
140 143
141 private: 144 private:
142 DISALLOW_COPY_AND_ASSIGN(MultiProcessTest); 145 DISALLOW_COPY_AND_ASSIGN(MultiProcessTest);
143 }; 146 };
144 147
145 } // namespace base 148 } // namespace base
146 149
147 #endif // BASE_TEST_MULTIPROCESS_TEST_H_ 150 #endif // BASE_TEST_MULTIPROCESS_TEST_H_
OLDNEW
« no previous file with comments | « base/test/main_stub.cc ('k') | base/test/multiprocess_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698