aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2011-12-15 10:30:39 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-12-20 11:46:14 -0500
commit65c1e0452a3389f9b7b8c1b23305ed2922fafb2d (patch)
tree7e6408b8e3794e3c399577c49b68a0fa0ff43fcf /tools
parentcb8f4e9aa37c469ddd80dda51469f327606c0118 (diff)
perf test: Add more automated tests for event parsing
Adding automated tests for event parsing to include testing for modifier and ',' operator. Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: cjashfor@linux.vnet.ibm.com Link: http://lkml.kernel.org/r/1323963039-7602-4-git-send-email-jolsa@redhat.com Signed-off-by: Jiri Olsa <jolsa@redhat.com> [ committer note: Remove some tests that need group_leader & bison patchkits ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-test.c127
1 files changed, 126 insertions, 1 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 6173f780dce0..2b9a7f497a20 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -603,7 +603,7 @@ out_free_threads:
603 603
604#define TEST_ASSERT_VAL(text, cond) \ 604#define TEST_ASSERT_VAL(text, cond) \
605do { \ 605do { \
606 if (!cond) { \ 606 if (!(cond)) { \
607 pr_debug("FAILED %s:%d %s\n", __FILE__, __LINE__, text); \ 607 pr_debug("FAILED %s:%d %s\n", __FILE__, __LINE__, text); \
608 return -1; \ 608 return -1; \
609 } \ 609 } \
@@ -759,6 +759,103 @@ static int test__checkevent_breakpoint_w(struct perf_evlist *evlist)
759 return 0; 759 return 0;
760} 760}
761 761
762static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist)
763{
764 struct perf_evsel *evsel = list_entry(evlist->entries.next,
765 struct perf_evsel, node);
766
767 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
768 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
769 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
770 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
771
772 return test__checkevent_tracepoint(evlist);
773}
774
775static int
776test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist)
777{
778 struct perf_evsel *evsel;
779
780 TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1);
781
782 list_for_each_entry(evsel, &evlist->entries, node) {
783 TEST_ASSERT_VAL("wrong exclude_user",
784 !evsel->attr.exclude_user);
785 TEST_ASSERT_VAL("wrong exclude_kernel",
786 evsel->attr.exclude_kernel);
787 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
788 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
789 }
790
791 return test__checkevent_tracepoint_multi(evlist);
792}
793
794static int test__checkevent_raw_modifier(struct perf_evlist *evlist)
795{
796 struct perf_evsel *evsel = list_entry(evlist->entries.next,
797 struct perf_evsel, node);
798
799 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
800 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
801 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
802 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
803
804 return test__checkevent_raw(evlist);
805}
806
807static int test__checkevent_numeric_modifier(struct perf_evlist *evlist)
808{
809 struct perf_evsel *evsel = list_entry(evlist->entries.next,
810 struct perf_evsel, node);
811
812 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
813 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
814 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
815 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
816
817 return test__checkevent_numeric(evlist);
818}
819
820static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist)
821{
822 struct perf_evsel *evsel = list_entry(evlist->entries.next,
823 struct perf_evsel, node);
824
825 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
826 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
827 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
828 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
829
830 return test__checkevent_symbolic_name(evlist);
831}
832
833static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist)
834{
835 struct perf_evsel *evsel = list_entry(evlist->entries.next,
836 struct perf_evsel, node);
837
838 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
839 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
840 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
841 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
842
843 return test__checkevent_symbolic_alias(evlist);
844}
845
846static int test__checkevent_genhw_modifier(struct perf_evlist *evlist)
847{
848 struct perf_evsel *evsel = list_entry(evlist->entries.next,
849 struct perf_evsel, node);
850
851 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
852 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
853 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
854 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
855
856 return test__checkevent_genhw(evlist);
857}
858
762static struct test__event_st { 859static struct test__event_st {
763 const char *name; 860 const char *name;
764 __u32 type; 861 __u32 type;
@@ -808,6 +905,34 @@ static struct test__event_st {
808 .name = "mem:0:w", 905 .name = "mem:0:w",
809 .check = test__checkevent_breakpoint_w, 906 .check = test__checkevent_breakpoint_w,
810 }, 907 },
908 {
909 .name = "syscalls:sys_enter_open:k",
910 .check = test__checkevent_tracepoint_modifier,
911 },
912 {
913 .name = "syscalls:*:u",
914 .check = test__checkevent_tracepoint_multi_modifier,
915 },
916 {
917 .name = "r1:kp",
918 .check = test__checkevent_raw_modifier,
919 },
920 {
921 .name = "1:1:hp",
922 .check = test__checkevent_numeric_modifier,
923 },
924 {
925 .name = "instructions:h",
926 .check = test__checkevent_symbolic_name_modifier,
927 },
928 {
929 .name = "faults:u",
930 .check = test__checkevent_symbolic_alias_modifier,
931 },
932 {
933 .name = "L1-dcache-load-miss:kp",
934 .check = test__checkevent_genhw_modifier,
935 },
811}; 936};
812 937
813#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st)) 938#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st))