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

Side by Side Diff: runtime/vm/virtual_memory_test.cc

Issue 684783010: Add unit test for VirtualMemory::Commit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 1 month 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 | « no previous file | 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 Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/unit_test.h" 6 #include "vm/unit_test.h"
7 #include "vm/virtual_memory.h" 7 #include "vm/virtual_memory.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 delete vm; 69 delete vm;
70 } 70 }
71 for (intptr_t i = 0; i < kIterations; ++i) { 71 for (intptr_t i = 0; i < kIterations; ++i) {
72 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize); 72 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
73 vm->Commit(false); 73 vm->Commit(false);
74 vm->Truncate(0, false); 74 vm->Truncate(0, false);
75 delete vm; 75 delete vm;
76 } 76 }
77 } 77 }
78 78
79
80 UNIT_TEST_CASE(VirtualMemoryCommitPartial) {
81 const intptr_t kVirtualMemoryBlockSize = 3 * MB;
82 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
83 EXPECT(vm != NULL);
84 // Commit only the middle MB and write to it.
85 const uword commit_start = vm->start() + (1 * MB);
86 const intptr_t kCommitSize = 1 * MB;
87 vm->Commit(commit_start, kCommitSize, false);
88 char* buf = reinterpret_cast<char*>(commit_start);
89 buf[0] = 'f';
90 buf[1] = 'o';
91 buf[2] = 'o';
92 buf[3] = 0;
93 EXPECT_STREQ("foo", buf);
94 delete vm;
95 }
96
79 } // namespace dart 97 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698