summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-06 12:18:20 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-06 12:18:20 +0000
commit40bbe59d2dd822e8448047f25c0349bb5c44d938 (patch)
tree618f1bf2b7c464f70e908248fbbe799133f3a1c0 /base
parente2fefe23d79a1de960d8903d9bb8520e6d1e1bd6 (diff)
downloadchromium_src-40bbe59d2dd822e8448047f25c0349bb5c44d938.zip
chromium_src-40bbe59d2dd822e8448047f25c0349bb5c44d938.tar.gz
chromium_src-40bbe59d2dd822e8448047f25c0349bb5c44d938.tar.bz2
GTTF: Detect browser crashes on shutdown in UI tests.
Previously the automation framework could miss a browser crash during shutdown on POSIX (on Windows there is crash_service.exe that should catch all crashes). This change makes the automation framework avoid losing information about the browser process' exit status (CrashAwareSleep), and fixes a bug in base::WaitForExitCodeWithTimeout (which on POSIX never reported the process has been signaled). Finally, it makes the automation framework use WaitForExitCodeWithTimeout instead of WaitForSingleProcess. This way we can get the exit status information in an accurate and cross-platform way. To avoid trying to close the same process handle twice (it's only an issue on Windows) I've changed WaitForExitCodeWithTimeout not to close the passed handle. It's only used in few places and I think this CL fixes all of them. I've tested this change locally on Mac with a UI test that SIGKILLs the browser. Before this change the test passed (it shouldn't), and after this change the test failed with an information that the browser has not exited cleanly. BUG=56644 Review URL: http://codereview.chromium.org/6689014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80608 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/process_util.h7
-rw-r--r--base/process_util_posix.cc22
-rw-r--r--base/process_util_win.cc12
3 files changed, 8 insertions, 33 deletions
diff --git a/base/process_util.h b/base/process_util.h
index b3d311e..bdf9b9e 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -373,10 +373,11 @@ BASE_API TerminationStatus GetTerminationStatus(ProcessHandle handle,
BASE_API bool WaitForExitCode(ProcessHandle handle, int* exit_code);
// Waits for process to exit. If it did exit within |timeout_milliseconds|,
-// then puts the exit code in |exit_code|, closes |handle|, and returns true.
+// then puts the exit code in |exit_code|, and returns true.
// In POSIX systems, if the process has been signaled then |exit_code| is set
// to -1. Returns false on failure (the caller is then responsible for closing
// |handle|).
+// The caller is always responsible for closing the |handle|.
BASE_API bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
int64 timeout_milliseconds);
@@ -395,10 +396,6 @@ BASE_API bool WaitForProcessesToExit(
BASE_API bool WaitForSingleProcess(ProcessHandle handle,
int64 wait_milliseconds);
-// Returns true when |wait_milliseconds| have elapsed and the process
-// is still running.
-BASE_API bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds);
-
// Waits a certain amount of time (can be 0) for all the processes with a given
// executable name to exit, then kills off any of them that are still around.
// If filter is non-null, then only processes selected by the filter are waited
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index 6c7a9f6..26301d2 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -724,14 +724,15 @@ bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
return false;
if (!waitpid_success)
return false;
- if (!WIFEXITED(status))
- return false;
if (WIFSIGNALED(status)) {
*exit_code = -1;
return true;
}
- *exit_code = WEXITSTATUS(status);
- return true;
+ if (WIFEXITED(status)) {
+ *exit_code = WEXITSTATUS(status);
+ return true;
+ }
+ return false;
}
#if defined(OS_MACOSX)
@@ -821,19 +822,6 @@ bool WaitForSingleProcess(ProcessHandle handle, int64 wait_milliseconds) {
}
}
-bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds) {
- bool waitpid_success;
- int status = WaitpidWithTimeout(handle, wait_milliseconds, &waitpid_success);
- if (status != -1) {
- DCHECK(waitpid_success);
- return !(WIFEXITED(status) || WIFSIGNALED(status));
- } else {
- // If waitpid returned with an error, then the process doesn't exist
- // (which most probably means it didn't exist before our call).
- return waitpid_success;
- }
-}
-
int64 TimeValToMicroseconds(const struct timeval& tv) {
static const int kMicrosecondsPerSecond = 1000000;
int64 ret = tv.tv_sec; // Avoid (int * int) integer overflow.
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 895ec3b..8ade06e 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -464,8 +464,7 @@ TerminationStatus GetTerminationStatus(ProcessHandle handle, int* exit_code) {
bool WaitForExitCode(ProcessHandle handle, int* exit_code) {
bool success = WaitForExitCodeWithTimeout(handle, exit_code, INFINITE);
- if (!success)
- CloseProcessHandle(handle);
+ CloseProcessHandle(handle);
return success;
}
@@ -477,10 +476,6 @@ bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
if (!::GetExitCodeProcess(handle, &temp_code))
return false;
- // Only close the handle on success, to give the caller a chance to forcefully
- // terminate the process if he wants to.
- CloseProcessHandle(handle);
-
*exit_code = temp_code;
return true;
}
@@ -544,11 +539,6 @@ bool WaitForSingleProcess(ProcessHandle handle, int64 wait_milliseconds) {
return retval;
}
-bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds) {
- bool retval = WaitForSingleObject(handle, wait_milliseconds) == WAIT_TIMEOUT;
- return retval;
-}
-
bool CleanupProcesses(const std::wstring& executable_name,
int64 wait_milliseconds,
int exit_code,