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

Unified Diff: sandbox/win/tests/validation_tests/commands.cc

Issue 319573006: Add sandbox support for process memory limits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review 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
Index: sandbox/win/tests/validation_tests/commands.cc
diff --git a/sandbox/win/tests/validation_tests/commands.cc b/sandbox/win/tests/validation_tests/commands.cc
index e7620c37600eb0d92e5957d5b7a794577b4b72f6..00796b76118eb66d010bac57668896047898fc5a 100644
--- a/sandbox/win/tests/validation_tests/commands.cc
+++ b/sandbox/win/tests/validation_tests/commands.cc
@@ -310,5 +310,25 @@ SBOX_TESTS_COMMAND int SleepCmd(int argc, wchar_t **argv) {
return SBOX_TEST_SUCCEEDED;
}
+SBOX_TESTS_COMMAND int AllocateCmd(int argc, wchar_t **argv) {
+ if (argc > 2)
+ return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
+
+ size_t mem_size = static_cast<size_t>(_wtoll(argv[0]));
+ void* memory = ::VirtualAlloc(NULL, mem_size, MEM_COMMIT | MEM_RESERVE,
+ PAGE_READWRITE);
+ if (!memory) {
+ // If we're testing broker termination we need to wait for it.
+ if (argc == 2 && _wcsicmp(argv[1], L"wait") == 0)
+ ::Sleep(5000);
+ return SBOX_TEST_DENIED;
+ }
+
+ if (!::VirtualFree(memory, 0, MEM_RELEASE))
+ return SBOX_TEST_FAILED;
+
+ return SBOX_TEST_SUCCEEDED;
+}
+
} // namespace sandbox

Powered by Google App Engine
This is Rietveld 408576698