summaryrefslogtreecommitdiff
path: root/src/tests/tcmalloc_unittest.cc
diff options
context:
space:
mode:
authorcsilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50>2011-03-04 23:52:33 +0000
committercsilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50>2011-03-04 23:52:33 +0000
commit6fe07cd2c0527e18276cc79a57e2212a4b048746 (patch)
treebddf3a270eaa039d36146c6f77e76a058c09ecfb /src/tests/tcmalloc_unittest.cc
parent75584139e40c9d6c952d9c5339c52e5b58302fc8 (diff)
downloadgperftools-6fe07cd2c0527e18276cc79a57e2212a4b048746.tar.gz
* add a flag to use MAP_PRIVATE in memfs_malloc (gangren)
* pthread_self() is now safe to use early (ppluzhnikov) * windows support for pprof: nul and /usr/bin/file (csilvers) * fix tc_malloc_size for debugallocation (csilvers) * add test on strdup to tcmalloc_test (csilvers) * augment heap-checker to deal with no-inode maps (csilvers) * Get rid of -Wno-unused-result: not all gcc's support it (csilvers) * /bin/true -> ':', which is faster and more portable (csilvers) git-svn-id: http://gperftools.googlecode.com/svn/trunk@107 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
Diffstat (limited to 'src/tests/tcmalloc_unittest.cc')
-rw-r--r--src/tests/tcmalloc_unittest.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/tests/tcmalloc_unittest.cc b/src/tests/tcmalloc_unittest.cc
index 7c21fc4..3af48f8 100644
--- a/src/tests/tcmalloc_unittest.cc
+++ b/src/tests/tcmalloc_unittest.cc
@@ -1015,7 +1015,10 @@ static int RunAllTests(int argc, char** argv) {
p1 = calloc(10, 2);
CHECK(p1 != NULL);
VerifyNewHookWasCalled();
- p1 = realloc(p1, 30);
+ // We make sure we realloc to a big size, since some systems (OS
+ // X) will notice if the realloced size continues to fit into the
+ // malloc-block and make this a noop if so.
+ p1 = realloc(p1, 30000);
CHECK(p1 != NULL);
VerifyNewHookWasCalled();
VerifyDeleteHookWasCalled();
@@ -1092,6 +1095,15 @@ static int RunAllTests(int argc, char** argv) {
::operator delete(p2, std::nothrow);
VerifyDeleteHookWasCalled();
+ // Try strdup(), which the system allocates but we must free. If
+ // all goes well, libc will use our malloc!
+ p2 = strdup("test");
+ CHECK(p2 != NULL);
+ VerifyNewHookWasCalled();
+ free(p2);
+ VerifyDeleteHookWasCalled();
+
+
// Test mmap too: both anonymous mmap and mmap of a file
// Note that for right now we only override mmap on linux
// systems, so those are the only ones for which we check.