Index: mojo/edk/test/multiprocess_test_helper.cc |
diff --git a/mojo/edk/test/multiprocess_test_helper.cc b/mojo/edk/test/multiprocess_test_helper.cc |
index 4bc550f505e2424f62229ace819c41d4dd4932e8..0803531b522887c7e1130c907ae4de13bc76042d 100644 |
--- a/mojo/edk/test/multiprocess_test_helper.cc |
+++ b/mojo/edk/test/multiprocess_test_helper.cc |
@@ -46,11 +46,13 @@ const char kMojoPrimordialPipeToken[] = "mojo-primordial-pipe-token"; |
const char kMojoNamedPipeName[] = "mojo-named-pipe-name"; |
template <typename Func> |
-int RunClientFunction(Func handler) { |
+int RunClientFunction(Func handler, bool close_pipe_on_exit) { |
CHECK(MultiprocessTestHelper::primordial_pipe.is_valid()); |
ScopedMessagePipeHandle pipe = |
std::move(MultiprocessTestHelper::primordial_pipe); |
- return handler(pipe.get().value()); |
+ MessagePipeHandle pipe_handle = |
+ close_pipe_on_exit ? pipe.get() : pipe.release(); |
+ return handler(pipe_handle.value()); |
} |
} // namespace |
@@ -232,20 +234,25 @@ void MultiprocessTestHelper::ChildSetup() { |
// static |
int MultiprocessTestHelper::RunClientMain( |
- const base::Callback<int(MojoHandle)>& main) { |
- return RunClientFunction([main](MojoHandle handle){ |
- return main.Run(handle); |
- }); |
+ const base::Callback<int(MojoHandle)>& main, |
+ bool close_pipe_on_exit) { |
+ return RunClientFunction( |
+ [main](MojoHandle handle) { return main.Run(handle); }, |
+ close_pipe_on_exit); |
} |
// static |
int MultiprocessTestHelper::RunClientTestMain( |
const base::Callback<void(MojoHandle)>& main) { |
- return RunClientFunction([main](MojoHandle handle) { |
- main.Run(handle); |
- return (::testing::Test::HasFatalFailure() || |
- ::testing::Test::HasNonfatalFailure()) ? 1 : 0; |
- }); |
+ return RunClientFunction( |
+ [main](MojoHandle handle) { |
+ main.Run(handle); |
+ return (::testing::Test::HasFatalFailure() || |
+ ::testing::Test::HasNonfatalFailure()) |
+ ? 1 |
+ : 0; |
+ }, |
+ true /* close_pipe_on_exit */); |
} |
// static |