diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-06-29 18:30:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-29 18:30:19 +0200 |
commit | fda563474cc374c4a0c5844f7dc2fc2651edc26f (patch) | |
tree | bc8e0f6ccfb528df16a9c3fcd1ce023c84dbc034 /vespamalloc/src/tests | |
parent | ebdcd395eee13cea7045e2bf6435c6875cdf0783 (diff) |
Revert "Revert "Revert "Add support for mallinfo2 with glibc 2.33"""
Diffstat (limited to 'vespamalloc/src/tests')
-rw-r--r-- | vespamalloc/src/tests/stacktrace/stacktrace.cpp | 21 | ||||
-rw-r--r-- | vespamalloc/src/tests/test1/new_test.cpp | 26 |
2 files changed, 15 insertions, 32 deletions
diff --git a/vespamalloc/src/tests/stacktrace/stacktrace.cpp b/vespamalloc/src/tests/stacktrace/stacktrace.cpp index 37322994586..f30e3c20f55 100644 --- a/vespamalloc/src/tests/stacktrace/stacktrace.cpp +++ b/vespamalloc/src/tests/stacktrace/stacktrace.cpp @@ -17,22 +17,12 @@ void * run(void * arg) } void verify_that_vespamalloc_datasegment_size_exists() { -#if __GLIBC_PREREQ(2, 33) - struct mallinfo2 info = mallinfo2(); - printf("Malloc used %zdm of memory\n", info.arena); - assert(info.arena >= 10 * 0x100000ul); - assert(info.arena < 10000 * 0x100000ul); - assert(info.fordblks == 0); - assert(info.fsmblks == 0); - assert(info.hblkhd == 0); - assert(info.hblks == 0); - assert(info.keepcost == 0); - assert(info.ordblks == 0); - assert(info.smblks == 0); - assert(info.uordblks == 0); - assert(info.usmblks == 0); -#else +#pragma GCC diagnostic push +#if __GNUC_PREREQ(2, 33) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif struct mallinfo info = mallinfo(); +#pragma GCC diagnostic push printf("Malloc used %dm of memory\n",info.arena); assert(info.arena >= 10); assert(info.arena < 10000); @@ -45,7 +35,6 @@ void verify_that_vespamalloc_datasegment_size_exists() { assert(info.smblks == 0); assert(info.uordblks == 0); assert(info.usmblks == 0); -#endif } int main(int argc, char *argv[]) diff --git a/vespamalloc/src/tests/test1/new_test.cpp b/vespamalloc/src/tests/test1/new_test.cpp index 7988367f415..9c291b3842e 100644 --- a/vespamalloc/src/tests/test1/new_test.cpp +++ b/vespamalloc/src/tests/test1/new_test.cpp @@ -95,23 +95,17 @@ TEST("verify new with alignment = 64 with single element") { LOG(info, "&s=%p", s.get()); } -#if __GLIBC_PREREQ(2, 26) -TEST("verify realloarray") { - void *arr = calloc(5,5); - errno = 0; - void *arr2 = reallocarray(arr, 800, 5); - int myErrno = errno; - EXPECT_NOT_EQUAL(arr, arr2); - EXPECT_NOT_EQUAL(nullptr, arr2); - EXPECT_NOT_EQUAL(ENOMEM, myErrno); - - errno = 0; - void *arr3 = reallocarray(arr2, 1ul << 33, 1ul << 33); - myErrno = errno; - EXPECT_EQUAL(nullptr, arr3); - EXPECT_EQUAL(ENOMEM, myErrno); +TEST("verify new with alignment = 64 with single element") { + struct alignas(64) S { + long a; + }; + static_assert(sizeof(S) == 64); + static_assert(alignof(S) == 64); + auto s = std::make_unique<S>(); + verify_aligned(s.get()); + cmp(s.get(), &s->a); + LOG(info, "&s=%p", s.get()); } -#endif void verify_vespamalloc_usable_size() { struct AllocInfo { size_t requested; size_t usable;}; |