diff options
author | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-22 17:28:30 +0000 |
---|---|---|
committer | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-22 17:28:30 +0000 |
commit | 61b93f88f388e26823dfbca2c04630cc3823ecb7 (patch) | |
tree | 0d21dd8447bf22c5b635f35e21ca3dc781041d97 /chrome/test | |
parent | 1733651c19923ce5aaa8918f038ea106ab42c7ec (diff) | |
download | chromium_src-61b93f88f388e26823dfbca2c04630cc3823ecb7.zip chromium_src-61b93f88f388e26823dfbca2c04630cc3823ecb7.tar.gz chromium_src-61b93f88f388e26823dfbca2c04630cc3823ecb7.tar.bz2 |
Cleanup orphaned testserver processes on posix.
If a chrome test that uses a testserver were to crash, the testserver process ends up being orphaned, potentially affecting subsequent tests. This patch causes child processes of a test case to be killed along with the test case if it were to be abruptly terminated.
BUG=55808
TEST=sync_integration_tests
Review URL: http://codereview.chromium.org/3423012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/test_launcher/out_of_proc_test_runner.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/chrome/test/test_launcher/out_of_proc_test_runner.cc b/chrome/test/test_launcher/out_of_proc_test_runner.cc index 47be495..282ae4a 100644 --- a/chrome/test/test_launcher/out_of_proc_test_runner.cc +++ b/chrome/test/test_launcher/out_of_proc_test_runner.cc @@ -89,7 +89,18 @@ class OutOfProcTestRunner : public tests::TestRunner { new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling); base::ProcessHandle process_handle; +#if defined(OS_POSIX) + // On POSIX, we launch the test in a new process group with pgid equal to + // its pid. Any child processes that the test may create will inherit the + // same pgid. This way, if the test is abruptly terminated, we can clean up + // any orphaned child processes it may have left behind. + base::environment_vector no_env; + base::file_handle_mapping_vector no_files; + if (!base::LaunchAppInNewProcessGroup(new_cmd_line.argv(), no_env, no_files, + false, &process_handle)) +#else if (!base::LaunchApp(new_cmd_line, false, false, &process_handle)) +#endif return false; int test_terminate_timeout_ms = kDefaultTestTimeoutMs; @@ -111,6 +122,13 @@ class OutOfProcTestRunner : public tests::TestRunner { // Ensure that the process terminates. base::KillProcess(process_handle, -1, true); + +#if defined(OS_POSIX) + // On POSIX, we need to clean up any child processes that the test might + // have created. On windows, child processes are automatically cleaned up + // using JobObjects. + base::KillProcessGroup(process_handle); +#endif } return exit_code == 0; |