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