OLD | NEW |
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/posix/eintr_wrapper.h" | 15 #include "base/posix/eintr_wrapper.h" |
16 #include "base/process_util.h" | 16 #include "base/process/kill.h" |
17 | 17 #include "base/process/launch.h" |
| 18 #include "base/process/process_handle.h" |
| 19 #include "base/process/process_metrics.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
19 | 21 |
20 typedef testing::Test ProcessInfoSnapshotMacTest; | 22 typedef testing::Test ProcessInfoSnapshotMacTest; |
21 | 23 |
22 TEST_F(ProcessInfoSnapshotMacTest, FindPidOneTest) { | 24 TEST_F(ProcessInfoSnapshotMacTest, FindPidOneTest) { |
23 // 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 |
24 // root. | 26 // root. |
25 std::vector<base::ProcessId> pid_list; | 27 std::vector<base::ProcessId> pid_list; |
26 pid_list.push_back(1); | 28 pid_list.push_back(1); |
27 ProcessInfoSnapshot snapshot; | 29 ProcessInfoSnapshot snapshot; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 ProcessInfoSnapshot::ProcInfoEntry proc_info; | 131 ProcessInfoSnapshot::ProcInfoEntry proc_info; |
130 ASSERT_TRUE(snapshot.GetProcInfo(process_handle, &proc_info)); | 132 ASSERT_TRUE(snapshot.GetProcInfo(process_handle, &proc_info)); |
131 // Effective user ID should be 0 (root). | 133 // Effective user ID should be 0 (root). |
132 EXPECT_EQ(proc_info.euid, 0u); | 134 EXPECT_EQ(proc_info.euid, 0u); |
133 // Real user ID should match the calling process's user id. | 135 // Real user ID should match the calling process's user id. |
134 EXPECT_EQ(proc_info.uid, geteuid()); | 136 EXPECT_EQ(proc_info.uid, geteuid()); |
135 | 137 |
136 ASSERT_TRUE(base::KillProcess(process_handle, 0, true)); | 138 ASSERT_TRUE(base::KillProcess(process_handle, 0, true)); |
137 PCHECK(HANDLE_EINTR(close(fds[0])) == 0); | 139 PCHECK(HANDLE_EINTR(close(fds[0])) == 0); |
138 } | 140 } |
OLD | NEW |