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

Side by Side Diff: content/common/sandbox_mac_diraccess_unittest.mm

Issue 843113003: MultiProcessTest: Update SpawnChild* to return a Process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #include <dirent.h> 6 #include <dirent.h>
7 7
8 extern "C" { 8 extern "C" {
9 #include <sandbox.h> 9 #include <sandbox.h>
10 } 10 }
(...skipping 16 matching lines...) Expand all
27 } // namespace 27 } // namespace
28 28
29 // Tests need to be in the same namespace as the Sandbox class to be useable 29 // Tests need to be in the same namespace as the Sandbox class to be useable
30 // with FRIEND_TEST() declaration. 30 // with FRIEND_TEST() declaration.
31 namespace content { 31 namespace content {
32 32
33 class MacDirAccessSandboxTest : public base::MultiProcessTest { 33 class MacDirAccessSandboxTest : public base::MultiProcessTest {
34 public: 34 public:
35 bool CheckSandbox(const std::string& directory_to_try) { 35 bool CheckSandbox(const std::string& directory_to_try) {
36 setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1); 36 setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1);
37 base::ProcessHandle child_process = SpawnChild("mac_sandbox_path_access"); 37 base::Process child_process = SpawnChild("mac_sandbox_path_access");
38 if (child_process == base::kNullProcessHandle) { 38 if (!child_process.IsValid()) {
39 LOG(WARNING) << "SpawnChild failed"; 39 LOG(WARNING) << "SpawnChild failed";
40 return false; 40 return false;
41 } 41 }
42 int code = -1; 42 int code = -1;
43 if (!base::WaitForExitCode(child_process, &code)) { 43 if (!child_process.WaitForExit(&code)) {
44 LOG(WARNING) << "base::WaitForExitCode failed"; 44 LOG(WARNING) << "Process::WaitForExit failed";
45 return false; 45 return false;
46 } 46 }
47 return code == 0; 47 return code == 0;
48 } 48 }
49 }; 49 };
50 50
51 TEST_F(MacDirAccessSandboxTest, StringEscape) { 51 TEST_F(MacDirAccessSandboxTest, StringEscape) {
52 const struct string_escape_test_data { 52 const struct string_escape_test_data {
53 const char* to_escape; 53 const char* to_escape;
54 const char* escaped; 54 const char* escaped;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 PLOG(ERROR) << "Sandbox breach: was able to write (" 300 PLOG(ERROR) << "Sandbox breach: was able to write ("
301 << denied_file2.value() 301 << denied_file2.value()
302 << ")"; 302 << ")";
303 return -1; 303 return -1;
304 } 304 }
305 305
306 return 0; 306 return 0;
307 } 307 }
308 308
309 } // namespace content 309 } // namespace content
OLDNEW
« no previous file with comments | « components/browser_watcher/exit_code_watcher_win_unittest.cc ('k') | content/common/sandbox_mac_unittest_helper.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698