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

Side by Side Diff: base/process_util_unittest.cc

Issue 660118: Merge the LINUX_TC_MALLOC #define with the existing TC_MALLOC #define.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/process_util_linux.cc ('k') | build/build_config.h » ('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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 return 0; 244 return 0;
245 } 245 }
246 246
247 int ProcessUtilTest::CountOpenFDsInChild() { 247 int ProcessUtilTest::CountOpenFDsInChild() {
248 int fds[2]; 248 int fds[2];
249 if (pipe(fds) < 0) 249 if (pipe(fds) < 0)
250 NOTREACHED(); 250 NOTREACHED();
251 251
252 file_handle_mapping_vector fd_mapping_vec; 252 file_handle_mapping_vector fd_mapping_vec;
253 fd_mapping_vec.push_back(std::pair<int,int>(fds[1], kChildPipe)); 253 fd_mapping_vec.push_back(std::pair<int, int>(fds[1], kChildPipe));
254 ProcessHandle handle = this->SpawnChild(L"ProcessUtilsLeakFDChildProcess", 254 ProcessHandle handle = this->SpawnChild(L"ProcessUtilsLeakFDChildProcess",
255 fd_mapping_vec, 255 fd_mapping_vec,
256 false); 256 false);
257 CHECK(handle); 257 CHECK(handle);
258 int ret = HANDLE_EINTR(close(fds[1])); 258 int ret = HANDLE_EINTR(close(fds[1]));
259 DPCHECK(ret == 0); 259 DPCHECK(ret == 0);
260 260
261 // Read number of open files in client process from pipe; 261 // Read number of open files in client process from pipe;
262 int num_open_files = -1; 262 int num_open_files = -1;
263 ssize_t bytes_read = 263 ssize_t bytes_read =
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 401
402 EXPECT_EQ(0, ParseProcStatCPU(kSelfStat)); 402 EXPECT_EQ(0, ParseProcStatCPU(kSelfStat));
403 } 403 }
404 #endif 404 #endif
405 405
406 #endif // defined(OS_POSIX) 406 #endif // defined(OS_POSIX)
407 407
408 // TODO(vandebo) make this work on Windows and Mac too. 408 // TODO(vandebo) make this work on Windows and Mac too.
409 #if defined(OS_LINUX) 409 #if defined(OS_LINUX)
410 410
411 #if defined(LINUX_USE_TCMALLOC) 411 #if defined(USE_TCMALLOC)
412 extern "C" { 412 extern "C" {
413 int tc_set_new_mode(int mode); 413 int tc_set_new_mode(int mode);
414 } 414 }
415 #endif // defined(LINUX_USE_TCMALLOC) 415 #endif // defined(USE_TCMALLOC)
416 416
417 class OutOfMemoryTest : public testing::Test { 417 class OutOfMemoryTest : public testing::Test {
418 public: 418 public:
419 OutOfMemoryTest() 419 OutOfMemoryTest()
420 : value_(NULL), 420 : value_(NULL),
421 // Make test size as large as possible minus a few pages so 421 // Make test size as large as possible minus a few pages so
422 // that alignment or other rounding doesn't make it wrap. 422 // that alignment or other rounding doesn't make it wrap.
423 test_size_(std::numeric_limits<std::size_t>::max() - 8192) { 423 test_size_(std::numeric_limits<std::size_t>::max() - 8192) {
424 } 424 }
425 425
426 virtual void SetUp() { 426 virtual void SetUp() {
427 // Must call EnableTerminationOnOutOfMemory() because that is called from 427 // Must call EnableTerminationOnOutOfMemory() because that is called from
428 // chrome's main function and therefore hasn't been called yet. 428 // chrome's main function and therefore hasn't been called yet.
429 EnableTerminationOnOutOfMemory(); 429 EnableTerminationOnOutOfMemory();
430 #if defined(LINUX_USE_TCMALLOC) 430 #if defined(USE_TCMALLOC)
431 tc_set_new_mode(1); 431 tc_set_new_mode(1);
432 } 432 }
433 433
434 virtual void TearDown() { 434 virtual void TearDown() {
435 tc_set_new_mode(0); 435 tc_set_new_mode(0);
436 #endif // defined(LINUX_USE_TCMALLOC) 436 #endif // defined(USE_TCMALLOC)
437 } 437 }
438 438
439 void* value_; 439 void* value_;
440 size_t test_size_; 440 size_t test_size_;
441 }; 441 };
442 442
443 TEST_F(OutOfMemoryTest, New) { 443 TEST_F(OutOfMemoryTest, New) {
444 ASSERT_DEATH(value_ = new char[test_size_], ""); 444 ASSERT_DEATH(value_ = new char[test_size_], "");
445 } 445 }
446 446
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 TEST_F(OutOfMemoryTest, Posix_memalign) { 481 TEST_F(OutOfMemoryTest, Posix_memalign) {
482 // Grab the return value of posix_memalign to silence a compiler warning 482 // Grab the return value of posix_memalign to silence a compiler warning
483 // about unused return values. We don't actually care about the return 483 // about unused return values. We don't actually care about the return
484 // value, since we're asserting death. 484 // value, since we're asserting death.
485 ASSERT_DEATH(EXPECT_EQ(ENOMEM, posix_memalign(&value_, 8, test_size_)), ""); 485 ASSERT_DEATH(EXPECT_EQ(ENOMEM, posix_memalign(&value_, 8, test_size_)), "");
486 } 486 }
487 487
488 #endif // defined(OS_LINUX) 488 #endif // defined(OS_LINUX)
489 489
490 } // namespace base 490 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_linux.cc ('k') | build/build_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698