Index: runtime/vm/dart_api_impl_test.cc |
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc |
index bf4ec2add62afb18e9fc350f8097b5ce0683b49b..92ace20d1cd49c5fa1ce4e22a20441bbdcc05719 100644 |
--- a/runtime/vm/dart_api_impl_test.cc |
+++ b/runtime/vm/dart_api_impl_test.cc |
@@ -9441,4 +9441,46 @@ TEST_CASE(Timeline_Dart_TimelineGetTrace) { |
free(data.buffer); |
} |
+ |
+TEST_CASE(Timeline_Dart_TimelineGetTraceGlobalOverride) { |
+ const char* kScriptChars = |
+ "foo() => 'a';\n" |
+ "main() => foo();\n"; |
+ |
+ Dart_Handle lib = |
+ TestCase::LoadTestScript(kScriptChars, NULL); |
+ |
+ const char* buffer = NULL; |
+ intptr_t buffer_length = 0; |
+ bool success = false; |
+ |
+ // Enable recording of all streams across the entire vm. |
+ Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL); |
+ |
+ // Invoke main, which will be compiled resulting in a compiler event in |
+ // the timeline. |
+ Dart_Handle result = Dart_Invoke(lib, |
+ NewString("main"), |
+ 0, |
+ NULL); |
+ EXPECT_VALID(result); |
+ |
+ // Grab the trace. |
+ AppendData data; |
+ success = Dart_TimelineGetTrace(AppendStreamConsumer, &data); |
+ EXPECT(success); |
+ buffer = reinterpret_cast<char*>(data.buffer); |
+ buffer_length = data.buffer_length; |
+ EXPECT(buffer_length > 0); |
+ EXPECT(buffer != NULL); |
+ |
+ // Heartbeat test. |
+ EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); |
+ EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); |
+ EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); |
+ |
+ // Free buffer allocated by AppendStreamConsumer |
+ free(data.buffer); |
+} |
+ |
} // namespace dart |