summaryrefslogtreecommitdiffstats
path: root/vespamalloc/src/tests
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-06-30 00:10:23 +0200
committerGitHub <noreply@github.com>2021-06-30 00:10:23 +0200
commita4c33e270068174c1b2ff5ffea94f90e3e93ccc5 (patch)
tree09e925a1caec1eb3a0b11383fe6c30bba66ffe3d /vespamalloc/src/tests
parent87de0d3c2b7c539a4c1ef9964a6f84edba9489f9 (diff)
Revert "Revert "Add support for mallinfo2 with glibc 2.33""
Diffstat (limited to 'vespamalloc/src/tests')
-rw-r--r--vespamalloc/src/tests/stacktrace/stacktrace.cpp21
-rw-r--r--vespamalloc/src/tests/test1/new_test.cpp26
2 files changed, 32 insertions, 15 deletions
diff --git a/vespamalloc/src/tests/stacktrace/stacktrace.cpp b/vespamalloc/src/tests/stacktrace/stacktrace.cpp
index f30e3c20f55..37322994586 100644
--- a/vespamalloc/src/tests/stacktrace/stacktrace.cpp
+++ b/vespamalloc/src/tests/stacktrace/stacktrace.cpp
@@ -17,12 +17,22 @@ void * run(void * arg)
}
void verify_that_vespamalloc_datasegment_size_exists() {
-#pragma GCC diagnostic push
-#if __GNUC_PREREQ(2, 33)
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+#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
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);
@@ -35,6 +45,7 @@ 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 9c291b3842e..7988367f415 100644
--- a/vespamalloc/src/tests/test1/new_test.cpp
+++ b/vespamalloc/src/tests/test1/new_test.cpp
@@ -95,17 +95,23 @@ TEST("verify new with alignment = 64 with single element") {
LOG(info, "&s=%p", s.get());
}
-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());
+#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);
}
+#endif
void verify_vespamalloc_usable_size() {
struct AllocInfo { size_t requested; size_t usable;};