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

Side by Side Diff: third_party/tcmalloc/chromium/src/tests/malloc_extension_test.cc

Issue 576001: Merged third_party/tcmalloc/vendor/src(google-perftools r87) into... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Removed the unnecessary printf and ASSERT(0) Created 10 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 25 matching lines...) Expand all
36 #include <stdio.h> 36 #include <stdio.h>
37 #include <sys/types.h> 37 #include <sys/types.h>
38 #include "base/logging.h" 38 #include "base/logging.h"
39 #include <google/malloc_extension.h> 39 #include <google/malloc_extension.h>
40 #include <google/malloc_extension_c.h> 40 #include <google/malloc_extension_c.h>
41 41
42 int main(int argc, char** argv) { 42 int main(int argc, char** argv) {
43 void* a = malloc(1000); 43 void* a = malloc(1000);
44 44
45 size_t cxx_bytes_used, c_bytes_used; 45 size_t cxx_bytes_used, c_bytes_used;
46 CHECK(MallocExtension::instance()->GetNumericProperty( 46 ASSERT_TRUE(MallocExtension::instance()->GetNumericProperty(
47 "generic.current_allocated_bytes", &cxx_bytes_used)); 47 "generic.current_allocated_bytes", &cxx_bytes_used));
48 CHECK(MallocExtension_GetNumericProperty( 48 ASSERT_TRUE(MallocExtension_GetNumericProperty(
49 "generic.current_allocated_bytes", &c_bytes_used)); 49 "generic.current_allocated_bytes", &c_bytes_used));
50 CHECK_GT(cxx_bytes_used, 1000); 50 ASSERT_GT(cxx_bytes_used, 1000);
51 CHECK_EQ(cxx_bytes_used, c_bytes_used); 51 ASSERT_EQ(cxx_bytes_used, c_bytes_used);
52 52
53 CHECK(MallocExtension::instance()->VerifyAllMemory()); 53 ASSERT_TRUE(MallocExtension::instance()->VerifyAllMemory());
54 CHECK(MallocExtension_VerifyAllMemory()); 54 ASSERT_TRUE(MallocExtension_VerifyAllMemory());
55 55
56 CHECK_GE(MallocExtension::instance()->GetAllocatedSize(a), 1000); 56 ASSERT_GE(MallocExtension::instance()->GetAllocatedSize(a), 1000);
57 // This is just a sanity check. If we allocated too much, tcmalloc is broken 57 // This is just a sanity check. If we allocated too much, tcmalloc is broken
58 CHECK_LE(MallocExtension::instance()->GetAllocatedSize(a), 5000); 58 ASSERT_LE(MallocExtension::instance()->GetAllocatedSize(a), 5000);
59 CHECK_GE(MallocExtension::instance()->GetEstimatedAllocatedSize(1000), 1000); 59 ASSERT_GE(MallocExtension::instance()->GetEstimatedAllocatedSize(1000), 1000);
60 60
61 for (int i = 0; i < 10; ++i) { 61 for (int i = 0; i < 10; ++i) {
62 void *p = malloc(i); 62 void *p = malloc(i);
63 CHECK_GE(MallocExtension::instance()->GetAllocatedSize(p), 63 ASSERT_GE(MallocExtension::instance()->GetAllocatedSize(p),
64 MallocExtension::instance()->GetEstimatedAllocatedSize(i)); 64 MallocExtension::instance()->GetEstimatedAllocatedSize(i));
65 free(p); 65 free(p);
66 } 66 }
67 67
68 // Check the c-shim version too. 68 // Check the c-shim version too.
69 CHECK_GE(MallocExtension_GetAllocatedSize(a), 1000); 69 ASSERT_GE(MallocExtension_GetAllocatedSize(a), 1000);
70 CHECK_LE(MallocExtension_GetAllocatedSize(a), 5000); 70 ASSERT_LE(MallocExtension_GetAllocatedSize(a), 5000);
71 CHECK_GE(MallocExtension_GetEstimatedAllocatedSize(1000), 1000); 71 ASSERT_GE(MallocExtension_GetEstimatedAllocatedSize(1000), 1000);
72 72
73 free(a); 73 free(a);
74 74
75 printf("DONE\n"); 75 printf("DONE\n");
76 return 0; 76 return 0;
77 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698