summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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();