OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "bin/builtin.h" | 5 #include "bin/builtin.h" |
6 #include "include/dart_api.h" | 6 #include "include/dart_api.h" |
7 #include "include/dart_mirrors_api.h" | 7 #include "include/dart_mirrors_api.h" |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "include/dart_tools_api.h" | 9 #include "include/dart_tools_api.h" |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 9423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9434 | 9434 |
9435 // Heartbeat test. | 9435 // Heartbeat test. |
9436 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); | 9436 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); |
9437 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); | 9437 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); |
9438 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); | 9438 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); |
9439 | 9439 |
9440 // Free buffer allocated by AppendStreamConsumer | 9440 // Free buffer allocated by AppendStreamConsumer |
9441 free(data.buffer); | 9441 free(data.buffer); |
9442 } | 9442 } |
9443 | 9443 |
| 9444 |
| 9445 TEST_CASE(Timeline_Dart_TimelineGetTraceGlobalOverride) { |
| 9446 const char* kScriptChars = |
| 9447 "foo() => 'a';\n" |
| 9448 "main() => foo();\n"; |
| 9449 |
| 9450 Dart_Handle lib = |
| 9451 TestCase::LoadTestScript(kScriptChars, NULL); |
| 9452 |
| 9453 const char* buffer = NULL; |
| 9454 intptr_t buffer_length = 0; |
| 9455 bool success = false; |
| 9456 |
| 9457 // Enable recording of all streams across the entire vm. |
| 9458 Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL); |
| 9459 |
| 9460 // Invoke main, which will be compiled resulting in a compiler event in |
| 9461 // the timeline. |
| 9462 Dart_Handle result = Dart_Invoke(lib, |
| 9463 NewString("main"), |
| 9464 0, |
| 9465 NULL); |
| 9466 EXPECT_VALID(result); |
| 9467 |
| 9468 // Grab the trace. |
| 9469 AppendData data; |
| 9470 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data); |
| 9471 EXPECT(success); |
| 9472 buffer = reinterpret_cast<char*>(data.buffer); |
| 9473 buffer_length = data.buffer_length; |
| 9474 EXPECT(buffer_length > 0); |
| 9475 EXPECT(buffer != NULL); |
| 9476 |
| 9477 // Heartbeat test. |
| 9478 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); |
| 9479 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); |
| 9480 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); |
| 9481 |
| 9482 // Free buffer allocated by AppendStreamConsumer |
| 9483 free(data.buffer); |
| 9484 } |
| 9485 |
9444 } // namespace dart | 9486 } // namespace dart |
OLD | NEW |