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

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

Issue 9429039: Cleanup: Remove base::environment_vector and base::file_handle_mapping_vector to StudlyCaps. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 EXPECT_GT(proc_info.vsize, 0u); // Its |vsize| should be nonzero though. 92 EXPECT_GT(proc_info.vsize, 0u); // Its |vsize| should be nonzero though.
93 } 93 }
94 94
95 // To verify that ProcessInfoSnapshot is getting the actual uid and effective 95 // To verify that ProcessInfoSnapshot is getting the actual uid and effective
96 // uid, this test runs top. top should have a uid of the caller and effective 96 // uid, this test runs top. top should have a uid of the caller and effective
97 // uid of 0 (root). 97 // uid of 0 (root).
98 TEST_F(ProcessInfoSnapshotMacTest, EffectiveVsRealUserIDTest) { 98 TEST_F(ProcessInfoSnapshotMacTest, EffectiveVsRealUserIDTest) {
99 // Create a pipe to be able to read top's output. 99 // Create a pipe to be able to read top's output.
100 int fds[2]; 100 int fds[2];
101 PCHECK(pipe(fds) == 0); 101 PCHECK(pipe(fds) == 0);
102 base::file_handle_mapping_vector fds_to_remap; 102 base::FileHandleMappingVector fds_to_remap;
103 fds_to_remap.push_back(std::make_pair(fds[1], 1)); 103 fds_to_remap.push_back(std::make_pair(fds[1], 1));
104 104
105 // Hook up top's stderr to the test process' stderr. 105 // Hook up top's stderr to the test process' stderr.
106 fds_to_remap.push_back(std::make_pair(fileno(stderr), 2)); 106 fds_to_remap.push_back(std::make_pair(fileno(stderr), 2));
107 107
108 std::vector<std::string> argv; 108 std::vector<std::string> argv;
109 argv.push_back("/usr/bin/top"); 109 argv.push_back("/usr/bin/top");
110 argv.push_back("-l"); 110 argv.push_back("-l");
111 argv.push_back("0"); 111 argv.push_back("0");
112 112
(...skipping 16 matching lines...) Expand all
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698