From 6fe07cd2c0527e18276cc79a57e2212a4b048746 Mon Sep 17 00:00:00 2001 From: csilvers Date: Fri, 4 Mar 2011 23:52:33 +0000 Subject: * 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 --- src/tests/tcmalloc_unittest.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/tests/tcmalloc_unittest.cc') 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. -- cgit v1.2.1