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

Side by Side Diff: chrome/common/sandbox_mac_unittest_helper.mm

Issue 3026055: Cleanup in base. This moves the implementation (and a bunch of header file... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/common/sandbox_mac_unittest_helper.h" 5 #include "chrome/common/sandbox_mac_unittest_helper.h"
6 6
7 extern "C" { 7 extern "C" {
8 #include <sandbox.h> 8 #include <sandbox.h>
9 } 9 }
10 10
11 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
12 #include "chrome/common/sandbox_mac.h" 12 #include "chrome/common/sandbox_mac.h"
13 #include "testing/multiprocess_func_list.h"
13 14
14 namespace { 15 namespace {
15 16
16 const char* kSandboxTypeKey = "CHROMIUM_SANDBOX_SANDBOX_TYPE"; 17 const char* kSandboxTypeKey = "CHROMIUM_SANDBOX_SANDBOX_TYPE";
17 const char* kSandboxTestNameKey = "CHROMIUM_SANDBOX_TEST_NAME"; 18 const char* kSandboxTestNameKey = "CHROMIUM_SANDBOX_TEST_NAME";
18 const char* kTestDataKey = "CHROMIUM_SANDBOX_USER_DATA"; 19 const char* kTestDataKey = "CHROMIUM_SANDBOX_USER_DATA";
19 20
20 } // namespace 21 } // namespace
21 22
22 namespace sandboxtest { 23 namespace sandboxtest {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 bool MacSandboxTest::RunTestInSandbox(sandbox::SandboxProcessType sandbox_type, 65 bool MacSandboxTest::RunTestInSandbox(sandbox::SandboxProcessType sandbox_type,
65 const char* test_name, 66 const char* test_name,
66 const char* test_data) { 67 const char* test_data) {
67 std::stringstream s; 68 std::stringstream s;
68 s << static_cast<int>(static_cast<int>(sandbox_type)); 69 s << static_cast<int>(static_cast<int>(sandbox_type));
69 setenv(kSandboxTypeKey, s.str().c_str(), 1); 70 setenv(kSandboxTypeKey, s.str().c_str(), 1);
70 setenv(kSandboxTestNameKey, test_name, 1); 71 setenv(kSandboxTestNameKey, test_name, 1);
71 if (test_data) 72 if (test_data)
72 setenv(kTestDataKey, test_data, 1); 73 setenv(kTestDataKey, test_data, 1);
73 74
74 base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner"); 75 base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner",
76 false);
75 int code = -1; 77 int code = -1;
76 if (!base::WaitForExitCode(child_process, &code)) { 78 if (!base::WaitForExitCode(child_process, &code)) {
77 LOG(WARNING) << "base::WaitForExitCode failed"; 79 LOG(WARNING) << "base::WaitForExitCode failed";
78 return false; 80 return false;
79 } 81 }
80 return code == 0; 82 return code == 0;
81 } 83 }
82 84
83 // Given a test name specified by |name| return that test case. 85 // Given a test name specified by |name| return that test case.
84 // If no test case is found for the given name, return NULL. 86 // If no test case is found for the given name, return NULL.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 146
145 if (!test_case->SandboxedTest()) { 147 if (!test_case->SandboxedTest()) {
146 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test"; 148 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test";
147 return -1; 149 return -1;
148 } 150 }
149 151
150 return 0; 152 return 0;
151 } 153 }
152 154
153 } // namespace 155 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698