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

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

Issue 7304008: Ensure tests check the return of SpawnChild() when they may wait without timeouts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mac compile fixes Created 9 years, 5 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) 2011 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 17 matching lines...) Expand all
28 // Tests need to be in the same namespace as the sandbox::Sandbox class to be 28 // Tests need to be in the same namespace as the sandbox::Sandbox class to be
29 // useable with FRIEND_TEST() declaration. 29 // useable with FRIEND_TEST() declaration.
30 namespace sandbox { 30 namespace sandbox {
31 31
32 class MacDirAccessSandboxTest : public base::MultiProcessTest { 32 class MacDirAccessSandboxTest : public base::MultiProcessTest {
33 public: 33 public:
34 bool CheckSandbox(const std::string& directory_to_try) { 34 bool CheckSandbox(const std::string& directory_to_try) {
35 setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1); 35 setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1);
36 base::ProcessHandle child_process = SpawnChild("mac_sandbox_path_access", 36 base::ProcessHandle child_process = SpawnChild("mac_sandbox_path_access",
37 false); 37 false);
38 if (child_process == base::kNullProcessHandle) {
39 LOG(WARNING) << "SpawnChild failed";
40 return false;
41 }
38 int code = -1; 42 int code = -1;
39 if (!base::WaitForExitCode(child_process, &code)) { 43 if (!base::WaitForExitCode(child_process, &code)) {
40 LOG(WARNING) << "base::WaitForExitCode failed"; 44 LOG(WARNING) << "base::WaitForExitCode failed";
41 return false; 45 return false;
42 } 46 }
43 return code == 0; 47 return code == 0;
44 } 48 }
45 }; 49 };
46 50
47 TEST_F(MacDirAccessSandboxTest, StringEscape) { 51 TEST_F(MacDirAccessSandboxTest, StringEscape) {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 PLOG(ERROR) << "Sandbox breach: was able to write (" 299 PLOG(ERROR) << "Sandbox breach: was able to write ("
296 << denied_file2.value() 300 << denied_file2.value()
297 << ")"; 301 << ")";
298 return -1; 302 return -1;
299 } 303 }
300 304
301 return 0; 305 return 0;
302 } 306 }
303 307
304 } // namespace sandbox 308 } // namespace sandbox
OLDNEW
« no previous file with comments | « content/common/process_watcher_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