Commit 6a1eea87 authored by tedvessenes@gmail.com's avatar tedvessenes@gmail.com

Remove old test timeout and process waiting function interfaces.

BUG=108171


Review URL: https://chromiumcodereview.appspot.com/10808069

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148656 0039d316-1c4b-4281-b951-d872f2087c98
parent e5662990
...@@ -506,9 +506,6 @@ BASE_EXPORT bool WaitForExitCode(ProcessHandle handle, int* exit_code); ...@@ -506,9 +506,6 @@ BASE_EXPORT bool WaitForExitCode(ProcessHandle handle, int* exit_code);
// to -1. Returns false on failure (the caller is then responsible for closing // to -1. Returns false on failure (the caller is then responsible for closing
// |handle|). // |handle|).
// The caller is always responsible for closing the |handle|. // The caller is always responsible for closing the |handle|.
BASE_EXPORT bool WaitForExitCodeWithTimeout(ProcessHandle handle,
int* exit_code,
int64 timeout_milliseconds);
BASE_EXPORT bool WaitForExitCodeWithTimeout(ProcessHandle handle, BASE_EXPORT bool WaitForExitCodeWithTimeout(ProcessHandle handle,
int* exit_code, int* exit_code,
base::TimeDelta timeout); base::TimeDelta timeout);
...@@ -517,10 +514,6 @@ BASE_EXPORT bool WaitForExitCodeWithTimeout(ProcessHandle handle, ...@@ -517,10 +514,6 @@ BASE_EXPORT bool WaitForExitCodeWithTimeout(ProcessHandle handle,
// is non-null, then only processes selected by the filter are waited on. // is non-null, then only processes selected by the filter are waited on.
// Returns after all processes have exited or wait_milliseconds have expired. // Returns after all processes have exited or wait_milliseconds have expired.
// Returns true if all the processes exited, false otherwise. // Returns true if all the processes exited, false otherwise.
BASE_EXPORT bool WaitForProcessesToExit(
const FilePath::StringType& executable_name,
int64 wait_milliseconds,
const ProcessFilter* filter);
BASE_EXPORT bool WaitForProcessesToExit( BASE_EXPORT bool WaitForProcessesToExit(
const FilePath::StringType& executable_name, const FilePath::StringType& executable_name,
base::TimeDelta wait, base::TimeDelta wait,
...@@ -529,8 +522,6 @@ BASE_EXPORT bool WaitForProcessesToExit( ...@@ -529,8 +522,6 @@ BASE_EXPORT bool WaitForProcessesToExit(
// Wait for a single process to exit. Return true if it exited cleanly within // Wait for a single process to exit. Return true if it exited cleanly within
// the given time limit. On Linux |handle| must be a child process, however // the given time limit. On Linux |handle| must be a child process, however
// on Mac and Windows it can be any process. // on Mac and Windows it can be any process.
BASE_EXPORT bool WaitForSingleProcess(ProcessHandle handle,
int64 wait_milliseconds);
BASE_EXPORT bool WaitForSingleProcess(ProcessHandle handle, BASE_EXPORT bool WaitForSingleProcess(ProcessHandle handle,
base::TimeDelta wait); base::TimeDelta wait);
......
...@@ -886,9 +886,9 @@ bool WaitForExitCode(ProcessHandle handle, int* exit_code) { ...@@ -886,9 +886,9 @@ bool WaitForExitCode(ProcessHandle handle, int* exit_code) {
} }
bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code, bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
int64 timeout_milliseconds) { base::TimeDelta timeout) {
bool waitpid_success = false; bool waitpid_success = false;
int status = WaitpidWithTimeout(handle, timeout_milliseconds, int status = WaitpidWithTimeout(handle, timeout.InMilliseconds(),
&waitpid_success); &waitpid_success);
if (status == -1) if (status == -1)
return false; return false;
...@@ -905,12 +905,6 @@ bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code, ...@@ -905,12 +905,6 @@ bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
return false; return false;
} }
bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
base::TimeDelta timeout) {
return WaitForExitCodeWithTimeout(
handle, exit_code, timeout.InMilliseconds());
}
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Using kqueue on Mac so that we can wait on non-child processes. // Using kqueue on Mac so that we can wait on non-child processes.
// We can't use kqueues on child processes because we need to reap // We can't use kqueues on child processes because we need to reap
...@@ -1003,11 +997,6 @@ static bool WaitForSingleNonChildProcess(ProcessHandle handle, ...@@ -1003,11 +997,6 @@ static bool WaitForSingleNonChildProcess(ProcessHandle handle,
} }
#endif // OS_MACOSX #endif // OS_MACOSX
bool WaitForSingleProcess(ProcessHandle handle, int64 wait_milliseconds) {
return WaitForSingleProcess(
handle, base::TimeDelta::FromMilliseconds(wait_milliseconds));
}
bool WaitForSingleProcess(ProcessHandle handle, base::TimeDelta wait) { bool WaitForSingleProcess(ProcessHandle handle, base::TimeDelta wait) {
ProcessHandle parent_pid = GetParentProcessId(handle); ProcessHandle parent_pid = GetParentProcessId(handle);
ProcessHandle our_pid = Process::Current().handle(); ProcessHandle our_pid = Process::Current().handle();
...@@ -1217,15 +1206,14 @@ bool GetAppOutputWithExitCode(const CommandLine& cl, ...@@ -1217,15 +1206,14 @@ bool GetAppOutputWithExitCode(const CommandLine& cl,
} }
bool WaitForProcessesToExit(const FilePath::StringType& executable_name, bool WaitForProcessesToExit(const FilePath::StringType& executable_name,
int64 wait_milliseconds, base::TimeDelta wait,
const ProcessFilter* filter) { const ProcessFilter* filter) {
bool result = false; bool result = false;
// TODO(port): This is inefficient, but works if there are multiple procs. // TODO(port): This is inefficient, but works if there are multiple procs.
// TODO(port): use waitpid to avoid leaving zombies around // TODO(port): use waitpid to avoid leaving zombies around
base::Time end_time = base::Time::Now() + base::Time end_time = base::Time::Now() + wait;
base::TimeDelta::FromMilliseconds(wait_milliseconds);
do { do {
NamedProcessIterator iter(executable_name, filter); NamedProcessIterator iter(executable_name, filter);
if (!iter.NextProcessEntry()) { if (!iter.NextProcessEntry()) {
...@@ -1238,12 +1226,6 @@ bool WaitForProcessesToExit(const FilePath::StringType& executable_name, ...@@ -1238,12 +1226,6 @@ bool WaitForProcessesToExit(const FilePath::StringType& executable_name,
return result; return result;
} }
bool WaitForProcessesToExit(const FilePath::StringType& executable_name,
base::TimeDelta wait,
const ProcessFilter* filter) {
return WaitForProcessesToExit(executable_name, wait.InMilliseconds(), filter);
}
bool CleanupProcesses(const FilePath::StringType& executable_name, bool CleanupProcesses(const FilePath::StringType& executable_name,
int64 wait_milliseconds, int64 wait_milliseconds,
int exit_code, int exit_code,
......
...@@ -546,8 +546,8 @@ bool WaitForExitCode(ProcessHandle handle, int* exit_code) { ...@@ -546,8 +546,8 @@ bool WaitForExitCode(ProcessHandle handle, int* exit_code) {
} }
bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code, bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
int64 timeout_milliseconds) { base::TimeDelta timeout) {
if (::WaitForSingleObject(handle, timeout_milliseconds) != WAIT_OBJECT_0) if (::WaitForSingleObject(handle, timeout.InMilliseconds()) != WAIT_OBJECT_0)
return false; return false;
DWORD temp_code; // Don't clobber out-parameters in case of failure. DWORD temp_code; // Don't clobber out-parameters in case of failure.
if (!::GetExitCodeProcess(handle, &temp_code)) if (!::GetExitCodeProcess(handle, &temp_code))
...@@ -557,12 +557,6 @@ bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code, ...@@ -557,12 +557,6 @@ bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
return true; return true;
} }
bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
base::TimeDelta timeout) {
return WaitForExitCodeWithTimeout(
handle, exit_code, timeout.InMilliseconds());
}
ProcessIterator::ProcessIterator(const ProcessFilter* filter) ProcessIterator::ProcessIterator(const ProcessFilter* filter)
: started_iteration_(false), : started_iteration_(false),
filter_(filter) { filter_(filter) {
...@@ -596,7 +590,7 @@ bool NamedProcessIterator::IncludeEntry() { ...@@ -596,7 +590,7 @@ bool NamedProcessIterator::IncludeEntry() {
} }
bool WaitForProcessesToExit(const FilePath::StringType& executable_name, bool WaitForProcessesToExit(const FilePath::StringType& executable_name,
int64 wait_milliseconds, base::TimeDelta wait,
const ProcessFilter* filter) { const ProcessFilter* filter) {
const ProcessEntry* entry; const ProcessEntry* entry;
bool result = true; bool result = true;
...@@ -604,8 +598,8 @@ bool WaitForProcessesToExit(const FilePath::StringType& executable_name, ...@@ -604,8 +598,8 @@ bool WaitForProcessesToExit(const FilePath::StringType& executable_name,
NamedProcessIterator iter(executable_name, filter); NamedProcessIterator iter(executable_name, filter);
while ((entry = iter.NextProcessEntry())) { while ((entry = iter.NextProcessEntry())) {
DWORD remaining_wait = DWORD remaining_wait = std::max<int64>(
std::max<int64>(0, wait_milliseconds - (GetTickCount() - start_time)); 0, wait.InMilliseconds() - (GetTickCount() - start_time));
HANDLE process = OpenProcess(SYNCHRONIZE, HANDLE process = OpenProcess(SYNCHRONIZE,
FALSE, FALSE,
entry->th32ProcessID); entry->th32ProcessID);
...@@ -617,17 +611,6 @@ bool WaitForProcessesToExit(const FilePath::StringType& executable_name, ...@@ -617,17 +611,6 @@ bool WaitForProcessesToExit(const FilePath::StringType& executable_name,
return result; return result;
} }
bool WaitForProcessesToExit(const FilePath::StringType& executable_name,
base::TimeDelta wait,
const ProcessFilter* filter) {
return WaitForProcessesToExit(executable_name, wait.InMilliseconds(), filter);
}
bool WaitForSingleProcess(ProcessHandle handle, int64 wait_milliseconds) {
return WaitForSingleProcess(
handle, base::TimeDelta::FromMilliseconds(wait_milliseconds));
}
bool WaitForSingleProcess(ProcessHandle handle, base::TimeDelta wait) { bool WaitForSingleProcess(ProcessHandle handle, base::TimeDelta wait) {
int exit_code; int exit_code;
if (!WaitForExitCodeWithTimeout(handle, &exit_code, wait)) if (!WaitForExitCodeWithTimeout(handle, &exit_code, wait))
...@@ -639,8 +622,9 @@ bool CleanupProcesses(const FilePath::StringType& executable_name, ...@@ -639,8 +622,9 @@ bool CleanupProcesses(const FilePath::StringType& executable_name,
int64 wait_milliseconds, int64 wait_milliseconds,
int exit_code, int exit_code,
const ProcessFilter* filter) { const ProcessFilter* filter) {
bool exited_cleanly = WaitForProcessesToExit(executable_name, bool exited_cleanly = WaitForProcessesToExit(
wait_milliseconds, executable_name,
base::TimeDelta::FromMilliseconds(wait_milliseconds),
filter); filter);
if (!exited_cleanly) if (!exited_cleanly)
KillProcesses(executable_name, exit_code, filter); KillProcesses(executable_name, exit_code, filter);
......
...@@ -17,33 +17,6 @@ class TestTimeouts { ...@@ -17,33 +17,6 @@ class TestTimeouts {
// by the test suite. // by the test suite.
static void Initialize(); static void Initialize();
// Timeout for actions that are expected to finish "almost instantly".
static int tiny_timeout_ms() {
DCHECK(initialized_);
return tiny_timeout_ms_;
}
// Timeout to wait for something to happen. If you are not sure
// which timeout to use, this is the one you want.
static int action_timeout_ms() {
DCHECK(initialized_);
return action_timeout_ms_;
}
// Timeout longer than the above, but still suitable to use
// multiple times in a single test. Use if the timeout above
// is not sufficient.
static int action_max_timeout_ms() {
DCHECK(initialized_);
return action_max_timeout_ms_;
}
// Timeout for a large test that may take a few minutes to run.
static int large_test_timeout_ms() {
DCHECK(initialized_);
return large_test_timeout_ms_;
}
// Timeout for actions that are expected to finish "almost instantly". // Timeout for actions that are expected to finish "almost instantly".
static base::TimeDelta tiny_timeout() { static base::TimeDelta tiny_timeout() {
DCHECK(initialized_); DCHECK(initialized_);
......
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