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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/win/tests/validation_tests/commands.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/win/tests/validation_tests/suite.cc
diff --git a/sandbox/win/tests/validation_tests/suite.cc b/sandbox/win/tests/validation_tests/suite.cc
index f85b8dacc01841da9b936060bd9e977b3c9e9668..4a8ae4316c95834227baec595a4c860890b866e7 100644
--- a/sandbox/win/tests/validation_tests/suite.cc
+++ b/sandbox/win/tests/validation_tests/suite.cc
@@ -217,4 +217,25 @@ TEST(ValidationSuite, TestThread) {
EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(command));
}
+// Tests if an over-limit allocation will be denied.
+TEST(ValidationSuite, TestMemoryLimit) {
+ TestRunner runner;
+ wchar_t command[1024] = {0};
+ const int kAllocationSize = 256 * 1024 * 1024;
+
+ wsprintf(command, L"AllocateCmd %d", kAllocationSize);
+ runner.GetPolicy()->SetJobMemoryLimit(kAllocationSize);
+ EXPECT_EQ(SBOX_FATAL_MEMORY_EXCEEDED, runner.RunTest(command));
+}
+
+// Tests a large allocation will succeed absent limits.
+TEST(ValidationSuite, TestMemoryNoLimit) {
+ TestRunner runner;
+ wchar_t command[1024] = {0};
+ const int kAllocationSize = 256 * 1024 * 1024;
+
+ wsprintf(command, L"AllocateCmd %d", kAllocationSize);
+ EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(command));
+}
+
} // namespace sandbox
« 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