OLD | NEW |
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/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> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 ProcessInfoSnapshot::ProcInfoEntry proc_info; | 70 ProcessInfoSnapshot::ProcInfoEntry proc_info; |
71 ASSERT_TRUE(snapshot.GetProcInfo(pid, &proc_info)); | 71 ASSERT_TRUE(snapshot.GetProcInfo(pid, &proc_info)); |
72 EXPECT_EQ(pid, proc_info.pid); | 72 EXPECT_EQ(pid, proc_info.pid); |
73 EXPECT_EQ(ppid, proc_info.ppid); | 73 EXPECT_EQ(ppid, proc_info.ppid); |
74 EXPECT_EQ(uid, proc_info.uid); | 74 EXPECT_EQ(uid, proc_info.uid); |
75 EXPECT_EQ(euid, proc_info.euid); | 75 EXPECT_EQ(euid, proc_info.euid); |
76 EXPECT_GE(proc_info.rss, 100u); // Sanity check: we're running, so we | 76 EXPECT_GE(proc_info.rss, 100u); // Sanity check: we're running, so we |
77 // should occupy at least 100 kilobytes. | 77 // should occupy at least 100 kilobytes. |
78 EXPECT_GE(proc_info.vsize, 1024u); // Sanity check: our |vsize| is presumably | 78 EXPECT_GE(proc_info.vsize, 1024u); // Sanity check: our |vsize| is presumably |
79 // at least a megabyte. | 79 // at least a megabyte. |
| 80 EXPECT_GE(proc_info.rshrd, 1024u); // Shared memory should also > 1 MB. |
| 81 EXPECT_GE(proc_info.rprvt, 1024u); // Same with private memory. |
80 | 82 |
81 // Find our parent. | 83 // Find our parent. |
82 ASSERT_TRUE(snapshot.GetProcInfo(ppid, &proc_info)); | 84 ASSERT_TRUE(snapshot.GetProcInfo(ppid, &proc_info)); |
83 EXPECT_EQ(ppid, proc_info.pid); | 85 EXPECT_EQ(ppid, proc_info.pid); |
84 EXPECT_NE(static_cast<int64>(proc_info.ppid), 0); | 86 EXPECT_NE(static_cast<int64>(proc_info.ppid), 0); |
85 EXPECT_EQ(uid, proc_info.uid); // This (and the following) should be true | 87 EXPECT_EQ(uid, proc_info.uid); // This (and the following) should be true |
86 EXPECT_EQ(euid, proc_info.euid); // under reasonable circumstances. | 88 EXPECT_EQ(euid, proc_info.euid); // under reasonable circumstances. |
87 // Can't say anything definite about its |rss|. | 89 // Can't say anything definite about its |rss|. |
88 EXPECT_GT(proc_info.vsize, 0u); // Its |vsize| should be nonzero though. | 90 EXPECT_GT(proc_info.vsize, 0u); // Its |vsize| should be nonzero though. |
89 } | 91 } |
(...skipping 11 matching lines...) Expand all Loading... |
101 | 103 |
102 ProcessInfoSnapshot::ProcInfoEntry proc_info; | 104 ProcessInfoSnapshot::ProcInfoEntry proc_info; |
103 ASSERT_TRUE(snapshot.GetProcInfo(process_handle, &proc_info)); | 105 ASSERT_TRUE(snapshot.GetProcInfo(process_handle, &proc_info)); |
104 // Effective user ID should be 0 (root). | 106 // Effective user ID should be 0 (root). |
105 EXPECT_EQ(proc_info.euid, 0u); | 107 EXPECT_EQ(proc_info.euid, 0u); |
106 // Real user ID should match the calling process's user id. | 108 // Real user ID should match the calling process's user id. |
107 EXPECT_EQ(proc_info.uid, geteuid()); | 109 EXPECT_EQ(proc_info.uid, geteuid()); |
108 | 110 |
109 ASSERT_TRUE(base::KillProcess(process_handle, 0, true)); | 111 ASSERT_TRUE(base::KillProcess(process_handle, 0, true)); |
110 } | 112 } |
OLD | NEW |