OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <string.h> | 7 #include <string.h> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 #ifdef __LP64__ | 427 #ifdef __LP64__ |
428 TEST_F(HeapProfilerTest, Test64Bit) { | 428 TEST_F(HeapProfilerTest, Test64Bit) { |
429 StackTrace st1 = GenStackTrace(8, 0x0); | 429 StackTrace st1 = GenStackTrace(8, 0x0); |
430 StackTrace st2 = GenStackTrace(10, 0x7fffffff70000000L); | 430 StackTrace st2 = GenStackTrace(10, 0x7fffffff70000000L); |
431 StackTrace st3 = GenStackTrace(10, 0xffffffff70000000L); | 431 StackTrace st3 = GenStackTrace(10, 0xffffffff70000000L); |
432 heap_profiler_alloc((void*)0x1000, 4096, st1.frames, st1.depth, 0); | 432 heap_profiler_alloc((void*)0x1000, 4096, st1.frames, st1.depth, 0); |
433 heap_profiler_alloc( | 433 heap_profiler_alloc( |
434 (void*)0x7ffffffffffff000L, 4096, st2.frames, st2.depth, 0); | 434 (void*)0x7ffffffffffff000L, 4096, st2.frames, st2.depth, 0); |
435 heap_profiler_alloc( | 435 heap_profiler_alloc( |
436 (void*)0xfffffffffffff000L, 4096, st3.frames, st3.depth, 0); | 436 (void*)0xfffffffffffff000L, 4096, st3.frames, st3.depth, 0); |
437 EXPECT_EQ(3, stats_.num_allocs); | 437 EXPECT_EQ(3u, stats_.num_allocs); |
438 EXPECT_EQ(3, stats_.num_stack_traces); | 438 EXPECT_EQ(3u, stats_.num_stack_traces); |
439 EXPECT_EQ(4096u + 4096 + 4096, stats_.total_alloc_bytes); | 439 EXPECT_EQ(4096u + 4096 + 4096, stats_.total_alloc_bytes); |
440 | 440 |
441 heap_profiler_free((void*)0x1000, 4096, NULL); | 441 heap_profiler_free((void*)0x1000, 4096, NULL); |
442 EXPECT_EQ(2u, stats_.num_allocs); | 442 EXPECT_EQ(2u, stats_.num_allocs); |
443 EXPECT_EQ(2u, stats_.num_stack_traces); | 443 EXPECT_EQ(2u, stats_.num_stack_traces); |
444 EXPECT_EQ(4096u + 4096, stats_.total_alloc_bytes); | 444 EXPECT_EQ(4096u + 4096, stats_.total_alloc_bytes); |
445 | 445 |
446 heap_profiler_free((void*)0x7ffffffffffff000L, 4096, NULL); | 446 heap_profiler_free((void*)0x7ffffffffffff000L, 4096, NULL); |
447 EXPECT_EQ(1u, stats_.num_allocs); | 447 EXPECT_EQ(1u, stats_.num_allocs); |
448 EXPECT_EQ(1u, stats_.num_stack_traces); | 448 EXPECT_EQ(1u, stats_.num_stack_traces); |
449 EXPECT_EQ(4096u, stats_.total_alloc_bytes); | 449 EXPECT_EQ(4096u, stats_.total_alloc_bytes); |
450 | 450 |
451 heap_profiler_free((void*)0xfffffffffffff000L, 4096, NULL); | 451 heap_profiler_free((void*)0xfffffffffffff000L, 4096, NULL); |
452 EXPECT_EQ(0u, stats_.num_allocs); | 452 EXPECT_EQ(0u, stats_.num_allocs); |
453 EXPECT_EQ(0u, stats_.num_stack_traces); | 453 EXPECT_EQ(0u, stats_.num_stack_traces); |
454 EXPECT_EQ(0u, stats_.total_alloc_bytes); | 454 EXPECT_EQ(0u, stats_.total_alloc_bytes); |
455 } | 455 } |
456 #endif | 456 #endif |
457 | 457 |
458 } // namespace | 458 } // namespace |
OLD | NEW |