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

Side by Side Diff: chrome/browser/process_info_snapshot_mac_unittest.cc

Issue 999033003: Remove uses of KillProcess() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/process_info_snapshot.h" 5 #include "chrome/browser/process_info_snapshot.h"
6 6
7 #include <sys/types.h> // For |uid_t| (and |pid_t|). 7 #include <sys/types.h> // For |uid_t| (and |pid_t|).
8 #include <unistd.h> // For |getpid()|, |getuid()|, etc. 8 #include <unistd.h> // For |getpid()|, |getuid()|, etc.
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/mac/mac_util.h" 15 #include "base/mac/mac_util.h"
16 #include "base/posix/eintr_wrapper.h" 16 #include "base/posix/eintr_wrapper.h"
17 #include "base/process/kill.h"
18 #include "base/process/launch.h" 17 #include "base/process/launch.h"
19 #include "base/process/process_handle.h" 18 #include "base/process/process.h"
20 #include "base/process/process_metrics.h" 19 #include "base/process/process_metrics.h"
21 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
22 21
23 typedef testing::Test ProcessInfoSnapshotMacTest; 22 typedef testing::Test ProcessInfoSnapshotMacTest;
24 23
25 TEST_F(ProcessInfoSnapshotMacTest, FindPidOneTest) { 24 TEST_F(ProcessInfoSnapshotMacTest, FindPidOneTest) {
26 // Sample process with PID 1, which should exist and presumably belong to 25 // Sample process with PID 1, which should exist and presumably belong to
27 // root. 26 // root.
28 std::vector<base::ProcessId> pid_list; 27 std::vector<base::ProcessId> pid_list;
29 pid_list.push_back(1); 28 pid_list.push_back(1);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ProcessInfoSnapshot snapshot; 135 ProcessInfoSnapshot snapshot;
137 ASSERT_TRUE(snapshot.Sample(pid_list)); 136 ASSERT_TRUE(snapshot.Sample(pid_list));
138 137
139 ProcessInfoSnapshot::ProcInfoEntry proc_info; 138 ProcessInfoSnapshot::ProcInfoEntry proc_info;
140 ASSERT_TRUE(snapshot.GetProcInfo(process.Pid(), &proc_info)); 139 ASSERT_TRUE(snapshot.GetProcInfo(process.Pid(), &proc_info));
141 // Effective user ID should be 0 (root). 140 // Effective user ID should be 0 (root).
142 EXPECT_EQ(proc_info.euid, 0u); 141 EXPECT_EQ(proc_info.euid, 0u);
143 // Real user ID should match the calling process's user id. 142 // Real user ID should match the calling process's user id.
144 EXPECT_EQ(proc_info.uid, geteuid()); 143 EXPECT_EQ(proc_info.uid, geteuid());
145 144
146 ASSERT_TRUE(base::KillProcess(process.Handle(), 0, true)); 145 ASSERT_TRUE(process.Terminate(0, true));
147 PCHECK(IGNORE_EINTR(close(fds[0])) == 0); 146 PCHECK(IGNORE_EINTR(close(fds[0])) == 0);
148 } 147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698