| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | 7 |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 // Be a good citizen and clean up after ourselves. This also re-enables the | 643 // Be a good citizen and clean up after ourselves. This also re-enables the |
| 644 // idle-shutdown behavior. | 644 // idle-shutdown behavior. |
| 645 StackSamplingProfiler::TestAPI::Reset(); | 645 StackSamplingProfiler::TestAPI::Reset(); |
| 646 } | 646 } |
| 647 }; | 647 }; |
| 648 | 648 |
| 649 } // namespace | 649 } // namespace |
| 650 | 650 |
| 651 // Checks that the basic expected information is present in a sampled call stack | 651 // Checks that the basic expected information is present in a sampled call stack |
| 652 // profile. | 652 // profile. |
| 653 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 653 // macOS ASAN is not yet supported - crbug.com/718628. |
| 654 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) && \ |
| 655 !(defined(ADDRESS_SANITIZER) && defined(OS_MACOSX)) |
| 654 #define MAYBE_Basic Basic | 656 #define MAYBE_Basic Basic |
| 655 #else | 657 #else |
| 656 #define MAYBE_Basic DISABLED_Basic | 658 #define MAYBE_Basic DISABLED_Basic |
| 657 #endif | 659 #endif |
| 658 TEST_F(StackSamplingProfilerTest, MAYBE_Basic) { | 660 TEST_F(StackSamplingProfilerTest, MAYBE_Basic) { |
| 659 SamplingParams params; | 661 SamplingParams params; |
| 660 params.sampling_interval = TimeDelta::FromMilliseconds(0); | 662 params.sampling_interval = TimeDelta::FromMilliseconds(0); |
| 661 params.samples_per_burst = 1; | 663 params.samples_per_burst = 1; |
| 662 | 664 |
| 663 std::vector<CallStackProfile> profiles; | 665 std::vector<CallStackProfile> profiles; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 CaptureProfiles(params, AVeryLongTimeDelta(), &profiles2); | 723 CaptureProfiles(params, AVeryLongTimeDelta(), &profiles2); |
| 722 ASSERT_EQ(1u, profiles2.size()); | 724 ASSERT_EQ(1u, profiles2.size()); |
| 723 const CallStackProfile& profile2 = profiles2[0]; | 725 const CallStackProfile& profile2 = profiles2[0]; |
| 724 ASSERT_EQ(1u, profile2.samples.size()); | 726 ASSERT_EQ(1u, profile2.samples.size()); |
| 725 const Sample& sample2 = profile2.samples[0]; | 727 const Sample& sample2 = profile2.samples[0]; |
| 726 EXPECT_EQ(sample1.process_milestones | (1u << 2), sample2.process_milestones); | 728 EXPECT_EQ(sample1.process_milestones | (1u << 2), sample2.process_milestones); |
| 727 } | 729 } |
| 728 | 730 |
| 729 // Checks that the profiler handles stacks containing dynamically-allocated | 731 // Checks that the profiler handles stacks containing dynamically-allocated |
| 730 // stack memory. | 732 // stack memory. |
| 731 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 733 // macOS ASAN is not yet supported - crbug.com/718628. |
| 734 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) && \ |
| 735 !(defined(ADDRESS_SANITIZER) && defined(OS_MACOSX)) |
| 732 #define MAYBE_Alloca Alloca | 736 #define MAYBE_Alloca Alloca |
| 733 #else | 737 #else |
| 734 #define MAYBE_Alloca DISABLED_Alloca | 738 #define MAYBE_Alloca DISABLED_Alloca |
| 735 #endif | 739 #endif |
| 736 TEST_F(StackSamplingProfilerTest, MAYBE_Alloca) { | 740 TEST_F(StackSamplingProfilerTest, MAYBE_Alloca) { |
| 737 SamplingParams params; | 741 SamplingParams params; |
| 738 params.sampling_interval = TimeDelta::FromMilliseconds(0); | 742 params.sampling_interval = TimeDelta::FromMilliseconds(0); |
| 739 params.samples_per_burst = 1; | 743 params.samples_per_burst = 1; |
| 740 | 744 |
| 741 std::vector<CallStackProfile> profiles; | 745 std::vector<CallStackProfile> profiles; |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 // Stop and destroy all profilers, always in the same order. Don't crash. | 1356 // Stop and destroy all profilers, always in the same order. Don't crash. |
| 1353 for (size_t i = 0; i < profiler_infos.size(); ++i) | 1357 for (size_t i = 0; i < profiler_infos.size(); ++i) |
| 1354 profiler_infos[i]->profiler.Stop(); | 1358 profiler_infos[i]->profiler.Stop(); |
| 1355 for (size_t i = 0; i < profiler_infos.size(); ++i) | 1359 for (size_t i = 0; i < profiler_infos.size(); ++i) |
| 1356 profiler_infos[i].reset(); | 1360 profiler_infos[i].reset(); |
| 1357 }); | 1361 }); |
| 1358 } | 1362 } |
| 1359 | 1363 |
| 1360 // Checks that a stack that runs through another library produces a stack with | 1364 // Checks that a stack that runs through another library produces a stack with |
| 1361 // the expected functions. | 1365 // the expected functions. |
| 1362 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 1366 // macOS ASAN is not yet supported - crbug.com/718628. |
| 1367 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) && \ |
| 1368 !(defined(ADDRESS_SANITIZER) && defined(OS_MACOSX)) |
| 1363 #define MAYBE_OtherLibrary OtherLibrary | 1369 #define MAYBE_OtherLibrary OtherLibrary |
| 1364 #else | 1370 #else |
| 1365 #define MAYBE_OtherLibrary DISABLED_OtherLibrary | 1371 #define MAYBE_OtherLibrary DISABLED_OtherLibrary |
| 1366 #endif | 1372 #endif |
| 1367 TEST_F(StackSamplingProfilerTest, MAYBE_OtherLibrary) { | 1373 TEST_F(StackSamplingProfilerTest, MAYBE_OtherLibrary) { |
| 1368 SamplingParams params; | 1374 SamplingParams params; |
| 1369 params.sampling_interval = TimeDelta::FromMilliseconds(0); | 1375 params.sampling_interval = TimeDelta::FromMilliseconds(0); |
| 1370 params.samples_per_burst = 1; | 1376 params.samples_per_burst = 1; |
| 1371 | 1377 |
| 1372 std::vector<CallStackProfile> profiles; | 1378 std::vector<CallStackProfile> profiles; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 #define MAYBE_UnloadingLibrary UnloadingLibrary | 1441 #define MAYBE_UnloadingLibrary UnloadingLibrary |
| 1436 #else | 1442 #else |
| 1437 #define MAYBE_UnloadingLibrary DISABLED_UnloadingLibrary | 1443 #define MAYBE_UnloadingLibrary DISABLED_UnloadingLibrary |
| 1438 #endif | 1444 #endif |
| 1439 TEST_F(StackSamplingProfilerTest, MAYBE_UnloadingLibrary) { | 1445 TEST_F(StackSamplingProfilerTest, MAYBE_UnloadingLibrary) { |
| 1440 TestLibraryUnload(false); | 1446 TestLibraryUnload(false); |
| 1441 } | 1447 } |
| 1442 | 1448 |
| 1443 // Checks that a stack that runs through a library that has been unloaded | 1449 // Checks that a stack that runs through a library that has been unloaded |
| 1444 // produces a stack, and doesn't crash. | 1450 // produces a stack, and doesn't crash. |
| 1445 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 1451 // macOS ASAN is not yet supported - crbug.com/718628. |
| 1452 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) && \ |
| 1453 !(defined(ADDRESS_SANITIZER) && defined(OS_MACOSX)) |
| 1446 #define MAYBE_UnloadedLibrary UnloadedLibrary | 1454 #define MAYBE_UnloadedLibrary UnloadedLibrary |
| 1447 #else | 1455 #else |
| 1448 #define MAYBE_UnloadedLibrary DISABLED_UnloadedLibrary | 1456 #define MAYBE_UnloadedLibrary DISABLED_UnloadedLibrary |
| 1449 #endif | 1457 #endif |
| 1450 TEST_F(StackSamplingProfilerTest, MAYBE_UnloadedLibrary) { | 1458 TEST_F(StackSamplingProfilerTest, MAYBE_UnloadedLibrary) { |
| 1451 TestLibraryUnload(true); | 1459 TestLibraryUnload(true); |
| 1452 } | 1460 } |
| 1453 | 1461 |
| 1454 // Checks that different threads can be sampled in parallel. | 1462 // Checks that different threads can be sampled in parallel. |
| 1455 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 1463 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 EXPECT_EQ(9u, profiler_thread1.profiles()[0].samples.size()); | 1598 EXPECT_EQ(9u, profiler_thread1.profiles()[0].samples.size()); |
| 1591 ASSERT_EQ(1u, profiler_thread2.profiles().size()); | 1599 ASSERT_EQ(1u, profiler_thread2.profiles().size()); |
| 1592 EXPECT_EQ(8u, profiler_thread2.profiles()[0].samples.size()); | 1600 EXPECT_EQ(8u, profiler_thread2.profiles()[0].samples.size()); |
| 1593 | 1601 |
| 1594 profiler_thread1.Join(); | 1602 profiler_thread1.Join(); |
| 1595 profiler_thread2.Join(); | 1603 profiler_thread2.Join(); |
| 1596 }); | 1604 }); |
| 1597 } | 1605 } |
| 1598 | 1606 |
| 1599 } // namespace base | 1607 } // namespace base |
| OLD | NEW |