| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (!sandbox_test_name) { | 132 if (!sandbox_test_name) { |
| 133 LOG(ERROR) << "Sandbox test name not specified"; | 133 LOG(ERROR) << "Sandbox test name not specified"; |
| 134 return -1; | 134 return -1; |
| 135 } | 135 } |
| 136 | 136 |
| 137 const char* test_data = getenv(kTestDataKey); | 137 const char* test_data = getenv(kTestDataKey); |
| 138 | 138 |
| 139 // Find Test Function to run; | 139 // Find Test Function to run; |
| 140 scoped_ptr<MacSandboxTestCase> | 140 scoped_ptr<MacSandboxTestCase> |
| 141 test_case(SandboxTestForName(sandbox_test_name)); | 141 test_case(SandboxTestForName(sandbox_test_name)); |
| 142 if (!test_case.get()) { | 142 if (!test_case) { |
| 143 LOG(ERROR) << "Invalid sandbox test name (" << sandbox_test_name << ")"; | 143 LOG(ERROR) << "Invalid sandbox test name (" << sandbox_test_name << ")"; |
| 144 return -1; | 144 return -1; |
| 145 } | 145 } |
| 146 if (test_data) | 146 if (test_data) |
| 147 test_case->SetTestData(test_data); | 147 test_case->SetTestData(test_data); |
| 148 | 148 |
| 149 // Run Test. | 149 // Run Test. |
| 150 if (!test_case->BeforeSandboxInit()) { | 150 if (!test_case->BeforeSandboxInit()) { |
| 151 LOG(ERROR) << sandbox_test_name << "Failed test before sandbox init"; | 151 LOG(ERROR) << sandbox_test_name << "Failed test before sandbox init"; |
| 152 return -1; | 152 return -1; |
| 153 } | 153 } |
| 154 | 154 |
| 155 Sandbox::SandboxWarmup(sandbox_type); | 155 Sandbox::SandboxWarmup(sandbox_type); |
| 156 | 156 |
| 157 if (!Sandbox::EnableSandbox(sandbox_type, base::FilePath())) { | 157 if (!Sandbox::EnableSandbox(sandbox_type, base::FilePath())) { |
| 158 LOG(ERROR) << "Failed to initialize sandbox " << sandbox_type; | 158 LOG(ERROR) << "Failed to initialize sandbox " << sandbox_type; |
| 159 return -1; | 159 return -1; |
| 160 } | 160 } |
| 161 | 161 |
| 162 if (!test_case->SandboxedTest()) { | 162 if (!test_case->SandboxedTest()) { |
| 163 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test"; | 163 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test"; |
| 164 return -1; | 164 return -1; |
| 165 } | 165 } |
| 166 | 166 |
| 167 return 0; | 167 return 0; |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace content | 170 } // namespace content |
| OLD | NEW |