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

Unified Diff: test/cctest/libplatform/test-tracing.cc

Issue 2200113003: [Tracing] V8 Tracing Controller - Fix async trace event bug (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix windows pointer output Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/libplatform/tracing/trace-writer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/libplatform/test-tracing.cc
diff --git a/test/cctest/libplatform/test-tracing.cc b/test/cctest/libplatform/test-tracing.cc
index 5cb788c10097af7aa7036258eff8cd5fb8381de1..a79a90861269b7cfcda60f74bb4a79beec312b36 100644
--- a/test/cctest/libplatform/test-tracing.cc
+++ b/test/cctest/libplatform/test-tracing.cc
@@ -309,6 +309,52 @@ TEST(TestTracingControllerMultipleArgsAndCopy) {
i::V8::SetPlatformForTesting(old_platform);
}
+TEST(TestAsyncTraceEvent) {
fmeawad 2016/08/03 06:48:02 All test names are based on Classes and not trace
rskang 2016/08/03 20:41:45 Done.
+ std::ostringstream stream;
+ v8::Platform* old_platform = i::V8::GetCurrentPlatform();
+ v8::Platform* default_platform = v8::platform::CreateDefaultPlatform();
+ i::V8::SetPlatformForTesting(default_platform);
+
+ uint64_t x = 0xdeadbeef5;
+ uint64_t* p = &x;
+
+ // Create a scope for the tracing controller to terminate the trace writer.
+ {
+ TracingController tracing_controller;
+ platform::SetTracingController(default_platform, &tracing_controller);
+ TraceWriter* writer = TraceWriter::CreateJSONTraceWriter(stream);
+
+ TraceBuffer* ring_buffer =
+ TraceBuffer::CreateTraceBufferRingBuffer(1, writer);
+ tracing_controller.Initialize(ring_buffer);
+ TraceConfig* trace_config = new TraceConfig();
+ trace_config->AddIncludedCategory("v8");
+ tracing_controller.StartTracing(trace_config);
+
+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("v8", "Test1", x);
+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("v8", "Test2", p);
fmeawad 2016/08/03 06:48:02 Can you add an END for these trace events?
rskang 2016/08/03 20:41:45 Not needed after merging into TestJSONTraceWriter.
+
+ tracing_controller.StopTracing();
+ }
+
+ std::string trace_str = stream.str();
+
+ std::vector<std::string> all_ids, all_ts;
+ GetJSONStrings(all_ids, trace_str, "\"id\"", "\"", "\"");
+ GetJSONStrings(all_ts, trace_str, "\"ts\"", ":", ",");
+
+ CHECK_EQ(all_ids.size(), 2);
+ CHECK_EQ(all_ids[0], "0xdeadbeef5");
+ std::ostringstream pointer_stream;
+ pointer_stream << "0x" << std::hex << reinterpret_cast<uint64_t>(&x);
+ CHECK_EQ(all_ids[1], pointer_stream.str());
+
+ // Ensure decimal values did not get corrupted due to hex ids.
+ CHECK(std::all_of(all_ts[1].begin() + 1, all_ts[1].end() - 1, isdigit));
+
+ i::V8::SetPlatformForTesting(old_platform);
+}
+
} // namespace tracing
} // namespace platform
} // namespace v8
« no previous file with comments | « src/libplatform/tracing/trace-writer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698