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

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

Issue 496007: Make ProcessWatcher use kqueues on Mac. (Closed)
Patch Set: No need for a thread Created 11 years 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_posix.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/common/process_watcher.h"
6
7 #if defined(OS_POSIX)
8 #include <sys/wait.h>
9
10 #include "base/eintr_wrapper.h"
11 #include "base/multiprocess_test.h"
12 #include "base/process_util.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 class ProcessWatcherTest : public MultiProcessTest {
16 };
17
18 namespace {
19
20 bool IsProcessDead(base::ProcessHandle child) {
21 // waitpid() will actually reap the process which is exactly NOT what we
22 // want to test for. The good thing is that if it can't find the process
23 // we'll get a nice value for errno which we can test for.
24 const pid_t result = HANDLE_EINTR(waitpid(child, NULL, WNOHANG));
25 return result == -1 && errno == ECHILD;
26 }
27
28 } // namespace
29
30 TEST_F(ProcessWatcherTest, DelayedTermination) {
31 base::ProcessHandle child_process =
32 SpawnChild(L"process_watcher_test_never_die");
33 ProcessWatcher::EnsureProcessTerminated(child_process);
34 base::WaitForSingleProcess(child_process, 5000);
35
36 // Check that process was really killed.
37 EXPECT_TRUE(IsProcessDead(child_process));
38 base::CloseProcessHandle(child_process);
39 }
40
41 MULTIPROCESS_TEST_MAIN(process_watcher_test_never_die) {
42 while(1){
43 sleep(500);
44 }
45 return 0;
46 }
47
48 #endif // OS_POSIX
OLDNEW
« no previous file with comments | « chrome/common/process_watcher_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698