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

Side by Side Diff: base/process_util_unittest.cc

Issue 399081: Enable TCMalloc on Linux by default. (Closed)
Patch Set: Oops, remove unintended change. Created 11 years 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
« no previous file with comments | « base/process_util_linux.cc ('k') | build/common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/eintr_wrapper.h" 10 #include "base/eintr_wrapper.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 "0 0 0 0 " // <- No CPU, apparently. 357 "0 0 0 0 " // <- No CPU, apparently.
358 "16 0 1 0 1676099790 2957312 114 4294967295 134512640 134528148 " 358 "16 0 1 0 1676099790 2957312 114 4294967295 134512640 134528148 "
359 "3221224832 3221224344 3086339742 0 0 0 0 0 0 0 17 0 0 0"; 359 "3221224832 3221224344 3086339742 0 0 0 0 0 0 0 17 0 0 0";
360 360
361 EXPECT_EQ(0, ParseProcStatCPU(kSelfStat)); 361 EXPECT_EQ(0, ParseProcStatCPU(kSelfStat));
362 } 362 }
363 #endif 363 #endif
364 364
365 #endif // defined(OS_POSIX) 365 #endif // defined(OS_POSIX)
366 366
367 // TODO(vandebo) make this work on Windows and Mac too.
367 #if defined(OS_LINUX) 368 #if defined(OS_LINUX)
368 // TODO(vandebo) make this work on Windows and Mac too. 369
370 #if defined(LINUX_USE_TCMALLOC)
371 extern "C" {
372 int tc_set_new_mode(int mode);
373 }
374 #endif // defined(LINUX_USE_TCMALLOC)
369 375
370 class OutOfMemoryTest : public testing::Test { 376 class OutOfMemoryTest : public testing::Test {
371 public: 377 public:
372 OutOfMemoryTest() 378 OutOfMemoryTest()
373 : value_(NULL), 379 : value_(NULL),
374 // Make test size as large as possible minus a few pages so 380 // Make test size as large as possible minus a few pages so
375 // that alignment or other rounding doesn't make it wrap. 381 // that alignment or other rounding doesn't make it wrap.
376 test_size_(std::numeric_limits<std::size_t>::max() - 8192) { 382 test_size_(std::numeric_limits<std::size_t>::max() - 8192) {
377 } 383 }
378 384
379 virtual void SetUp() { 385 virtual void SetUp() {
380 // Must call EnableTerminationOnOutOfMemory() because that is called from 386 // Must call EnableTerminationOnOutOfMemory() because that is called from
381 // chrome's main function and therefore hasn't been called yet. 387 // chrome's main function and therefore hasn't been called yet.
382 EnableTerminationOnOutOfMemory(); 388 EnableTerminationOnOutOfMemory();
389 #if defined(LINUX_USE_TCMALLOC)
390 tc_set_new_mode(1);
391 }
392
393 virtual void TearDown() {
394 tc_set_new_mode(0);
395 #endif // defined(LINUX_USE_TCMALLOC)
383 } 396 }
384 397
385 void* value_; 398 void* value_;
386 size_t test_size_; 399 size_t test_size_;
387 }; 400 };
388 401
389 TEST_F(OutOfMemoryTest, New) { 402 TEST_F(OutOfMemoryTest, New) {
390 ASSERT_DEATH(value_ = new char[test_size_], ""); 403 ASSERT_DEATH(value_ = new char[test_size_], "");
391 } 404 }
392 405
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 ASSERT_DEATH(value_ = __libc_pvalloc(test_size_), ""); 462 ASSERT_DEATH(value_ = __libc_pvalloc(test_size_), "");
450 } 463 }
451 464
452 TEST_F(OutOfMemoryTest, __libc_memalign) { 465 TEST_F(OutOfMemoryTest, __libc_memalign) {
453 ASSERT_DEATH(value_ = __libc_memalign(4, test_size_), ""); 466 ASSERT_DEATH(value_ = __libc_memalign(4, test_size_), "");
454 } 467 }
455 468
456 #endif // defined(OS_LINUX) 469 #endif // defined(OS_LINUX)
457 470
458 } // namespace base 471 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_linux.cc ('k') | build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698