aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-08-08 06:23:52 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-08-14 16:04:06 -0400
commit905f5ee2f769c85eb6f0b6ee38f803829efd68a3 (patch)
tree77e7a4ab9c69554c5ea99ac113c890e17ba8578d
parent6a4bb04caacc8c2d06f345130e9086e3fea38ca7 (diff)
perf test: Add automated tests for event group parsing
Adding 5 more tests for new event group syntax. Tests are executed within the 'perf test parse' test suite. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ulrich Drepper <drepper@gmail.com> Link: http://lkml.kernel.org/n/tip-dmhsv8mpoksx2wp97balqiem@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/parse-events-test.c302
1 files changed, 299 insertions, 3 deletions
diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c
index 127d648cc548..429dd688281a 100644
--- a/tools/perf/util/parse-events-test.c
+++ b/tools/perf/util/parse-events-test.c
@@ -513,6 +513,285 @@ static int test__checkterms_simple(struct list_head *terms)
513 return 0; 513 return 0;
514} 514}
515 515
516static int test__group1(struct perf_evlist *evlist)
517{
518 struct perf_evsel *evsel, *leader;
519
520 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
521
522 /* instructions:k */
523 evsel = leader = list_entry(evlist->entries.next,
524 struct perf_evsel, node);
525 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
526 TEST_ASSERT_VAL("wrong config",
527 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
528 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
529 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
530 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
531 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
532 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
533 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
534 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
535
536 /* cycles:upp */
537 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
538 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
539 TEST_ASSERT_VAL("wrong config",
540 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
541 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
542 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
543 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
544 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
545 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
546 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2);
547 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
548
549 return 0;
550}
551
552static int test__group2(struct perf_evlist *evlist)
553{
554 struct perf_evsel *evsel, *leader;
555
556 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
557
558 /* faults + :ku modifier */
559 evsel = leader = list_entry(evlist->entries.next,
560 struct perf_evsel, node);
561 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
562 TEST_ASSERT_VAL("wrong config",
563 PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config);
564 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
565 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
566 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
567 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
568 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
569 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
570 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
571
572 /* cache-references + :u modifier */
573 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
574 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
575 TEST_ASSERT_VAL("wrong config",
576 PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config);
577 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
578 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
579 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
580 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
581 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
582 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
583 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
584
585 /* cycles:k */
586 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
587 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
588 TEST_ASSERT_VAL("wrong config",
589 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
590 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
591 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
592 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
593 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
594 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
595 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
596 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
597
598 return 0;
599}
600
601static int test__group3(struct perf_evlist *evlist __used)
602{
603 struct perf_evsel *evsel, *leader;
604
605 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries);
606
607 /* group1 syscalls:sys_enter_open:H */
608 evsel = leader = list_entry(evlist->entries.next,
609 struct perf_evsel, node);
610 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
611 TEST_ASSERT_VAL("wrong sample_type",
612 PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type);
613 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
614 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
615 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
616 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
617 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
618 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
619 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
620 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
621 TEST_ASSERT_VAL("wrong group name",
622 !strcmp(leader->group_name, "group1"));
623
624 /* group1 cycles:kppp */
625 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
626 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
627 TEST_ASSERT_VAL("wrong config",
628 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
629 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
630 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
631 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
632 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
633 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
634 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3);
635 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
636 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
637
638 /* group2 cycles + G modifier */
639 evsel = leader = list_entry(evsel->node.next, struct perf_evsel, node);
640 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
641 TEST_ASSERT_VAL("wrong config",
642 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
643 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
644 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
645 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
646 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
647 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
648 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
649 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
650 TEST_ASSERT_VAL("wrong group name",
651 !strcmp(leader->group_name, "group2"));
652
653 /* group2 1:3 + G modifier */
654 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
655 TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
656 TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config);
657 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
658 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
659 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
660 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
661 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
662 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
663 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
664
665 /* instructions:u */
666 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
667 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
668 TEST_ASSERT_VAL("wrong config",
669 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
670 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
671 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
672 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
673 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
674 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
675 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
676 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
677
678 return 0;
679}
680
681static int test__group4(struct perf_evlist *evlist __used)
682{
683 struct perf_evsel *evsel, *leader;
684
685 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
686
687 /* cycles:u + p */
688 evsel = leader = list_entry(evlist->entries.next,
689 struct perf_evsel, node);
690 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
691 TEST_ASSERT_VAL("wrong config",
692 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
693 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
694 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
695 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
696 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
697 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
698 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1);
699 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
700 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
701
702 /* instructions:kp + p */
703 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
704 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
705 TEST_ASSERT_VAL("wrong config",
706 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
707 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
708 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
709 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
710 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
711 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
712 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2);
713 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
714
715 return 0;
716}
717
718static int test__group5(struct perf_evlist *evlist __used)
719{
720 struct perf_evsel *evsel, *leader;
721
722 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries);
723
724 /* cycles + G */
725 evsel = leader = list_entry(evlist->entries.next,
726 struct perf_evsel, node);
727 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
728 TEST_ASSERT_VAL("wrong config",
729 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
730 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
731 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
732 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
733 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
734 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
735 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
736 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
737 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
738
739 /* instructions + G */
740 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
741 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
742 TEST_ASSERT_VAL("wrong config",
743 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
744 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
745 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
746 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
747 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
748 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
749 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
750 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
751
752 /* cycles:G */
753 evsel = leader = list_entry(evsel->node.next, struct perf_evsel, node);
754 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
755 TEST_ASSERT_VAL("wrong config",
756 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
757 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
758 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
759 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
760 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
761 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
762 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
763 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
764 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
765
766 /* instructions:G */
767 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
768 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
769 TEST_ASSERT_VAL("wrong config",
770 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
771 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
772 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
773 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
774 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
775 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
776 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
777 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
778
779 /* cycles */
780 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
781 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
782 TEST_ASSERT_VAL("wrong config",
783 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
784 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
785 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
786 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
787 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
788 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
789 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
790 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
791
792 return 0;
793}
794
516struct test__event_st { 795struct test__event_st {
517 const char *name; 796 const char *name;
518 __u32 type; 797 __u32 type;
@@ -632,6 +911,26 @@ static struct test__event_st test__events[] = {
632 .name = "mem:0:rw:kp", 911 .name = "mem:0:rw:kp",
633 .check = test__checkevent_breakpoint_rw_modifier, 912 .check = test__checkevent_breakpoint_rw_modifier,
634 }, 913 },
914 [28] = {
915 .name = "{instructions:k,cycles:upp}",
916 .check = test__group1,
917 },
918 [29] = {
919 .name = "{faults:k,cache-references}:u,cycles:k",
920 .check = test__group2,
921 },
922 [30] = {
923 .name = "group1{syscalls:sys_enter_open:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u",
924 .check = test__group3,
925 },
926 [31] = {
927 .name = "{cycles:u,instructions:kp}:p",
928 .check = test__group4,
929 },
930 [32] = {
931 .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles",
932 .check = test__group5,
933 },
635}; 934};
636 935
637static struct test__event_st test__events_pmu[] = { 936static struct test__event_st test__events_pmu[] = {
@@ -658,9 +957,6 @@ static struct test__term test__terms[] = {
658 }, 957 },
659}; 958};
660 959
661#define TEST__TERMS_CNT (sizeof(test__terms) / \
662 sizeof(struct test__term))
663
664static int test_event(struct test__event_st *e) 960static int test_event(struct test__event_st *e)
665{ 961{
666 struct perf_evlist *evlist; 962 struct perf_evlist *evlist;