Bug 1598992 - Add test for profile hand-off from Base to Gecko Profiler - r=gregtatum

Differential Revision: https://phabricator.services.mozilla.com/D54446

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gerald Squelart 2019-11-26 23:01:14 +00:00
Родитель c62ee84686
Коммит 6550e4931e
1 изменённых файлов: 49 добавлений и 0 удалений

Просмотреть файл

@ -1722,3 +1722,52 @@ TEST(GeckoProfiler, PostSamplingCallback)
ASSERT_TRUE(!profiler_callback_after_sampling(
[&](SamplingState) { ASSERT_TRUE(false); }));
}
#ifdef MOZ_BASE_PROFILER
TEST(GeckoProfiler, BaseProfilerHandOff)
{
const char* filters[] = {"GeckoMain"};
ASSERT_TRUE(!baseprofiler::profiler_is_active());
ASSERT_TRUE(!profiler_is_active());
// Start the Base Profiler.
baseprofiler::profiler_start(
PROFILER_DEFAULT_ENTRIES, PROFILER_DEFAULT_INTERVAL,
ProfilerFeature::StackWalk, filters, MOZ_ARRAY_LENGTH(filters));
ASSERT_TRUE(baseprofiler::profiler_is_active());
ASSERT_TRUE(!profiler_is_active());
// Add at least a marker, which should go straight into the buffer.
Maybe<baseprofiler::ProfilerBufferInfo> info0 =
baseprofiler::profiler_get_buffer_info();
BASE_PROFILER_ADD_MARKER("Marker from base profiler", OTHER);
Maybe<baseprofiler::ProfilerBufferInfo> info1 =
baseprofiler::profiler_get_buffer_info();
ASSERT_GT(info1->mRangeEnd, info0->mRangeEnd);
// Start the Gecko Profiler, which should grab the Base Profiler profile and
// stop it.
profiler_start(PROFILER_DEFAULT_ENTRIES, PROFILER_DEFAULT_INTERVAL,
ProfilerFeature::StackWalk, filters,
MOZ_ARRAY_LENGTH(filters));
ASSERT_TRUE(!baseprofiler::profiler_is_active());
ASSERT_TRUE(profiler_is_active());
// Write some Gecko Profiler samples.
ASSERT_EQ(WaitForSamplingState(), SamplingState::SamplingCompleted);
// Check that the Gecko Profiler profile contains at least the Base Profiler
// main thread samples.
UniquePtr<char[]> profile = profiler_get_profile();
ASSERT_TRUE(profile);
ASSERT_TRUE(profile[0] == '{');
ASSERT_TRUE(strstr(profile.get(), "GeckoMain (pre-xul)"));
ASSERT_TRUE(strstr(profile.get(), "Marker from base profiler"));
profiler_stop();
ASSERT_TRUE(!profiler_is_active());
}
#endif // MOZ_BASE_PROFILER