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

Side by Side Diff: test/cctest/libplatform/test-tracing.cc

Issue 2309943005: [Tracing] Minor bug fixes related to trace serialization (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/libplatform/tracing/trace-writer.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 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 int16_t gg = -77; 210 int16_t gg = -77;
211 signed char hh = -88; 211 signed char hh = -88;
212 bool ii1 = true; 212 bool ii1 = true;
213 bool ii2 = false; 213 bool ii2 = false;
214 double jj1 = 99.0; 214 double jj1 = 99.0;
215 double jj2 = 1e100; 215 double jj2 = 1e100;
216 double jj3 = std::numeric_limits<double>::quiet_NaN(); 216 double jj3 = std::numeric_limits<double>::quiet_NaN();
217 double jj4 = std::numeric_limits<double>::infinity(); 217 double jj4 = std::numeric_limits<double>::infinity();
218 double jj5 = -std::numeric_limits<double>::infinity(); 218 double jj5 = -std::numeric_limits<double>::infinity();
219 void* kk = &aa; 219 void* kk = &aa;
220 const char* ll = "\"100\""; 220 const char* ll = "100";
221 std::string mm = "INIT"; 221 std::string mm = "INIT";
222 std::string mmm = "\"INIT\""; 222 std::string mmm = "\"INIT\"";
223 223
224 // Create a scope for the tracing controller to terminate the trace writer. 224 // Create a scope for the tracing controller to terminate the trace writer.
225 { 225 {
226 TracingController tracing_controller; 226 TracingController tracing_controller;
227 platform::SetTracingController(default_platform, &tracing_controller); 227 platform::SetTracingController(default_platform, &tracing_controller);
228 TraceWriter* writer = TraceWriter::CreateJSONTraceWriter(stream); 228 TraceWriter* writer = TraceWriter::CreateJSONTraceWriter(stream);
229 229
230 TraceBuffer* ring_buffer = 230 TraceBuffer* ring_buffer =
(...skipping 16 matching lines...) Expand all
247 TRACE_EVENT1("v8", "v8.Test.jj1", "jj1", jj1); 247 TRACE_EVENT1("v8", "v8.Test.jj1", "jj1", jj1);
248 TRACE_EVENT1("v8", "v8.Test.jj2", "jj2", jj2); 248 TRACE_EVENT1("v8", "v8.Test.jj2", "jj2", jj2);
249 TRACE_EVENT1("v8", "v8.Test.jj3", "jj3", jj3); 249 TRACE_EVENT1("v8", "v8.Test.jj3", "jj3", jj3);
250 TRACE_EVENT1("v8", "v8.Test.jj4", "jj4", jj4); 250 TRACE_EVENT1("v8", "v8.Test.jj4", "jj4", jj4);
251 TRACE_EVENT1("v8", "v8.Test.jj5", "jj5", jj5); 251 TRACE_EVENT1("v8", "v8.Test.jj5", "jj5", jj5);
252 TRACE_EVENT1("v8", "v8.Test.kk", "kk", kk); 252 TRACE_EVENT1("v8", "v8.Test.kk", "kk", kk);
253 TRACE_EVENT1("v8", "v8.Test.ll", "ll", ll); 253 TRACE_EVENT1("v8", "v8.Test.ll", "ll", ll);
254 TRACE_EVENT1("v8", "v8.Test.mm", "mm", TRACE_STR_COPY(mmm.c_str())); 254 TRACE_EVENT1("v8", "v8.Test.mm", "mm", TRACE_STR_COPY(mmm.c_str()));
255 255
256 TRACE_EVENT2("v8", "v8.Test2.1", "aa", aa, "ll", ll); 256 TRACE_EVENT2("v8", "v8.Test2.1", "aa", aa, "ll", ll);
257 TRACE_EVENT2("v8", "v8.Test2.2", "mm1", TRACE_STR_COPY(mmm.c_str()), "mm2", 257 TRACE_EVENT2("v8", "v8.Test2.2", "mm1", TRACE_STR_COPY(mm.c_str()), "mm2",
258 TRACE_STR_COPY(mmm.c_str())); 258 TRACE_STR_COPY(mmm.c_str()));
259 259
260 // Check copies are correct. 260 // Check copies are correct.
261 TRACE_EVENT_COPY_INSTANT0("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD); 261 TRACE_EVENT_COPY_INSTANT0("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD);
262 TRACE_EVENT_COPY_INSTANT1("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD, 262 TRACE_EVENT_COPY_INSTANT2("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD, "mm1",
263 mm.c_str(), mmm.c_str()); 263 mm.c_str(), "mm2", mmm.c_str());
264 TRACE_EVENT_COPY_INSTANT2("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD,
265 mm.c_str(), mmm.c_str(), mm.c_str(), mmm.c_str());
266 mm = "CHANGED"; 264 mm = "CHANGED";
267 mmm = "CHANGED"; 265 mmm = "CHANGED";
268 266
269 tracing_controller.StopTracing(); 267 tracing_controller.StopTracing();
270 } 268 }
271 269
272 std::string trace_str = stream.str(); 270 std::string trace_str = stream.str();
273 271
274 std::vector<std::string> all_args, all_names, all_cats; 272 std::vector<std::string> all_args, all_names, all_cats;
275 GetJSONStrings(all_args, trace_str, "\"args\"", "{", "}"); 273 GetJSONStrings(all_args, trace_str, "\"args\"", "{", "}");
276 GetJSONStrings(all_names, trace_str, "\"name\"", "\"", "\""); 274 GetJSONStrings(all_names, trace_str, "\"name\"", "\"", "\"");
277 GetJSONStrings(all_cats, trace_str, "\"cat\"", "\"", "\""); 275 GetJSONStrings(all_cats, trace_str, "\"cat\"", "\"", "\"");
278 276
279 CHECK_EQ(all_args.size(), 23); 277 CHECK_EQ(all_args.size(), 22);
280 CHECK_EQ(all_args[0], "\"aa\":11"); 278 CHECK_EQ(all_args[0], "\"aa\":11");
281 CHECK_EQ(all_args[1], "\"bb\":22"); 279 CHECK_EQ(all_args[1], "\"bb\":22");
282 CHECK_EQ(all_args[2], "\"cc\":33"); 280 CHECK_EQ(all_args[2], "\"cc\":33");
283 CHECK_EQ(all_args[3], "\"dd\":44"); 281 CHECK_EQ(all_args[3], "\"dd\":44");
284 CHECK_EQ(all_args[4], "\"ee\":-55"); 282 CHECK_EQ(all_args[4], "\"ee\":-55");
285 CHECK_EQ(all_args[5], "\"ff\":-66"); 283 CHECK_EQ(all_args[5], "\"ff\":-66");
286 CHECK_EQ(all_args[6], "\"gg\":-77"); 284 CHECK_EQ(all_args[6], "\"gg\":-77");
287 CHECK_EQ(all_args[7], "\"hh\":-88"); 285 CHECK_EQ(all_args[7], "\"hh\":-88");
288 CHECK_EQ(all_args[8], "\"ii1\":true"); 286 CHECK_EQ(all_args[8], "\"ii1\":true");
289 CHECK_EQ(all_args[9], "\"ii2\":false"); 287 CHECK_EQ(all_args[9], "\"ii2\":false");
290 CHECK_EQ(all_args[10], "\"jj1\":99.0"); 288 CHECK_EQ(all_args[10], "\"jj1\":99.0");
291 CHECK_EQ(all_args[11], "\"jj2\":1e+100"); 289 CHECK_EQ(all_args[11], "\"jj2\":1e+100");
292 CHECK_EQ(all_args[12], "\"jj3\":\"NaN\""); 290 CHECK_EQ(all_args[12], "\"jj3\":\"NaN\"");
293 CHECK_EQ(all_args[13], "\"jj4\":\"Infinity\""); 291 CHECK_EQ(all_args[13], "\"jj4\":\"Infinity\"");
294 CHECK_EQ(all_args[14], "\"jj5\":\"-Infinity\""); 292 CHECK_EQ(all_args[14], "\"jj5\":\"-Infinity\"");
295 std::ostringstream pointer_stream; 293 std::ostringstream pointer_stream;
296 pointer_stream << "\"kk\":\"" << &aa << "\""; 294 pointer_stream << "\"kk\":\"" << &aa << "\"";
297 CHECK_EQ(all_args[15], pointer_stream.str()); 295 CHECK_EQ(all_args[15], pointer_stream.str());
298 CHECK_EQ(all_args[16], "\"ll\":\"100\""); 296 CHECK_EQ(all_args[16], "\"ll\":\"100\"");
299 CHECK_EQ(all_args[17], "\"mm\":\"INIT\""); 297 CHECK_EQ(all_args[17], "\"mm\":\"\\\"INIT\\\"\"");
300 298
301 CHECK_EQ(all_names[18], "v8.Test2.1"); 299 CHECK_EQ(all_names[18], "v8.Test2.1");
302 CHECK_EQ(all_args[18], "\"aa\":11,\"ll\":\"100\""); 300 CHECK_EQ(all_args[18], "\"aa\":11,\"ll\":\"100\"");
303 CHECK_EQ(all_args[19], "\"mm1\":\"INIT\",\"mm2\":\"INIT\""); 301 CHECK_EQ(all_args[19], "\"mm1\":\"INIT\",\"mm2\":\"\\\"INIT\\\"\"");
304 302
305 CHECK_EQ(all_names[20], "INIT"); 303 CHECK_EQ(all_names[20], "INIT");
306 CHECK_EQ(all_names[21], "INIT"); 304 CHECK_EQ(all_names[21], "INIT");
307 CHECK_EQ(all_args[21], "\"INIT\":\"INIT\""); 305 CHECK_EQ(all_args[21], "\"mm1\":\"INIT\",\"mm2\":\"\\\"INIT\\\"\"");
308 CHECK_EQ(all_names[22], "INIT");
309 CHECK_EQ(all_args[22], "\"INIT\":\"INIT\",\"INIT\":\"INIT\"");
310 306
311 i::V8::SetPlatformForTesting(old_platform); 307 i::V8::SetPlatformForTesting(old_platform);
312 } 308 }
313 309
314 } // namespace tracing 310 } // namespace tracing
315 } // namespace platform 311 } // namespace platform
316 } // namespace v8 312 } // namespace v8
OLDNEW
« 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