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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 const char* test_data) { | 74 const char* test_data) { |
75 std::stringstream s; | 75 std::stringstream s; |
76 s << static_cast<int>(static_cast<int>(sandbox_type)); | 76 s << static_cast<int>(static_cast<int>(sandbox_type)); |
77 setenv(kSandboxTypeKey, s.str().c_str(), 1); | 77 setenv(kSandboxTypeKey, s.str().c_str(), 1); |
78 setenv(kSandboxTestNameKey, test_name, 1); | 78 setenv(kSandboxTestNameKey, test_name, 1); |
79 if (test_data) | 79 if (test_data) |
80 setenv(kTestDataKey, test_data, 1); | 80 setenv(kTestDataKey, test_data, 1); |
81 | 81 |
82 base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner", | 82 base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner", |
83 false); | 83 false); |
| 84 if (child_process == base::kNullProcessHandle) { |
| 85 LOG(WARNING) << "SpawnChild failed"; |
| 86 return false; |
| 87 } |
84 int code = -1; | 88 int code = -1; |
85 if (!base::WaitForExitCode(child_process, &code)) { | 89 if (!base::WaitForExitCode(child_process, &code)) { |
86 LOG(WARNING) << "base::WaitForExitCode failed"; | 90 LOG(WARNING) << "base::WaitForExitCode failed"; |
87 return false; | 91 return false; |
88 } | 92 } |
89 return code == 0; | 93 return code == 0; |
90 } | 94 } |
91 | 95 |
92 bool MacSandboxTestCase::BeforeSandboxInit() { | 96 bool MacSandboxTestCase::BeforeSandboxInit() { |
93 return true; | 97 return true; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 165 |
162 if (!test_case->SandboxedTest()) { | 166 if (!test_case->SandboxedTest()) { |
163 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test"; | 167 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test"; |
164 return -1; | 168 return -1; |
165 } | 169 } |
166 | 170 |
167 return 0; | 171 return 0; |
168 } | 172 } |
169 | 173 |
170 } // namespace | 174 } // namespace |
OLD | NEW |