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

Unified Diff: third_party/tcmalloc/chromium/src/tests/system-alloc_unittest.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/system-alloc_unittest.cc
diff --git a/third_party/tcmalloc/chromium/src/tests/system-alloc_unittest.cc b/third_party/tcmalloc/chromium/src/tests/system-alloc_unittest.cc
index c006425d707fcad02099261e1e6ebccb4f820c3f..f0259a19b2a26fa4b3213db78716d40bf9026f77 100644
--- a/third_party/tcmalloc/chromium/src/tests/system-alloc_unittest.cc
+++ b/third_party/tcmalloc/chromium/src/tests/system-alloc_unittest.cc
@@ -40,8 +40,9 @@
#endif
#include <sys/types.h>
#include <algorithm>
+#include <limits>
#include "base/logging.h" // for Check_GEImpl, Check_LTImpl, etc
-#include <google/malloc_extension.h> // for MallocExtension::instance
+#include <gperftools/malloc_extension.h> // for MallocExtension::instance
#include "common.h" // for kAddressBits
class ArraySysAllocator : public SysAllocator {
@@ -83,7 +84,6 @@ public:
void DumpStats() {
}
- void FlagsInitialized() {}
private:
static const int kArraySize = 8 * 1024 * 1024;
@@ -115,14 +115,30 @@ TEST(AddressBits, CpuVirtualBits) {
const int kPointerBits = 8 * sizeof(void*);
const int kImplementedVirtualBits = NumImplementedVirtualBits();
- CHECK_GE(kAddressBits, min(kImplementedVirtualBits, kPointerBits));
+ CHECK_GE(kAddressBits, std::min(kImplementedVirtualBits, kPointerBits));
}
#endif
static void TestBasicRetryFailTest() {
// Check with the allocator still works after a failed allocation.
- void* p = malloc(1ULL << 50); // Asking for 1P ram
- CHECK(p == NULL);
+ //
+ // There is no way to call malloc and guarantee it will fail. malloc takes a
+ // size_t parameter and the C++ standard does not constrain the size of
+ // size_t. For example, consider an implementation where size_t is 32 bits
+ // and pointers are 64 bits.
+ //
+ // It is likely, though, that sizeof(size_t) == sizeof(void*). In that case,
+ // the first allocation here might succeed but the second allocation must
+ // fail.
+ //
+ // If the second allocation succeeds, you will have to rewrite or
+ // disable this test.
+ // The weird parens are to avoid macro-expansion of 'max' on windows.
+ const size_t kHugeSize = (std::numeric_limits<size_t>::max)() / 2;
+ void* p1 = malloc(kHugeSize);
+ void* p2 = malloc(kHugeSize);
+ CHECK(p2 == NULL);
+ if (p1 != NULL) free(p1);
char* q = new char[1024];
CHECK(q != NULL);

Powered by Google App Engine
This is Rietveld 408576698