OLD | NEW |
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 #include "content/common/sandbox_mac_unittest_helper.h" | 5 #include "content/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 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 bool MacSandboxTest::RunTestInSandbox(SandboxType sandbox_type, | 70 bool MacSandboxTest::RunTestInSandbox(SandboxType sandbox_type, |
71 const char* test_name, | 71 const char* test_name, |
72 const char* test_data) { | 72 const char* test_data) { |
73 std::stringstream s; | 73 std::stringstream s; |
74 s << static_cast<int>(static_cast<int>(sandbox_type)); | 74 s << static_cast<int>(static_cast<int>(sandbox_type)); |
75 setenv(kSandboxTypeKey, s.str().c_str(), 1); | 75 setenv(kSandboxTypeKey, s.str().c_str(), 1); |
76 setenv(kSandboxTestNameKey, test_name, 1); | 76 setenv(kSandboxTestNameKey, test_name, 1); |
77 if (test_data) | 77 if (test_data) |
78 setenv(kTestDataKey, test_data, 1); | 78 setenv(kTestDataKey, test_data, 1); |
79 | 79 |
80 base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner"); | 80 base::Process child_process = SpawnChild("mac_sandbox_test_runner"); |
81 if (child_process == base::kNullProcessHandle) { | 81 if (!child_process.IsValid()) { |
82 LOG(WARNING) << "SpawnChild failed"; | 82 LOG(WARNING) << "SpawnChild failed"; |
83 return false; | 83 return false; |
84 } | 84 } |
85 int code = -1; | 85 int code = -1; |
86 if (!base::WaitForExitCode(child_process, &code)) { | 86 if (!child_process.WaitForExit(&code)) { |
87 LOG(WARNING) << "base::WaitForExitCode failed"; | 87 LOG(WARNING) << "Process::WaitForExit failed"; |
88 return false; | 88 return false; |
89 } | 89 } |
90 return code == 0; | 90 return code == 0; |
91 } | 91 } |
92 | 92 |
93 bool MacSandboxTestCase::BeforeSandboxInit() { | 93 bool MacSandboxTestCase::BeforeSandboxInit() { |
94 return true; | 94 return true; |
95 } | 95 } |
96 | 96 |
97 void MacSandboxTestCase::SetTestData(const char* test_data) { | 97 void MacSandboxTestCase::SetTestData(const char* test_data) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 if (!test_case->SandboxedTest()) { | 161 if (!test_case->SandboxedTest()) { |
162 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test"; | 162 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test"; |
163 return -1; | 163 return -1; |
164 } | 164 } |
165 | 165 |
166 return 0; | 166 return 0; |
167 } | 167 } |
168 | 168 |
169 } // namespace content | 169 } // namespace content |
OLD | NEW |