summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-01-03 18:52:23 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-01-03 18:52:23 +0100
commit8fd7bdfae6ddee3ba4f6d9a586b82a327510e3cb (patch)
treebd2cce89afead9d42f4ea72f11c26e9e0fbcde44 /vespalib
parentc0ecc5d29f69fcd6824ad971a3ce4773330a6f1e (diff)
The -> Then typo and added a test that mmap leaves untouched if no room for extension.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/alloc/alloc_test.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/vespalib/src/tests/alloc/alloc_test.cpp b/vespalib/src/tests/alloc/alloc_test.cpp
index 03d600c6559..a533197ef91 100644
--- a/vespalib/src/tests/alloc/alloc_test.cpp
+++ b/vespalib/src/tests/alloc/alloc_test.cpp
@@ -116,7 +116,7 @@ TEST("mmap alloc can be extended if room") {
Alloc buf = Alloc::allocMMap(100);
// Normally mmapping starts at the top and grows down in address space.
- // The there is no room to extend the last mapping.
+ // Then there is no room to extend the last mapping.
// So in order to verify this we first mmap a reserved area that we unmap
// before we test extension.
EXPECT_GREATER(reserved.get(), buf.get());
@@ -132,6 +132,24 @@ TEST("mmap alloc can be extended if room") {
EXPECT_EQUAL(8192, buf.size());
}
+TEST("mmap alloc can not be extended if no room") {
+ Alloc reserved = Alloc::allocMMap(100);
+ Alloc buf = Alloc::allocMMap(100);
+
+ // Normally mmapping starts at the top and grows down in address space.
+ // Then there is no room to extend the last mapping.
+ // So in order to verify this we first mmap a reserved area that we unmap
+ // before we test extension.
+ EXPECT_GREATER(reserved.get(), buf.get());
+ EXPECT_EQUAL(reserved.get(), static_cast<const char *>(buf.get()) + buf.size());
+
+ void * oldPtr = buf.get();
+ EXPECT_EQUAL(4096, buf.size());
+ EXPECT_FALSE(buf.resize_inplace(4097));
+ EXPECT_EQUAL(oldPtr, buf.get());
+ EXPECT_EQUAL(4096, buf.size());
+}
+
TEST("heap alloc can not be shrinked") {
Alloc buf = Alloc::allocHeap(101);
void * oldPtr = buf.get();