diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-09 18:22:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-09 18:22:31 +0100 |
commit | 6c6587b5be7ea8ca01bfbfba42b290fb4873ba45 (patch) | |
tree | 67a5dde7b07283d02025add86c64a2a4a6fada67 /vespamalloc/src/tests | |
parent | 5603653ace6fce5bba2bf515685dc1de97a42088 (diff) | |
parent | 5f96af6e4995a7a38445f3d24482baaedeec0668 (diff) |
Merge pull request #21120 from vespa-engine/revert-21119-revert-21118-balder/wire-in-mallopt-control-of-vespamalloc-skeletonv7.541.24
Revert "Revert "Wire in mallopt(in param, int value) interface in vespamalloc and ver…""
Diffstat (limited to 'vespamalloc/src/tests')
-rw-r--r-- | vespamalloc/src/tests/stacktrace/stacktrace.cpp | 1 | ||||
-rw-r--r-- | vespamalloc/src/tests/test1/new_test.cpp | 26 |
2 files changed, 24 insertions, 3 deletions
diff --git a/vespamalloc/src/tests/stacktrace/stacktrace.cpp b/vespamalloc/src/tests/stacktrace/stacktrace.cpp index b28a9653d27..2f0d2eb2277 100644 --- a/vespamalloc/src/tests/stacktrace/stacktrace.cpp +++ b/vespamalloc/src/tests/stacktrace/stacktrace.cpp @@ -1,6 +1,5 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <cstdlib> -#include <cstdio> #include <pthread.h> #include <dlfcn.h> #include <cassert> 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(); } |