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

Unified Diff: util/test/multiprocess.cc

Issue 586053002: MachMultiprocess test: the child process must wait for the parent to finish (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Handle it in the base class Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/test/multiprocess.h ('k') | util/test/multiprocess_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/test/multiprocess.cc
diff --git a/util/test/multiprocess.cc b/util/test/multiprocess.cc
index 4c0ce3a0c55b58ec530e19bdaf15b4cdb3c546bb..24c2e44f238ad8ca1920f0a5820e3b0dd4157434 100644
--- a/util/test/multiprocess.cc
+++ b/util/test/multiprocess.cc
@@ -22,6 +22,7 @@
#include "base/auto_reset.h"
#include "base/files/scoped_file.h"
+#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
@@ -113,9 +114,9 @@ void Multiprocess::Run() {
}
if (reason_ == kTerminationNormal) {
- message += base::StringPrintf("exit with code %d", code_);
+ message += base::StringPrintf(" exit with code %d", code_);
} else if (reason == kTerminationSignal) {
- message += base::StringPrintf("termination by signal %d", code_);
+ message += base::StringPrintf(" termination by signal %d", code_);
}
if (reason != reason_ || code != code_) {
@@ -159,17 +160,33 @@ pid_t Multiprocess::ChildPID() const {
int Multiprocess::ReadPipeFD() const {
int fd = info_->child_pid ? info_->pipe_c2p_read.get()
: info_->pipe_p2c_read.get();
- EXPECT_NE(-1, fd);
+ CHECK_NE(fd, -1);
return fd;
}
int Multiprocess::WritePipeFD() const {
int fd = info_->child_pid ? info_->pipe_p2c_write.get()
: info_->pipe_c2p_write.get();
- EXPECT_NE(-1, fd);
+ CHECK_NE(fd, -1);
return fd;
}
+void Multiprocess::CloseReadPipe() {
+ if (info_->child_pid) {
+ info_->pipe_c2p_read.reset();
+ } else {
+ info_->pipe_p2c_read.reset();
+ }
+}
+
+void Multiprocess::CloseWritePipe() {
+ if (info_->child_pid) {
+ info_->pipe_p2c_write.reset();
+ } else {
+ info_->pipe_c2p_write.reset();
+ }
+}
+
void Multiprocess::RunParent() {
// The parent uses the read end of c2p and the write end of p2c.
info_->pipe_c2p_write.reset();
« no previous file with comments | « util/test/multiprocess.h ('k') | util/test/multiprocess_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698