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 "base/trace_event/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "base/threading/sequenced_task_runner_handle.h" | 25 #include "base/threading/sequenced_task_runner_handle.h" |
26 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
27 #include "base/threading/thread.h" | 27 #include "base/threading/thread.h" |
28 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
29 #include "base/trace_event/memory_dump_provider.h" | 29 #include "base/trace_event/memory_dump_provider.h" |
30 #include "base/trace_event/memory_dump_scheduler.h" | 30 #include "base/trace_event/memory_dump_scheduler.h" |
31 #include "base/trace_event/memory_infra_background_whitelist.h" | 31 #include "base/trace_event/memory_infra_background_whitelist.h" |
32 #include "base/trace_event/process_memory_dump.h" | 32 #include "base/trace_event/process_memory_dump.h" |
33 #include "base/trace_event/trace_buffer.h" | 33 #include "base/trace_event/trace_buffer.h" |
34 #include "base/trace_event/trace_config_memory_test_util.h" | 34 #include "base/trace_event/trace_config_memory_test_util.h" |
| 35 #include "build/build_config.h" |
35 #include "testing/gmock/include/gmock/gmock.h" | 36 #include "testing/gmock/include/gmock/gmock.h" |
36 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
37 | 38 |
38 using testing::_; | 39 using testing::_; |
39 using testing::AnyNumber; | 40 using testing::AnyNumber; |
40 using testing::AtMost; | 41 using testing::AtMost; |
41 using testing::Between; | 42 using testing::Between; |
42 using testing::Invoke; | 43 using testing::Invoke; |
43 using testing::Return; | 44 using testing::Return; |
44 | 45 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); | 433 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); |
433 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true)); | 434 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true)); |
434 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true)); | 435 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true)); |
435 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, | 436 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, |
436 MemoryDumpLevelOfDetail::DETAILED); | 437 MemoryDumpLevelOfDetail::DETAILED); |
437 DisableTracing(); | 438 DisableTracing(); |
438 } | 439 } |
439 | 440 |
440 // Checks that the dump provider invocations depend only on the current | 441 // Checks that the dump provider invocations depend only on the current |
441 // registration state and not on previous registrations and dumps. | 442 // registration state and not on previous registrations and dumps. |
442 // flaky: crbug.com/706874 | 443 // Flaky on iOS, see crbug.com/706874 |
443 TEST_F(MemoryDumpManagerTest, DISABLED_RegistrationConsistency) { | 444 #if defined(OS_IOS) |
| 445 #define MAYBE_RegistrationConsistency DISABLED_RegistrationConsistency |
| 446 #else |
| 447 #define MAYBE_RegistrationConsistency RegistrationConsistency |
| 448 #endif |
| 449 TEST_F(MemoryDumpManagerTest, MAYBE_RegistrationConsistency) { |
444 InitializeMemoryDumpManager(false /* is_coordinator */); | 450 InitializeMemoryDumpManager(false /* is_coordinator */); |
445 MockMemoryDumpProvider mdp; | 451 MockMemoryDumpProvider mdp; |
446 | 452 |
447 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); | 453 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); |
448 | 454 |
449 { | 455 { |
450 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); | 456 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); |
451 EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true)); | 457 EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true)); |
452 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 458 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
453 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, | 459 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 | 1013 |
1008 EnableTracingWithTraceConfig( | 1014 EnableTracingWithTraceConfig( |
1009 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers( | 1015 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers( |
1010 kLightDumpPeriodMs, kHeavyDumpPeriodMs)); | 1016 kLightDumpPeriodMs, kHeavyDumpPeriodMs)); |
1011 run_loop.Run(); | 1017 run_loop.Run(); |
1012 DisableTracing(); | 1018 DisableTracing(); |
1013 } | 1019 } |
1014 | 1020 |
1015 // Tests against race conditions that might arise when disabling tracing in the | 1021 // Tests against race conditions that might arise when disabling tracing in the |
1016 // middle of a global memory dump. | 1022 // middle of a global memory dump. |
1017 // flaky: crbug.com/706874 | 1023 // Flaky on iOS, see crbug.com/706961 |
1018 TEST_F(MemoryDumpManagerTest, DISABLED_DisableTracingWhileDumping) { | 1024 #if defined(OS_IOS) |
| 1025 #define MAYBE_DisableTracingWhileDumping DISABLED_DisableTracingWhileDumping |
| 1026 #else |
| 1027 #define MAYBE_DisableTracingWhileDumping DisableTracingWhileDumping |
| 1028 #endif |
| 1029 TEST_F(MemoryDumpManagerTest, MAYBE_DisableTracingWhileDumping) { |
1019 base::WaitableEvent tracing_disabled_event( | 1030 base::WaitableEvent tracing_disabled_event( |
1020 WaitableEvent::ResetPolicy::AUTOMATIC, | 1031 WaitableEvent::ResetPolicy::AUTOMATIC, |
1021 WaitableEvent::InitialState::NOT_SIGNALED); | 1032 WaitableEvent::InitialState::NOT_SIGNALED); |
1022 InitializeMemoryDumpManager(false /* is_coordinator */); | 1033 InitializeMemoryDumpManager(false /* is_coordinator */); |
1023 | 1034 |
1024 // Register a bound dump provider. | 1035 // Register a bound dump provider. |
1025 std::unique_ptr<Thread> mdp_thread(new Thread("test thread")); | 1036 std::unique_ptr<Thread> mdp_thread(new Thread("test thread")); |
1026 mdp_thread->Start(); | 1037 mdp_thread->Start(); |
1027 MockMemoryDumpProvider mdp_with_affinity; | 1038 MockMemoryDumpProvider mdp_with_affinity; |
1028 RegisterDumpProvider(&mdp_with_affinity, mdp_thread->task_runner(), | 1039 RegisterDumpProvider(&mdp_with_affinity, mdp_thread->task_runner(), |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 thread.Start(); | 1302 thread.Start(); |
1292 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions, | 1303 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions, |
1293 "BlacklistTestDumpProvider"); | 1304 "BlacklistTestDumpProvider"); |
1294 // Unregistering on wrong thread should not crash. | 1305 // Unregistering on wrong thread should not crash. |
1295 mdm_->UnregisterDumpProvider(&mdp1); | 1306 mdm_->UnregisterDumpProvider(&mdp1); |
1296 thread.Stop(); | 1307 thread.Stop(); |
1297 } | 1308 } |
1298 | 1309 |
1299 } // namespace trace_event | 1310 } // namespace trace_event |
1300 } // namespace base | 1311 } // namespace base |
OLD | NEW |