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

Unified Diff: base/profiler/stack_sampling_profiler_unittest.cc

Issue 2680703004: Wait for sampling to complete before destructing. (Closed)
Patch Set: cleanup, comments, and fixes Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/profiler/stack_sampling_profiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/profiler/stack_sampling_profiler_unittest.cc
diff --git a/base/profiler/stack_sampling_profiler_unittest.cc b/base/profiler/stack_sampling_profiler_unittest.cc
index e1f09e13f7abfcfa29f8101ae3ac093e73379a8a..179dafa89d5253b0b1e06447127867959a0bdce3 100644
--- a/base/profiler/stack_sampling_profiler_unittest.cc
+++ b/base/profiler/stack_sampling_profiler_unittest.cc
@@ -393,6 +393,8 @@ void CaptureProfiles(const SamplingParams& params, TimeDelta profiler_wait_time,
WithTargetThread([&params, profiles,
profiler_wait_time](PlatformThreadId target_thread_id) {
+ WaitableEvent profiler_completed(WaitableEvent::ResetPolicy::MANUAL,
+ WaitableEvent::InitialState::NOT_SIGNALED);
WaitableEvent sampling_thread_completed(
WaitableEvent::ResetPolicy::MANUAL,
WaitableEvent::InitialState::NOT_SIGNALED);
@@ -402,8 +404,9 @@ void CaptureProfiles(const SamplingParams& params, TimeDelta profiler_wait_time,
StackSamplingProfiler profiler(target_thread_id, params, callback);
profiler.Start();
sampling_thread_completed.TimedWait(profiler_wait_time);
- profiler.Stop();
- sampling_thread_completed.Wait();
+ profiler.Stop(&profiler_completed);
+ profiler_completed.Wait();
+ ASSERT_TRUE(sampling_thread_completed.IsSignaled());
});
}
@@ -765,35 +768,6 @@ TEST(StackSamplingProfilerTest, MAYBE_Alloca) {
<< FormatSampleForDiagnosticOutput(sample, profile.modules);
}
-// Checks that the fire-and-forget interface works.
-#if defined(STACK_SAMPLING_PROFILER_SUPPORTED)
-#define MAYBE_StartAndRunAsync StartAndRunAsync
-#else
-#define MAYBE_StartAndRunAsync DISABLED_StartAndRunAsync
-#endif
-TEST(StackSamplingProfilerTest, MAYBE_StartAndRunAsync) {
- // StartAndRunAsync requires the caller to have a message loop.
- MessageLoop message_loop;
-
- SamplingParams params;
- params.samples_per_burst = 1;
-
- CallStackProfiles profiles;
- WithTargetThread([&params, &profiles](PlatformThreadId target_thread_id) {
- WaitableEvent sampling_thread_completed(
- WaitableEvent::ResetPolicy::AUTOMATIC,
- WaitableEvent::InitialState::NOT_SIGNALED);
- const StackSamplingProfiler::CompletedCallback callback =
- Bind(&SaveProfilesAndSignalEvent, Unretained(&profiles),
- Unretained(&sampling_thread_completed));
- StackSamplingProfiler::StartAndRunAsync(target_thread_id, params, callback);
- RunLoop().RunUntilIdle();
- sampling_thread_completed.Wait();
- });
-
- ASSERT_EQ(1u, profiles.size());
-}
-
// Checks that the expected number of profiles and samples are present in the
// call stack profiles produced.
#if defined(STACK_SAMPLING_PROFILER_SUPPORTED)
@@ -898,6 +872,7 @@ TEST(StackSamplingProfilerTest, MAYBE_DestroyProfilerWhileProfiling) {
});
}
+#if 0 // Not currently supported.
// Checks that we can destroy the thread under test while profiling.
#if defined(STACK_SAMPLING_PROFILER_SUPPORTED)
#define MAYBE_DestroyThreadWhileProfiling DestroyThreadWhileProfiling
@@ -951,7 +926,7 @@ TEST(StackSamplingProfilerTest, MAYBE_DestroyThreadWhileProfiling) {
thread_sampled.Wait();
// Stop sampling and wait for it to finish.
- profiler.Stop();
+ profiler.Stop(nullptr);
sampling_thread_completed.Wait();
// There should be one profile in which the first sample has frames and
@@ -960,6 +935,7 @@ TEST(StackSamplingProfilerTest, MAYBE_DestroyThreadWhileProfiling) {
EXPECT_NE(0U, profiles[0].samples.front().frames.size());
EXPECT_EQ(0U, profiles[0].samples.back().frames.size());
}
+#endif
// Checks that the same profiler may be run multiple times.
#if defined(STACK_SAMPLING_PROFILER_SUPPORTED)
« no previous file with comments | « base/profiler/stack_sampling_profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698