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