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

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

Issue 8608005: Check for NULL pointer before assigning the test data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 9 years, 1 month 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
« no previous file with comments | « content/common/sandbox_mac_unittest_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 const char* test_data = getenv(kTestDataKey); 142 const char* test_data = getenv(kTestDataKey);
143 143
144 // Find Test Function to run; 144 // Find Test Function to run;
145 scoped_ptr<sandboxtest::MacSandboxTestCase> 145 scoped_ptr<sandboxtest::MacSandboxTestCase>
146 test_case(sandboxtest::SandboxTestForName(sandbox_test_name)); 146 test_case(sandboxtest::SandboxTestForName(sandbox_test_name));
147 if (!test_case.get()) { 147 if (!test_case.get()) {
148 LOG(ERROR) << "Invalid sandbox test name (" << sandbox_test_name << ")"; 148 LOG(ERROR) << "Invalid sandbox test name (" << sandbox_test_name << ")";
149 return -1; 149 return -1;
150 } 150 }
151 test_case->SetTestData(test_data); 151 if (test_data)
152 test_case->SetTestData(test_data);
152 153
153 // Run Test. 154 // Run Test.
154 if (!test_case->BeforeSandboxInit()) { 155 if (!test_case->BeforeSandboxInit()) {
155 LOG(ERROR) << sandbox_test_name << "Failed test before sandbox init"; 156 LOG(ERROR) << sandbox_test_name << "Failed test before sandbox init";
156 return -1; 157 return -1;
157 } 158 }
158 159
159 Sandbox::SandboxWarmup(sandbox_type); 160 Sandbox::SandboxWarmup(sandbox_type);
160 161
161 if (!Sandbox::EnableSandbox(sandbox_type, FilePath())) { 162 if (!Sandbox::EnableSandbox(sandbox_type, FilePath())) {
162 LOG(ERROR) << "Failed to initialize sandbox " << sandbox_type; 163 LOG(ERROR) << "Failed to initialize sandbox " << sandbox_type;
163 return -1; 164 return -1;
164 } 165 }
165 166
166 if (!test_case->SandboxedTest()) { 167 if (!test_case->SandboxedTest()) {
167 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test"; 168 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test";
168 return -1; 169 return -1;
169 } 170 }
170 171
171 return 0; 172 return 0;
172 } 173 }
173 174
174 } // namespace 175 } // namespace
OLDNEW
« no previous file with comments | « content/common/sandbox_mac_unittest_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698