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

Unified Diff: util/test/multiprocess.cc

Issue 553153002: Add Multiprocess::SetExpectedChildTermination() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: 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
Index: util/test/multiprocess.cc
diff --git a/util/test/multiprocess.cc b/util/test/multiprocess.cc
index 34cbddc4de633a3c9c33665c3691447f3a0a7501..4c0ce3a0c55b58ec530e19bdaf15b4cdb3c546bb 100644
--- a/util/test/multiprocess.cc
+++ b/util/test/multiprocess.cc
@@ -52,7 +52,10 @@ struct MultiprocessInfo {
} // namespace internal
-Multiprocess::Multiprocess() : info_(NULL) {
+Multiprocess::Multiprocess()
+ : info_(NULL),
+ code_(EXIT_SUCCESS),
+ reason_(kTerminationNormal) {
}
void Multiprocess::Run() {
@@ -89,24 +92,46 @@ void Multiprocess::Run() {
int status;
pid_t wait_pid = waitpid(pid, &status, 0);
ASSERT_EQ(pid, wait_pid) << ErrnoMessage("waitpid");
- if (status != 0) {
- std::string message;
- if (WIFEXITED(status)) {
- message = base::StringPrintf("Child exited with code %d",
- WEXITSTATUS(status));
- } else if (WIFSIGNALED(status)) {
- message = base::StringPrintf("Child terminated by signal %d (%s) %s",
- WTERMSIG(status),
- strsignal(WTERMSIG(status)),
- WCOREDUMP(status) ? " (core dumped)" : "");
- }
- ASSERT_EQ(0, status) << message;
+
+ TerminationReason reason;
+ int code;
+ std::string message;
+ if (WIFEXITED(status)) {
+ reason = kTerminationNormal;
+ code = WEXITSTATUS(status);
+ message = base::StringPrintf("Child exited with code %d, expected", code);
+ } else if (WIFSIGNALED(status)) {
+ reason = kTerminationSignal;
+ code = WTERMSIG(status);
+ message =
+ base::StringPrintf("Child terminated by signal %d (%s)%s, expected",
+ code,
+ strsignal(code),
+ WCOREDUMP(status) ? " (core dumped)" : "");
+ } else {
+ FAIL() << "Unknown termination reason";
+ }
+
+ if (reason_ == kTerminationNormal) {
+ message += base::StringPrintf("exit with code %d", code_);
+ } else if (reason == kTerminationSignal) {
+ message += base::StringPrintf("termination by signal %d", code_);
+ }
+
+ if (reason != reason_ || code != code_) {
+ ADD_FAILURE() << message;
}
} else {
RunChild();
}
}
+void Multiprocess::SetExpectedChildTermination(TerminationReason reason,
+ int code) {
+ reason_ = reason;
+ code_ = code;
+}
+
Multiprocess::~Multiprocess() {
}

Powered by Google App Engine
This is Rietveld 408576698