Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: chrome/common/process_watcher_unittest.cc

Issue 542042: Mac: ensure child processes are properly reaped -- eliminate Helper zombies. (Closed)
Patch Set: Added test. Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/process_watcher_mac.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/process_watcher.h" 5 #include "chrome/common/process_watcher.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #include <sys/wait.h> 8 #include <sys/wait.h>
9 9
10 #include "base/eintr_wrapper.h" 10 #include "base/eintr_wrapper.h"
(...skipping 21 matching lines...) Expand all
32 SpawnChild(L"process_watcher_test_never_die"); 32 SpawnChild(L"process_watcher_test_never_die");
33 ProcessWatcher::EnsureProcessTerminated(child_process); 33 ProcessWatcher::EnsureProcessTerminated(child_process);
34 base::WaitForSingleProcess(child_process, 5000); 34 base::WaitForSingleProcess(child_process, 5000);
35 35
36 // Check that process was really killed. 36 // Check that process was really killed.
37 EXPECT_TRUE(IsProcessDead(child_process)); 37 EXPECT_TRUE(IsProcessDead(child_process));
38 base::CloseProcessHandle(child_process); 38 base::CloseProcessHandle(child_process);
39 } 39 }
40 40
41 MULTIPROCESS_TEST_MAIN(process_watcher_test_never_die) { 41 MULTIPROCESS_TEST_MAIN(process_watcher_test_never_die) {
42 while(1){ 42 while (1) {
43 sleep(500); 43 sleep(500);
44 } 44 }
45 return 0; 45 return 0;
46 } 46 }
47 47
48 TEST_F(ProcessWatcherTest, ImmediateTermination) {
49 base::ProcessHandle child_process =
50 SpawnChild(L"process_watcher_test_die_immediately");
51 // Give it time to die.
52 sleep(2);
53 ProcessWatcher::EnsureProcessTerminated(child_process);
54
55 // Check that process was really killed.
56 EXPECT_TRUE(IsProcessDead(child_process));
57 base::CloseProcessHandle(child_process);
58 }
59
60 MULTIPROCESS_TEST_MAIN(process_watcher_test_die_immediately) {
61 return 0;
62 }
63
48 #endif // OS_POSIX 64 #endif // OS_POSIX
OLDNEW
« no previous file with comments | « chrome/common/process_watcher_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698