ServiceManagement test: reduce test flake.

ExpectProcessIsRunning() goes to a lot of trouble to deal with the flaky
{CTL_KERN, KERN_PROCARGS2} API exposed by ProcessArgumentsForPID(). It
retries that call inside an inner loop until it succeeds, because it may
fail while a process is mid-exec(). Once it succeeds, it should use the
argv it obtained. Waiting for success and then attempting to call
ProcessArgumentsForPID() again to get argv can be flaky when the first
attempt succeeds because it’s pre-exec(), and the second one catches the
process in the middle of the exec() and fails.

The existence of the inner loop was intended to protect against this
problem, and the subsequent call outside of the inner loop appears to be
left behind from before the inner loop existed. It should have been
removed when the inner loop was added.

TEST=util_test ServiceManagement.SubmitRemoveJob
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/644473005
This commit is contained in:
Mark Mentovai 2014-10-09 17:26:50 -04:00
parent c182be95a2
commit 7669b33010

View File

@ -58,7 +58,6 @@ void ExpectProcessIsRunning(pid_t pid, std::string& last_arg) {
} while (inner_tries--);
ASSERT_TRUE(success);
ASSERT_TRUE(ProcessArgumentsForPID(pid, &job_argv));
ASSERT_FALSE(job_argv.empty());
if (job_argv.back() == last_arg) {
break;