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

Side by Side Diff: base/process_util_unittest.cc

Issue 555192: Add a utility function to run a process as an arbitrary user... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 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) 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 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/eintr_wrapper.h" 10 #include "base/eintr_wrapper.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 // Let's make sure stderr is ignored. 182 // Let's make sure stderr is ignored.
183 CommandLine other_cmd_line(python_runtime); 183 CommandLine other_cmd_line(python_runtime);
184 other_cmd_line.AppendLooseValue(L"-c"); 184 other_cmd_line.AppendLooseValue(L"-c");
185 other_cmd_line.AppendLooseValue( 185 other_cmd_line.AppendLooseValue(
186 L"\"import sys; sys.stderr.write('Hello!');\""); 186 L"\"import sys; sys.stderr.write('Hello!');\"");
187 output.clear(); 187 output.clear();
188 ASSERT_TRUE(base::GetAppOutput(other_cmd_line, &output)); 188 ASSERT_TRUE(base::GetAppOutput(other_cmd_line, &output));
189 EXPECT_EQ("", output); 189 EXPECT_EQ("", output);
190 } 190 }
191
192 TEST_F(ProcessUtilTest, LaunchAsUser) {
193 base::UserTokenHandle token;
194 ASSERT_TRUE(OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token));
195 std::wstring cmdline =
196 this->MakeCmdLine(L"SimpleChildProcess", false).command_line_string();
197 EXPECT_TRUE(base::LaunchAppAsUser(token, cmdline, false, NULL));
198 }
199
191 #endif // defined(OS_WIN) 200 #endif // defined(OS_WIN)
192 201
193 #if defined(OS_POSIX) 202 #if defined(OS_POSIX)
194 // Returns the maximum number of files that a process can have open. 203 // Returns the maximum number of files that a process can have open.
195 // Returns 0 on error. 204 // Returns 0 on error.
196 int GetMaxFilesOpenInProcess() { 205 int GetMaxFilesOpenInProcess() {
197 struct rlimit rlim; 206 struct rlimit rlim;
198 if (getrlimit(RLIMIT_NOFILE, &rlim) != 0) { 207 if (getrlimit(RLIMIT_NOFILE, &rlim) != 0) {
199 return 0; 208 return 0;
200 } 209 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 TEST_F(OutOfMemoryTest, Posix_memalign) { 474 TEST_F(OutOfMemoryTest, Posix_memalign) {
466 // Grab the return value of posix_memalign to silence a compiler warning 475 // Grab the return value of posix_memalign to silence a compiler warning
467 // about unused return values. We don't actually care about the return 476 // about unused return values. We don't actually care about the return
468 // value, since we're asserting death. 477 // value, since we're asserting death.
469 ASSERT_DEATH(EXPECT_EQ(ENOMEM, posix_memalign(&value_, 8, test_size_)), ""); 478 ASSERT_DEATH(EXPECT_EQ(ENOMEM, posix_memalign(&value_, 8, test_size_)), "");
470 } 479 }
471 480
472 #endif // defined(OS_LINUX) 481 #endif // defined(OS_LINUX)
473 482
474 } // namespace base 483 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util.h ('k') | base/process_util_win.cc » ('j') | base/process_util_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698