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

Side by Side Diff: sandbox/win/tests/validation_tests/suite.cc

Issue 319573006: Add sandbox support for process memory limits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 6 years, 6 months 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 | « sandbox/win/tests/validation_tests/commands.cc ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file contains the validation tests for the sandbox. 5 // This file contains the validation tests for the sandbox.
6 // It includes the tests that need to be performed inside the 6 // It includes the tests that need to be performed inside the
7 // sandbox. 7 // sandbox.
8 8
9 #include <shlwapi.h> 9 #include <shlwapi.h>
10 10
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 // Tests if the threads are correctly protected by the sandbox. 211 // Tests if the threads are correctly protected by the sandbox.
212 TEST(ValidationSuite, TestThread) { 212 TEST(ValidationSuite, TestThread) {
213 TestRunner runner; 213 TestRunner runner;
214 wchar_t command[1024] = {0}; 214 wchar_t command[1024] = {0};
215 215
216 wsprintf(command, L"OpenThreadCmd %d", ::GetCurrentThreadId()); 216 wsprintf(command, L"OpenThreadCmd %d", ::GetCurrentThreadId());
217 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(command)); 217 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(command));
218 } 218 }
219 219
220 // Tests if an over-limit allocation will be denied.
221 TEST(ValidationSuite, TestMemoryLimit) {
222 TestRunner runner;
223 wchar_t command[1024] = {0};
224 const int kAllocationSize = 256 * 1024 * 1024;
225
226 wsprintf(command, L"AllocateCmd %d", kAllocationSize);
227 runner.GetPolicy()->SetJobMemoryLimit(kAllocationSize);
228 EXPECT_EQ(SBOX_FATAL_MEMORY_EXCEEDED, runner.RunTest(command));
229 }
230
231 // Tests a large allocation will succeed absent limits.
232 TEST(ValidationSuite, TestMemoryNoLimit) {
233 TestRunner runner;
234 wchar_t command[1024] = {0};
235 const int kAllocationSize = 256 * 1024 * 1024;
236
237 wsprintf(command, L"AllocateCmd %d", kAllocationSize);
238 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(command));
239 }
240
220 } // namespace sandbox 241 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/tests/validation_tests/commands.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698