summaryrefslogtreecommitdiffstats
path: root/vespamalloc/src/tests/test1/new_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vespamalloc/src/tests/test1/new_test.cpp')
-rw-r--r--vespamalloc/src/tests/test1/new_test.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/vespamalloc/src/tests/test1/new_test.cpp b/vespamalloc/src/tests/test1/new_test.cpp
index 5230869145d..0723f8cca85 100644
--- a/vespamalloc/src/tests/test1/new_test.cpp
+++ b/vespamalloc/src/tests/test1/new_test.cpp
@@ -134,14 +134,28 @@ void verify_vespamalloc_usable_size() {
}
}
+enum class MallocLibrary { UNKNOWN, VESPA_MALLOC, VESPA_MALLOC_D};
+
+MallocLibrary
+detectLibrary() {
+ if (dlsym(RTLD_NEXT, "is_vespamallocd") != nullptr) {
+ // Debug variants will never have more memory available as there is pre/postamble for error detection.
+ return MallocLibrary::VESPA_MALLOC_D;
+ } else if (dlsym(RTLD_NEXT, "is_vespamalloc") != nullptr) {
+ return MallocLibrary::VESPA_MALLOC;
+ }
+ return MallocLibrary::UNKNOWN;
+}
+
TEST("verify malloc_usable_size is sane") {
constexpr size_t SZ = 33;
std::unique_ptr<char[]> buf = std::make_unique<char[]>(SZ);
size_t usable_size = malloc_usable_size(buf.get());
- if (dlsym(RTLD_NEXT, "is_vespamallocd") != nullptr) {
+ MallocLibrary env = detectLibrary();
+ if (env == MallocLibrary::VESPA_MALLOC_D) {
// Debug variants will never have more memory available as there is pre/postamble for error detection.
EXPECT_EQUAL(SZ, usable_size);
- } else if (dlsym(RTLD_NEXT, "is_vespamalloc") != nullptr) {
+ } else if (env == MallocLibrary::VESPA_MALLOC) {
// Normal production vespamalloc will round up
EXPECT_EQUAL(64u, usable_size);
verify_vespamalloc_usable_size();
@@ -151,5 +165,13 @@ TEST("verify malloc_usable_size is sane") {
}
}
+TEST("verify mallopt") {
+ MallocLibrary env = detectLibrary();
+ if (env == MallocLibrary::UNKNOWN) return;
+ EXPECT_EQUAL(0, mallopt(M_MMAP_MAX, 0x1000000));
+ EXPECT_EQUAL(1, mallopt(M_MMAP_THRESHOLD, 0x1000000));
+ EXPECT_EQUAL(1, mallopt(M_MMAP_THRESHOLD, -1));
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }