Commit 37bc1c78 authored by erikchen's avatar erikchen Committed by Commit bot

mac: Fix TestGTMSMJobSubmitRemove on Yosemite.

On OSX 10.10, using launch_msg() to remove a job does not guarantee that the
task is synchronously killed. The unit test needs to wait for the task to be
killed before proceeding.

BUG=390276

Review URL: https://codereview.chromium.org/664863003

Cr-Commit-Position: refs/heads/master@{#314181}
parent 97aff32a
......@@ -7,6 +7,8 @@
#include "base/mac/foundation_util.h"
#include "base/mac/launchd.h"
#include "base/mac/scoped_nsobject.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/google_toolbox_for_mac/src/Foundation/GTMServiceManagement.h"
......@@ -58,7 +60,20 @@ TEST(ServiceProcessControlMac, TestGTMSMJobSubmitRemove) {
// Remove the job.
ASSERT_TRUE(GTMSMJobRemove(label_cf, &error));
pid = base::mac::PIDForJob(label);
// Wait for the job to be killed.
base::TimeDelta timeout_in_ms = TestTimeouts::action_timeout();
base::Time start_time = base::Time::Now();
while (1) {
pid = base::mac::PIDForJob(label);
if (pid < 0)
break;
base::Time current_time = base::Time::Now();
if (current_time - start_time > timeout_in_ms)
break;
}
EXPECT_LT(pid, 0);
// Attempting to remove the job again should fail.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment