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

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

Issue 2367603002: [tracing] Support ConvertableToTraceFormat argument type. (Closed)
Patch Set: Fix layout tests failures & reland. Created 4 years, 3 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/tracing/trace-event.h ('k') | test/cctest/test-trace-event.cc » ('j') | 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 2e15d6af9e0e356f256b00eb0784fb248db196d3..b2579cecd53b03befee7433007674df6da2b58eb 100644
--- a/test/cctest/libplatform/test-tracing.cc
+++ b/test/cctest/libplatform/test-tracing.cc
@@ -35,7 +35,8 @@ TEST(TestTraceObject) {
TraceObject trace_object;
uint8_t category_enabled_flag = 41;
trace_object.Initialize('X', &category_enabled_flag, "Test.Trace",
- "Test.Scope", 42, 123, 0, NULL, NULL, NULL, 0);
+ "Test.Scope", 42, 123, 0, nullptr, nullptr, nullptr,
+ nullptr, 0);
CHECK_EQ('X', trace_object.phase());
CHECK_EQ(category_enabled_flag, *trace_object.category_enabled_flag());
CHECK_EQ(std::string("Test.Trace"), std::string(trace_object.name()));
@@ -44,6 +45,19 @@ TEST(TestTraceObject) {
CHECK_EQ(0, trace_object.cpu_duration());
}
+class ConvertableToTraceFormatMock : public v8::ConvertableToTraceFormat {
+ public:
+ explicit ConvertableToTraceFormatMock(int value) : value_(value) {}
+ void AppendAsTraceFormat(std::string* out) const override {
+ *out += "[" + std::to_string(value_) + "," + std::to_string(value_) + "]";
+ }
+
+ private:
+ int value_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConvertableToTraceFormatMock);
+};
+
class MockTraceWriter : public TraceWriter {
public:
void AppendTraceEvent(TraceObject* trace_event) override {
@@ -75,7 +89,8 @@ TEST(TestTraceBufferRingBuffer) {
TraceObject* trace_object = ring_buffer->AddTraceEvent(&handles[i]);
CHECK_NOT_NULL(trace_object);
trace_object->Initialize('X', &category_enabled_flag, names[i].c_str(),
- "Test.Scope", 42, 123, 0, NULL, NULL, NULL, 0);
+ "Test.Scope", 42, 123, 0, nullptr, nullptr,
+ nullptr, nullptr, 0);
trace_object = ring_buffer->GetEventByHandle(handles[i]);
CHECK_NOT_NULL(trace_object);
CHECK_EQ('X', trace_object->phase());
@@ -128,13 +143,13 @@ TEST(TestJSONTraceWriter) {
TraceObject trace_object;
trace_object.InitializeForTesting(
'X', tracing_controller.GetCategoryGroupEnabled("v8-cat"), "Test0",
- v8::internal::tracing::kGlobalScope, 42, 123, 0, NULL, NULL, NULL,
- TRACE_EVENT_FLAG_HAS_ID, 11, 22, 100, 50, 33, 44);
+ v8::internal::tracing::kGlobalScope, 42, 123, 0, nullptr, nullptr,
+ nullptr, nullptr, TRACE_EVENT_FLAG_HAS_ID, 11, 22, 100, 50, 33, 44);
writer->AppendTraceEvent(&trace_object);
trace_object.InitializeForTesting(
'Y', tracing_controller.GetCategoryGroupEnabled("v8-cat"), "Test1",
- v8::internal::tracing::kGlobalScope, 43, 456, 0, NULL, NULL, NULL, 0,
- 55, 66, 110, 55, 77, 88);
+ v8::internal::tracing::kGlobalScope, 43, 456, 0, nullptr, nullptr,
+ nullptr, nullptr, 0, 55, 66, 110, 55, 77, 88);
writer->AppendTraceEvent(&trace_object);
tracing_controller.StopTracing();
}
@@ -264,6 +279,14 @@ TEST(TestTracingControllerMultipleArgsAndCopy) {
mm = "CHANGED";
mmm = "CHANGED";
+ TRACE_EVENT_INSTANT1("v8", "v8.Test", TRACE_EVENT_SCOPE_THREAD, "a1",
+ new ConvertableToTraceFormatMock(42));
+ std::unique_ptr<ConvertableToTraceFormatMock> trace_event_arg(
+ new ConvertableToTraceFormatMock(42));
+ TRACE_EVENT_INSTANT2("v8", "v8.Test", TRACE_EVENT_SCOPE_THREAD, "a1",
+ std::move(trace_event_arg), "a2",
+ new ConvertableToTraceFormatMock(123));
+
tracing_controller.StopTracing();
}
@@ -274,7 +297,7 @@ TEST(TestTracingControllerMultipleArgsAndCopy) {
GetJSONStrings(all_names, trace_str, "\"name\"", "\"", "\"");
GetJSONStrings(all_cats, trace_str, "\"cat\"", "\"", "\"");
- CHECK_EQ(all_args.size(), 22);
+ CHECK_EQ(all_args.size(), 24);
CHECK_EQ(all_args[0], "\"aa\":11");
CHECK_EQ(all_args[1], "\"bb\":22");
CHECK_EQ(all_args[2], "\"cc\":33");
@@ -303,6 +326,8 @@ TEST(TestTracingControllerMultipleArgsAndCopy) {
CHECK_EQ(all_names[20], "INIT");
CHECK_EQ(all_names[21], "INIT");
CHECK_EQ(all_args[21], "\"mm1\":\"INIT\",\"mm2\":\"\\\"INIT\\\"\"");
+ CHECK_EQ(all_args[22], "\"a1\":[42,42]");
+ CHECK_EQ(all_args[23], "\"a1\":[42,42],\"a2\":[123,123]");
i::V8::SetPlatformForTesting(old_platform);
}
« no previous file with comments | « src/tracing/trace-event.h ('k') | test/cctest/test-trace-event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698