| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 #include <limits> | 4 #include <limits> |
| 5 | 5 |
| 6 #include "include/libplatform/v8-tracing.h" | 6 #include "include/libplatform/v8-tracing.h" |
| 7 #include "src/tracing/trace-event.h" | 7 #include "src/tracing/trace-event.h" |
| 8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 TraceBuffer* ring_buffer = | 121 TraceBuffer* ring_buffer = |
| 122 TraceBuffer::CreateTraceBufferRingBuffer(1, writer); | 122 TraceBuffer::CreateTraceBufferRingBuffer(1, writer); |
| 123 tracing_controller.Initialize(ring_buffer); | 123 tracing_controller.Initialize(ring_buffer); |
| 124 TraceConfig* trace_config = new TraceConfig(); | 124 TraceConfig* trace_config = new TraceConfig(); |
| 125 trace_config->AddIncludedCategory("v8-cat"); | 125 trace_config->AddIncludedCategory("v8-cat"); |
| 126 tracing_controller.StartTracing(trace_config); | 126 tracing_controller.StartTracing(trace_config); |
| 127 | 127 |
| 128 TraceObject trace_object; | 128 TraceObject trace_object; |
| 129 trace_object.InitializeForTesting( | 129 trace_object.InitializeForTesting( |
| 130 'X', tracing_controller.GetCategoryGroupEnabled("v8-cat"), "Test0", | 130 'X', tracing_controller.GetCategoryGroupEnabled("v8-cat"), "Test0", |
| 131 v8::internal::tracing::kGlobalScope, 42, 123, 0, NULL, NULL, NULL, 0, | 131 v8::internal::tracing::kGlobalScope, 42, 123, 0, NULL, NULL, NULL, |
| 132 11, 22, 100, 50, 33, 44); | 132 TRACE_EVENT_FLAG_HAS_ID, 11, 22, 100, 50, 33, 44); |
| 133 writer->AppendTraceEvent(&trace_object); | 133 writer->AppendTraceEvent(&trace_object); |
| 134 trace_object.InitializeForTesting( | 134 trace_object.InitializeForTesting( |
| 135 'Y', tracing_controller.GetCategoryGroupEnabled("v8-cat"), "Test1", | 135 'Y', tracing_controller.GetCategoryGroupEnabled("v8-cat"), "Test1", |
| 136 v8::internal::tracing::kGlobalScope, 43, 456, 0, NULL, NULL, NULL, 0, | 136 v8::internal::tracing::kGlobalScope, 43, 456, 0, NULL, NULL, NULL, 0, |
| 137 55, 66, 110, 55, 77, 88); | 137 55, 66, 110, 55, 77, 88); |
| 138 writer->AppendTraceEvent(&trace_object); | 138 writer->AppendTraceEvent(&trace_object); |
| 139 tracing_controller.StopTracing(); | 139 tracing_controller.StopTracing(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 std::string trace_str = stream.str(); | 142 std::string trace_str = stream.str(); |
| 143 std::string expected_trace_str = | 143 std::string expected_trace_str = |
| 144 "{\"traceEvents\":[{\"pid\":11,\"tid\":22,\"ts\":100,\"tts\":50," | 144 "{\"traceEvents\":[{\"pid\":11,\"tid\":22,\"ts\":100,\"tts\":50," |
| 145 "\"ph\":\"X\",\"cat\":\"v8-cat\",\"name\":\"Test0\",\"dur\":33," | 145 "\"ph\":\"X\",\"cat\":\"v8-cat\",\"name\":\"Test0\",\"dur\":33," |
| 146 "\"tdur\":44,\"args\":{}},{\"pid\":55,\"tid\":66,\"ts\":110,\"tts\":55," | 146 "\"tdur\":44,\"id\":\"0x2a\",\"args\":{}},{\"pid\":55,\"tid\":66," |
| 147 "\"ph\":\"Y\",\"cat\":\"v8-cat\",\"name\":\"Test1\",\"dur\":77," | 147 "\"ts\":110,\"tts\":55,\"ph\":\"Y\",\"cat\":\"v8-cat\",\"name\":" |
| 148 "\"tdur\":88,\"args\":{}}]}"; | 148 "\"Test1\",\"dur\":77,\"tdur\":88,\"args\":{}}]}"; |
| 149 | 149 |
| 150 CHECK_EQ(expected_trace_str, trace_str); | 150 CHECK_EQ(expected_trace_str, trace_str); |
| 151 | 151 |
| 152 i::V8::SetPlatformForTesting(old_platform); | 152 i::V8::SetPlatformForTesting(old_platform); |
| 153 } | 153 } |
| 154 | 154 |
| 155 TEST(TestTracingController) { | 155 TEST(TestTracingController) { |
| 156 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); | 156 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); |
| 157 v8::Platform* default_platform = v8::platform::CreateDefaultPlatform(); | 157 v8::Platform* default_platform = v8::platform::CreateDefaultPlatform(); |
| 158 i::V8::SetPlatformForTesting(default_platform); | 158 i::V8::SetPlatformForTesting(default_platform); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 CHECK_EQ(all_args[21], "\"INIT\":\"INIT\""); | 305 CHECK_EQ(all_args[21], "\"INIT\":\"INIT\""); |
| 306 CHECK_EQ(all_names[22], "INIT"); | 306 CHECK_EQ(all_names[22], "INIT"); |
| 307 CHECK_EQ(all_args[22], "\"INIT\":\"INIT\",\"INIT\":\"INIT\""); | 307 CHECK_EQ(all_args[22], "\"INIT\":\"INIT\",\"INIT\":\"INIT\""); |
| 308 | 308 |
| 309 i::V8::SetPlatformForTesting(old_platform); | 309 i::V8::SetPlatformForTesting(old_platform); |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace tracing | 312 } // namespace tracing |
| 313 } // namespace platform | 313 } // namespace platform |
| 314 } // namespace v8 | 314 } // namespace v8 |
| OLD | NEW |