Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Unified Diff: third_party/tcmalloc/chromium/src/tests/simple_compat_test.cc

Issue 9311003: Update the tcmalloc chromium branch to r144 (gperftools 2.0), and merge chromium-specific changes. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebasec Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/chromium/src/tests/simple_compat_test.cc
diff --git a/third_party/tcmalloc/chromium/src/tests/current_allocated_bytes_test.cc b/third_party/tcmalloc/chromium/src/tests/simple_compat_test.cc
similarity index 59%
copy from third_party/tcmalloc/chromium/src/tests/current_allocated_bytes_test.cc
copy to third_party/tcmalloc/chromium/src/tests/simple_compat_test.cc
index 8188e7b6937d165abcd787ddf87c5a66daaea841..824cfcf693d6d900864595e4fddb4074d96f76f3 100644
--- a/third_party/tcmalloc/chromium/src/tests/current_allocated_bytes_test.cc
+++ b/third_party/tcmalloc/chromium/src/tests/simple_compat_test.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, Google Inc.
+// Copyright (c) 2012, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -26,38 +26,42 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
// ---
-//
// Author: Craig Silverstein
+//
+// This just verifies that we can compile code that #includes stuff
+// via the backwards-compatibility 'google/' #include-dir. It does
+// not include config.h on purpose, to better simulate a perftools
+// client.
-// This tests the accounting done by tcmalloc. When we allocate and
-// free a small buffer, the number of bytes used by the application
-// before the alloc+free should match the number of bytes used after.
-// However, the internal data structures used by tcmalloc will be
-// quite different -- new spans will have been allocated, etc. This
-// is, thus, a simple test that we account properly for the internal
-// data structures, so that we report the actual application-used
-// bytes properly.
-
-#include "config_for_unittests.h"
-#include <stdlib.h>
+#include <stddef.h>
#include <stdio.h>
+#include <google/heap-checker.h>
+#include <google/heap-profiler.h>
#include <google/malloc_extension.h>
-#include "base/logging.h"
+#include <google/malloc_extension_c.h>
+#include <google/malloc_hook.h>
+#include <google/malloc_hook_c.h>
+#include <google/profiler.h>
+#include <google/stacktrace.h>
+#include <google/tcmalloc.h>
-const char kCurrent[] = "generic.current_allocated_bytes";
+// We don't link in -lprofiler for this test, so be sure not to make
+// any function calls that require the cpu-profiler code. The
+// heap-profiler is ok.
-int main() {
- // We don't do accounting right when using debugallocation.cc, so
- // turn off the test then. TODO(csilvers): get this working too.
-#ifdef NDEBUG
- size_t before_bytes, after_bytes;
- MallocExtension::instance()->GetNumericProperty(kCurrent, &before_bytes);
- free(malloc(200));
- MallocExtension::instance()->GetNumericProperty(kCurrent, &after_bytes);
+HeapLeakChecker::Disabler* heap_checker_h;
+void (*heap_profiler_h)(const char*) = &HeapProfilerStart;
+MallocExtension::Ownership malloc_extension_h;
+MallocExtension_Ownership malloc_extension_c_h;
+MallocHook::NewHook* malloc_hook_h;
+MallocHook_NewHook* malloc_hook_c_h;
+ProfilerOptions* profiler_h;
+int (*stacktrace_h)(void**, int, int) = &GetStackTrace;
+void* (*tcmalloc_h)(size_t) = &tc_new;
- CHECK_EQ(before_bytes, after_bytes);
-#endif
+int main(int argc, char** argv) {
printf("PASS\n");
return 0;
}

Powered by Google App Engine
This is Rietveld 408576698