diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-02 22:01:14 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-02 22:01:14 +0000 |
commit | e84a4ee48635252679b4903a5b08ec6e863dbd63 (patch) | |
tree | 3c5c3fec41608a4905661408c32913371ce8719c | |
parent | 1482a09d841f71aed1cdf0130bfd5180d8a835c0 (diff) | |
download | chromium_src-e84a4ee48635252679b4903a5b08ec6e863dbd63.zip chromium_src-e84a4ee48635252679b4903a5b08ec6e863dbd63.tar.gz chromium_src-e84a4ee48635252679b4903a5b08ec6e863dbd63.tar.bz2 |
Ensure tests check the return of SpawnChild() when they may wait without timeouts
Ensure that the result of SpawnChild() is consistently checked for unittests.
If an child fails to launch, SpawnChild() will return
base::kNullProcessHandle. Waiting on this handle is equivalent to waiting for
any child to terminate - and if there are no children, this may wait
indefinitely, causing the whole test executable to timeout after 10 minutes.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7304008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91430 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/shared_memory_unittest.cc | 1 | ||||
-rw-r--r-- | content/common/process_watcher_unittest.cc | 4 | ||||
-rw-r--r-- | content/common/sandbox_mac_diraccess_unittest.mm | 4 | ||||
-rw-r--r-- | content/common/sandbox_mac_unittest_helper.mm | 4 |
4 files changed, 12 insertions, 1 deletions
diff --git a/base/shared_memory_unittest.cc b/base/shared_memory_unittest.cc index edcbb50..9472101 100644 --- a/base/shared_memory_unittest.cc +++ b/base/shared_memory_unittest.cc @@ -383,6 +383,7 @@ TEST_F(SharedMemoryProcessTest, MAYBE_Tasks) { ProcessHandle handles[kNumTasks]; for (int index = 0; index < kNumTasks; ++index) { handles[index] = SpawnChild("SharedMemoryTestMain", false); + ASSERT_TRUE(handles[index]); } int exit_code = 0; diff --git a/content/common/process_watcher_unittest.cc b/content/common/process_watcher_unittest.cc index 260075b..7b25500 100644 --- a/content/common/process_watcher_unittest.cc +++ b/content/common/process_watcher_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -31,6 +31,7 @@ bool IsProcessDead(base::ProcessHandle child) { TEST_F(ProcessWatcherTest, DelayedTermination) { base::ProcessHandle child_process = SpawnChild("process_watcher_test_never_die", false); + ASSERT_TRUE(child_process); ProcessWatcher::EnsureProcessTerminated(child_process); base::WaitForSingleProcess(child_process, 5000); @@ -49,6 +50,7 @@ MULTIPROCESS_TEST_MAIN(process_watcher_test_never_die) { TEST_F(ProcessWatcherTest, ImmediateTermination) { base::ProcessHandle child_process = SpawnChild("process_watcher_test_die_immediately", false); + ASSERT_TRUE(child_process); // Give it time to die. sleep(2); ProcessWatcher::EnsureProcessTerminated(child_process); diff --git a/content/common/sandbox_mac_diraccess_unittest.mm b/content/common/sandbox_mac_diraccess_unittest.mm index 8aad63b..b728c64 100644 --- a/content/common/sandbox_mac_diraccess_unittest.mm +++ b/content/common/sandbox_mac_diraccess_unittest.mm @@ -35,6 +35,10 @@ class MacDirAccessSandboxTest : public base::MultiProcessTest { setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1); base::ProcessHandle child_process = SpawnChild("mac_sandbox_path_access", false); + if (child_process == base::kNullProcessHandle) { + LOG(WARNING) << "SpawnChild failed"; + return false; + } int code = -1; if (!base::WaitForExitCode(child_process, &code)) { LOG(WARNING) << "base::WaitForExitCode failed"; diff --git a/content/common/sandbox_mac_unittest_helper.mm b/content/common/sandbox_mac_unittest_helper.mm index 564cc8b..3b0345d 100644 --- a/content/common/sandbox_mac_unittest_helper.mm +++ b/content/common/sandbox_mac_unittest_helper.mm @@ -81,6 +81,10 @@ bool MacSandboxTest::RunTestInSandbox(Sandbox::SandboxProcessType sandbox_type, base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner", false); + if (child_process == base::kNullProcessHandle) { + LOG(WARNING) << "SpawnChild failed"; + return false; + } int code = -1; if (!base::WaitForExitCode(child_process, &code)) { LOG(WARNING) << "base::WaitForExitCode failed"; |