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 9465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9476 | 9476 |
9477 // Heartbeat test. | 9477 // Heartbeat test. |
9478 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); | 9478 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); |
9479 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); | 9479 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); |
9480 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); | 9480 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); |
9481 | 9481 |
9482 // Free buffer allocated by AppendStreamConsumer | 9482 // Free buffer allocated by AppendStreamConsumer |
9483 free(data.buffer); | 9483 free(data.buffer); |
9484 } | 9484 } |
9485 | 9485 |
| 9486 |
| 9487 UNIT_TEST_CASE(Timeline_Dart_GlobalTimelineGetTrace) { |
| 9488 const char* buffer = NULL; |
| 9489 intptr_t buffer_length = 0; |
| 9490 bool success = false; |
| 9491 |
| 9492 // Enable all streams. |
| 9493 Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL | |
| 9494 DART_TIMELINE_STREAM_VM); |
| 9495 { |
| 9496 // Create isolate. |
| 9497 TestIsolateScope __test_isolate__; |
| 9498 Thread* __thread__ = Thread::Current(); |
| 9499 ASSERT(__thread__->isolate() == __test_isolate__.isolate()); |
| 9500 StackZone __zone__(__thread__); |
| 9501 HandleScope __hs__(__thread__); |
| 9502 |
| 9503 // Load test script. |
| 9504 const char* kScriptChars = |
| 9505 "foo() => 'a';\n" |
| 9506 "main() => foo();\n"; |
| 9507 |
| 9508 Dart_Handle lib = |
| 9509 TestCase::LoadTestScript(kScriptChars, NULL); |
| 9510 |
| 9511 // Invoke main, which will be compiled resulting in a compiler event in |
| 9512 // the timeline. |
| 9513 Dart_Handle result = Dart_Invoke(lib, |
| 9514 NewString("main"), |
| 9515 0, |
| 9516 NULL); |
| 9517 EXPECT_VALID(result); |
| 9518 } |
| 9519 |
| 9520 // Isolate is shutdown now. |
| 9521 // Grab the global trace. |
| 9522 AppendData data; |
| 9523 success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data); |
| 9524 EXPECT(success); |
| 9525 buffer = reinterpret_cast<char*>(data.buffer); |
| 9526 buffer_length = data.buffer_length; |
| 9527 EXPECT(buffer_length > 0); |
| 9528 EXPECT(buffer != NULL); |
| 9529 |
| 9530 // Heartbeat test. |
| 9531 EXPECT_SUBSTRING("\"name\":\"InitializeIsolate\"", buffer); |
| 9532 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); |
| 9533 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); |
| 9534 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); |
| 9535 |
| 9536 // Free buffer allocated by AppendStreamConsumer |
| 9537 free(data.buffer); |
| 9538 } |
| 9539 |
9486 } // namespace dart | 9540 } // namespace dart |
OLD | NEW |