posix: Correctly show the expected exit status in multiprocess tests

When reason is mistaken for reason_, things can get unreasonable.

Change-Id: I3deff343fd6836eba3111ba7551174591c2bf5bc
Reviewed-on: https://chromium-review.googlesource.com/354101
Reviewed-by: Robert Sesek <rsesek@chromium.org>
This commit is contained in:
Mark Mentovai 2016-06-20 13:41:40 -04:00
parent 6dbf952678
commit 89835b30f8

View File

@ -98,12 +98,12 @@ void Multiprocess::Run() {
if (WIFEXITED(status)) { if (WIFEXITED(status)) {
reason = kTerminationNormal; reason = kTerminationNormal;
code = WEXITSTATUS(status); code = WEXITSTATUS(status);
message = base::StringPrintf("Child exited with code %d, expected", code); message = base::StringPrintf("Child exited with code %d", code);
} else if (WIFSIGNALED(status)) { } else if (WIFSIGNALED(status)) {
reason = kTerminationSignal; reason = kTerminationSignal;
code = WTERMSIG(status); code = WTERMSIG(status);
message = message =
base::StringPrintf("Child terminated by signal %d (%s)%s, expected", base::StringPrintf("Child terminated by signal %d (%s)%s",
code, code,
strsignal(code), strsignal(code),
WCOREDUMP(status) ? " (core dumped)" : ""); WCOREDUMP(status) ? " (core dumped)" : "");
@ -112,9 +112,11 @@ void Multiprocess::Run() {
} }
if (reason_ == kTerminationNormal) { if (reason_ == kTerminationNormal) {
message += base::StringPrintf(" exit with code %d", code_); message += base::StringPrintf(", expected exit with code %d", code_);
} else if (reason == kTerminationSignal) { } else if (reason_ == kTerminationSignal) {
message += base::StringPrintf(" termination by signal %d", code_); message += base::StringPrintf(", expected termination by signal %d (%s)",
code_,
strsignal(code_));
} }
if (reason != reason_ || code != code_) { if (reason != reason_ || code != code_) {