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

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 1412193007: Fix Dart_GlobalTimelineGetTrace to null terminate the string (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9544 matching lines...) Expand 10 before | Expand all | Expand 10 after
9555 9555
9556 // Grab the trace. 9556 // Grab the trace.
9557 AppendData data; 9557 AppendData data;
9558 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data); 9558 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data);
9559 EXPECT(success); 9559 EXPECT(success);
9560 buffer = reinterpret_cast<char*>(data.buffer); 9560 buffer = reinterpret_cast<char*>(data.buffer);
9561 buffer_length = data.buffer_length; 9561 buffer_length = data.buffer_length;
9562 EXPECT(buffer_length > 0); 9562 EXPECT(buffer_length > 0);
9563 EXPECT(buffer != NULL); 9563 EXPECT(buffer != NULL);
9564 9564
9565 // Response starts with a '{' character and not a '['.
9566 EXPECT(buffer[0] == '{');
9567 // Response ends with a '}' character and not a ']'.
9568 EXPECT(buffer[buffer_length - 1] == '\0');
9569 EXPECT(buffer[buffer_length - 2] == '}');
9570
9565 // Heartbeat test. 9571 // Heartbeat test.
9566 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); 9572 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer);
9567 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); 9573 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer);
9568 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); 9574 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer);
9569 9575
9570 // Free buffer allocated by AppendStreamConsumer 9576 // Free buffer allocated by AppendStreamConsumer
9571 free(data.buffer); 9577 free(data.buffer);
9572 } 9578 }
9573 9579
9574 9580
(...skipping 27 matching lines...) Expand all
9602 AppendData data; 9608 AppendData data;
9603 data.buffer = NULL; 9609 data.buffer = NULL;
9604 data.buffer_length = 0; 9610 data.buffer_length = 0;
9605 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data); 9611 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data);
9606 EXPECT(success); 9612 EXPECT(success);
9607 buffer = reinterpret_cast<char*>(data.buffer); 9613 buffer = reinterpret_cast<char*>(data.buffer);
9608 buffer_length = data.buffer_length; 9614 buffer_length = data.buffer_length;
9609 EXPECT(buffer_length > 0); 9615 EXPECT(buffer_length > 0);
9610 EXPECT(buffer != NULL); 9616 EXPECT(buffer != NULL);
9611 9617
9618 // Response starts with a '{' character and not a '['.
9619 EXPECT(buffer[0] == '{');
9620 // Response ends with a '}' character and not a ']'.
9621 EXPECT(buffer[buffer_length - 1] == '\0');
9622 EXPECT(buffer[buffer_length - 2] == '}');
9623
9612 // Heartbeat test. 9624 // Heartbeat test.
9613 EXPECT_SUBSTRING("\"cat\":\"Dart\"", buffer); 9625 EXPECT_SUBSTRING("\"cat\":\"Dart\"", buffer);
9614 EXPECT_SUBSTRING("\"name\":\"DART_NAME\"", buffer); 9626 EXPECT_SUBSTRING("\"name\":\"DART_NAME\"", buffer);
9615 9627
9616 // Free buffer allocated by AppendStreamConsumer 9628 // Free buffer allocated by AppendStreamConsumer
9617 free(data.buffer); 9629 free(data.buffer);
9618 } 9630 }
9619 9631
9620 9632
9621 TEST_CASE(Timeline_Dart_TimelineGetTraceWithDartEvents) { 9633 TEST_CASE(Timeline_Dart_TimelineGetTraceWithDartEvents) {
(...skipping 25 matching lines...) Expand all
9647 9659
9648 // Grab the trace. 9660 // Grab the trace.
9649 AppendData data; 9661 AppendData data;
9650 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data); 9662 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data);
9651 EXPECT(success); 9663 EXPECT(success);
9652 buffer = reinterpret_cast<char*>(data.buffer); 9664 buffer = reinterpret_cast<char*>(data.buffer);
9653 buffer_length = data.buffer_length; 9665 buffer_length = data.buffer_length;
9654 EXPECT(buffer_length > 0); 9666 EXPECT(buffer_length > 0);
9655 EXPECT(buffer != NULL); 9667 EXPECT(buffer != NULL);
9656 9668
9669 // Response starts with a '{' character and not a '['.
9670 EXPECT(buffer[0] == '{');
9671 // Response ends with a '}' character and not a ']'.
9672 EXPECT(buffer[buffer_length - 1] == '\0');
9673 EXPECT(buffer[buffer_length - 2] == '}');
9674
9657 // Heartbeat test. 9675 // Heartbeat test.
9658 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); 9676 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer);
9659 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); 9677 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer);
9660 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); 9678 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer);
9661 EXPECT_SUBSTRING("\"cat\":\"Dart\"", buffer); 9679 EXPECT_SUBSTRING("\"cat\":\"Dart\"", buffer);
9662 EXPECT_SUBSTRING("\"name\":\"DART_NAME\"", buffer); 9680 EXPECT_SUBSTRING("\"name\":\"DART_NAME\"", buffer);
9663 9681
9664 // Free buffer allocated by AppendStreamConsumer 9682 // Free buffer allocated by AppendStreamConsumer
9665 free(data.buffer); 9683 free(data.buffer);
9666 } 9684 }
(...skipping 23 matching lines...) Expand all
9690 9708
9691 // Grab the trace. 9709 // Grab the trace.
9692 AppendData data; 9710 AppendData data;
9693 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data); 9711 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data);
9694 EXPECT(success); 9712 EXPECT(success);
9695 buffer = reinterpret_cast<char*>(data.buffer); 9713 buffer = reinterpret_cast<char*>(data.buffer);
9696 buffer_length = data.buffer_length; 9714 buffer_length = data.buffer_length;
9697 EXPECT(buffer_length > 0); 9715 EXPECT(buffer_length > 0);
9698 EXPECT(buffer != NULL); 9716 EXPECT(buffer != NULL);
9699 9717
9718 // Response starts with a '{' character and not a '['.
9719 EXPECT(buffer[0] == '{');
9720 // Response ends with a '}' character and not a ']'.
9721 EXPECT(buffer[buffer_length - 1] == '\0');
9722 EXPECT(buffer[buffer_length - 2] == '}');
9723
9700 // Heartbeat test. 9724 // Heartbeat test.
9701 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); 9725 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer);
9702 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); 9726 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer);
9703 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); 9727 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer);
9704 9728
9705 // Free buffer allocated by AppendStreamConsumer 9729 // Free buffer allocated by AppendStreamConsumer
9706 free(data.buffer); 9730 free(data.buffer);
9707 } 9731 }
9708 9732
9709 9733
(...skipping 28 matching lines...) Expand all
9738 9762
9739 // Grab the global trace. 9763 // Grab the global trace.
9740 AppendData data; 9764 AppendData data;
9741 success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data); 9765 success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data);
9742 EXPECT(success); 9766 EXPECT(success);
9743 buffer = reinterpret_cast<char*>(data.buffer); 9767 buffer = reinterpret_cast<char*>(data.buffer);
9744 buffer_length = data.buffer_length; 9768 buffer_length = data.buffer_length;
9745 EXPECT(buffer_length > 0); 9769 EXPECT(buffer_length > 0);
9746 EXPECT(buffer != NULL); 9770 EXPECT(buffer != NULL);
9747 9771
9772 // Response starts with a '{' character and not a '['.
9773 EXPECT(buffer[0] == '{');
9774 // Response ends with a '}' character and not a ']'.
9775 EXPECT(buffer[buffer_length - 1] == '\0');
9776 EXPECT(buffer[buffer_length - 2] == '}');
9777
9748 // Heartbeat test. 9778 // Heartbeat test.
9749 EXPECT_SUBSTRING("\"name\":\"TestVMDuration\"", buffer); 9779 EXPECT_SUBSTRING("\"name\":\"TestVMDuration\"", buffer);
9750 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); 9780 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer);
9751 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); 9781 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer);
9752 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); 9782 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer);
9753 EXPECT_NOTSUBSTRING("\"function\":\"::_bar\"", buffer); 9783 EXPECT_NOTSUBSTRING("\"function\":\"::_bar\"", buffer);
9754 9784
9755 // Free buffer allocated by AppendStreamConsumer 9785 // Free buffer allocated by AppendStreamConsumer
9756 free(data.buffer); 9786 free(data.buffer);
9757 data.buffer = NULL; 9787 data.buffer = NULL;
(...skipping 14 matching lines...) Expand all
9772 NULL); 9802 NULL);
9773 } 9803 }
9774 9804
9775 // Grab the global trace. 9805 // Grab the global trace.
9776 success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data); 9806 success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data);
9777 EXPECT(success); 9807 EXPECT(success);
9778 buffer = reinterpret_cast<char*>(data.buffer); 9808 buffer = reinterpret_cast<char*>(data.buffer);
9779 buffer_length = data.buffer_length; 9809 buffer_length = data.buffer_length;
9780 EXPECT(buffer_length > 0); 9810 EXPECT(buffer_length > 0);
9781 EXPECT(buffer != NULL); 9811 EXPECT(buffer != NULL);
9812 // Response starts with a '{' character and not a '['.
9813 EXPECT(buffer[0] == '{');
9814 // Response ends with a '}' character and not a ']'.
9815 EXPECT(buffer[buffer_length - 1] == '\0');
9816 EXPECT(buffer[buffer_length - 2] == '}');
9782 9817
9783 // Heartbeat test for old events. 9818 // Heartbeat test for old events.
9784 EXPECT_SUBSTRING("\"name\":\"TestVMDuration\"", buffer); 9819 EXPECT_SUBSTRING("\"name\":\"TestVMDuration\"", buffer);
9785 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); 9820 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer);
9786 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); 9821 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer);
9787 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); 9822 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer);
9788 9823
9789 // Heartbeat test for new events. 9824 // Heartbeat test for new events.
9790 EXPECT_SUBSTRING("\"name\":\"TestVMDuration2\"", buffer); 9825 EXPECT_SUBSTRING("\"name\":\"TestVMDuration2\"", buffer);
9791 EXPECT_SUBSTRING("\"function\":\"::_bar\"", buffer); 9826 EXPECT_SUBSTRING("\"function\":\"::_bar\"", buffer);
9792 9827
9793 // Free buffer allocated by AppendStreamConsumer 9828 // Free buffer allocated by AppendStreamConsumer
9794 free(data.buffer); 9829 free(data.buffer);
9795 } 9830 }
9796 9831
9797 } // namespace dart 9832 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698