diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2020-04-15 13:18:50 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2020-04-15 13:30:03 +0200 |
commit | d5cfd893211bc24d7ed108b4607c80b22bd3ea7f (patch) | |
tree | 8c4893053a17b2aeaefd364034333d1eb07ae513 /vespalib/src/tests/alloc | |
parent | 1ee3a5aa8d674b1456b684c583a96092be91a344 (diff) |
Check that pointers are equal, don't try to compare C strings.
Skip some tests that depend on the linux vm subsystem when running
unit tests on non-linux platform.
Diffstat (limited to 'vespalib/src/tests/alloc')
-rw-r--r-- | vespalib/src/tests/alloc/alloc_test.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/vespalib/src/tests/alloc/alloc_test.cpp b/vespalib/src/tests/alloc/alloc_test.cpp index 4a569050f45..d46d2374dfc 100644 --- a/vespalib/src/tests/alloc/alloc_test.cpp +++ b/vespalib/src/tests/alloc/alloc_test.cpp @@ -155,7 +155,7 @@ void ensureRoomForExtension(const Alloc & buf, Alloc & reserved) { // So in order to verify this we first mmap a reserved area that we unmap // before we test extension. if (reserved.get() > buf.get()) { - EXPECT_EQUAL(reserved.get(), static_cast<const char *>(buf.get()) + buf.size()); + EXPECT_EQUAL(reserved.get(), static_cast<const void *>(static_cast<const char *>(buf.get()) + buf.size())); { Alloc().swap(reserved); } @@ -166,14 +166,15 @@ void verifyNoExtensionWhenNoRoom(Alloc & buf, Alloc & reserved, size_t sz) { if (reserved.get() > buf.get()) { // Normally mmapping starts at the top and grows down in address space. // Then there is no room to extend the last mapping. - EXPECT_EQUAL(reserved.get(), static_cast<const char *>(buf.get()) + buf.size()); + EXPECT_EQUAL(reserved.get(), static_cast<const void *>(static_cast<const char *>(buf.get()) + buf.size())); TEST_DO(verifyExtension(buf, sz, sz)); } else { - EXPECT_EQUAL(buf.get(), static_cast<const char *>(reserved.get()) + reserved.size()); + EXPECT_EQUAL(buf.get(), static_cast<const void *>(static_cast<const char *>(reserved.get()) + reserved.size())); TEST_DO(verifyExtension(reserved, sz, sz)); } } +#ifdef __linux__ TEST("auto alloced mmap alloc can be extended if room") { static constexpr size_t SZ = MemoryAllocator::HUGEPAGE_SIZE*2; Alloc reserved = Alloc::alloc(SZ); @@ -207,6 +208,7 @@ TEST("mmap alloc can not be extended if no room") { TEST_DO(verifyNoExtensionWhenNoRoom(buf, reserved, 4096)); } +#endif TEST("heap alloc can not be shrinked") { Alloc buf = Alloc::allocHeap(101); |