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

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: 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/src/sandbox_types.h ('k') | sandbox/win/tests/validation_tests/suite.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4b1209483ea9e65b5654f67a9904a538d9841679 100644
--- a/sandbox/win/tests/validation_tests/commands.cc
+++ b/sandbox/win/tests/validation_tests/commands.cc
@@ -310,5 +310,24 @@ 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 != 1)
+ 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) {
+ // We need to give the broker a chance to kill our process on failure.
+ ::Sleep(5000);
+ return SBOX_TEST_DENIED;
+ }
+
+ if (!::VirtualFree(memory, 0, MEM_RELEASE))
+ return SBOX_TEST_FAILED;
+
+ return SBOX_TEST_SUCCEEDED;
+}
+
} // namespace sandbox
« no previous file with comments | « sandbox/win/src/sandbox_types.h ('k') | sandbox/win/tests/validation_tests/suite.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698