OLD | NEW |
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 Loading... |
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 |
OLD | NEW |