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

Side by Side Diff: base/debug/trace_event_unittest.cc

Issue 11366109: Adding raw tracing to trace framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use ThreadIdNameManager to retrieve correct thread names. Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 4
5 #include "base/debug/trace_event_unittest.h" 5 #include "base/debug/trace_event_unittest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 TRACE_EVENT_INSTANT_ETW("TRACE_EVENT_INSTANT_ETW1 call", 5, "value"); 372 TRACE_EVENT_INSTANT_ETW("TRACE_EVENT_INSTANT_ETW1 call", 5, "value");
373 373
374 TRACE_COUNTER1("all", "TRACE_COUNTER1 call", 31415); 374 TRACE_COUNTER1("all", "TRACE_COUNTER1 call", 31415);
375 TRACE_COUNTER2("all", "TRACE_COUNTER2 call", 375 TRACE_COUNTER2("all", "TRACE_COUNTER2 call",
376 "a", 30000, 376 "a", 30000,
377 "b", 1415); 377 "b", 1415);
378 378
379 TRACE_COUNTER_ID1("all", "TRACE_COUNTER_ID1 call", 0x319009, 31415); 379 TRACE_COUNTER_ID1("all", "TRACE_COUNTER_ID1 call", 0x319009, 31415);
380 TRACE_COUNTER_ID2("all", "TRACE_COUNTER_ID2 call", 0x319009, 380 TRACE_COUNTER_ID2("all", "TRACE_COUNTER_ID2 call", 0x319009,
381 "a", 30000, "b", 1415); 381 "a", 30000, "b", 1415);
382
383 TRACE_EVENT_COPY_BEGIN_EXPLICIT0("all",
384 "TRACE_EVENT_COPY_BEGIN_EXPLICIT0 call",
385 42, 1, 12345);
386 TRACE_EVENT_COPY_END_EXPLICIT0("all", "TRACE_EVENT_COPY_END_EXPLICIT0 call",
387 42, 1, 23456);
388
389 TRACE_EVENT_BEGIN_EXPLICIT0("all", "TRACE_EVENT_BEGIN_EXPLICIT0 call",
390 42, 2, 34567);
391 TRACE_EVENT_END_EXPLICIT0("all", "TRACE_EVENT_END_EXPLICIT0 call",
392 42, 2, 45678);
393
382 } // Scope close causes TRACE_EVENT0 etc to send their END events. 394 } // Scope close causes TRACE_EVENT0 etc to send their END events.
383 395
384 if (task_complete_event) 396 if (task_complete_event)
385 task_complete_event->Signal(); 397 task_complete_event->Signal();
386 } 398 }
387 399
388 void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) { 400 void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) {
389 const DictionaryValue* item = NULL; 401 const DictionaryValue* item = NULL;
390 402
391 #define EXPECT_FIND_(string) \ 403 #define EXPECT_FIND_(string) \
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 EXPECT_TRUE((item && item->GetString("ph", &ph))); 603 EXPECT_TRUE((item && item->GetString("ph", &ph)));
592 EXPECT_EQ("C", ph); 604 EXPECT_EQ("C", ph);
593 605
594 int value; 606 int value;
595 EXPECT_TRUE((item && item->GetInteger("args.a", &value))); 607 EXPECT_TRUE((item && item->GetInteger("args.a", &value)));
596 EXPECT_EQ(30000, value); 608 EXPECT_EQ(30000, value);
597 609
598 EXPECT_TRUE((item && item->GetInteger("args.b", &value))); 610 EXPECT_TRUE((item && item->GetInteger("args.b", &value)));
599 EXPECT_EQ(1415, value); 611 EXPECT_EQ(1415, value);
600 } 612 }
613
614 EXPECT_FIND_("TRACE_EVENT_COPY_BEGIN_EXPLICIT0 call");
615 {
616 int val;
617 EXPECT_TRUE((item && item->GetInteger("ts", &val)));
618 EXPECT_EQ(12345, val);
619 EXPECT_TRUE((item && item->GetInteger("tid", &val)));
620 EXPECT_EQ(42, val);
621 std::string id;
622 EXPECT_TRUE((item && item->GetString("id", &id)));
623 EXPECT_EQ("1", id);
624 }
625
626 EXPECT_FIND_("TRACE_EVENT_COPY_END_EXPLICIT0 call");
627 {
628 int val;
629 EXPECT_TRUE((item && item->GetInteger("ts", &val)));
630 EXPECT_EQ(23456, val);
631 EXPECT_TRUE((item && item->GetInteger("tid", &val)));
632 EXPECT_EQ(42, val);
633 std::string id;
634 EXPECT_TRUE((item && item->GetString("id", &id)));
635 EXPECT_EQ("1", id);
636 }
637
638 EXPECT_FIND_("TRACE_EVENT_BEGIN_EXPLICIT0 call");
639 {
640 int val;
641 EXPECT_TRUE((item && item->GetInteger("ts", &val)));
642 EXPECT_EQ(34567, val);
643 EXPECT_TRUE((item && item->GetInteger("tid", &val)));
644 EXPECT_EQ(42, val);
645 std::string id;
646 EXPECT_TRUE((item && item->GetString("id", &id)));
647 EXPECT_EQ("2", id);
648 }
649
650 EXPECT_FIND_("TRACE_EVENT_END_EXPLICIT0 call");
651 {
652 int val;
653 EXPECT_TRUE((item && item->GetInteger("ts", &val)));
654 EXPECT_EQ(45678, val);
655 EXPECT_TRUE((item && item->GetInteger("tid", &val)));
656 EXPECT_EQ(42, val);
657 std::string id;
658 EXPECT_TRUE((item && item->GetString("id", &id)));
659 EXPECT_EQ("2", id);
660 }
601 } 661 }
602 662
603 void TraceManyInstantEvents(int thread_id, int num_events, 663 void TraceManyInstantEvents(int thread_id, int num_events,
604 WaitableEvent* task_complete_event) { 664 WaitableEvent* task_complete_event) {
605 for (int i = 0; i < num_events; i++) { 665 for (int i = 0; i < num_events; i++) {
606 TRACE_EVENT_INSTANT2("all", "multi thread event", 666 TRACE_EVENT_INSTANT2("all", "multi thread event",
607 "thread", thread_id, 667 "thread", thread_id,
608 "event", i); 668 "event", i);
609 } 669 }
610 670
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 Clear(); 1511 Clear();
1452 1512
1453 trace_buffer_.Start(); 1513 trace_buffer_.Start();
1454 trace_buffer_.AddFragment("bla1,bla2,bla3,bla4"); 1514 trace_buffer_.AddFragment("bla1,bla2,bla3,bla4");
1455 trace_buffer_.Finish(); 1515 trace_buffer_.Finish();
1456 EXPECT_STREQ(json_output_.json_output.c_str(), "[bla1,bla2,bla3,bla4]"); 1516 EXPECT_STREQ(json_output_.json_output.c_str(), "[bla1,bla2,bla3,bla4]");
1457 } 1517 }
1458 1518
1459 } // namespace debug 1519 } // namespace debug
1460 } // namespace base 1520 } // namespace base
OLDNEW
« base/debug/trace_event_impl.h ('K') | « base/debug/trace_event_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698