0001
0002
0003
0004
0005 set -e
0006
0007 err=0
0008 test_default_stat() {
0009 echo "Basic stat command test"
0010 if ! perf stat true 2>&1 | egrep -q "Performance counter stats for 'true':"
0011 then
0012 echo "Basic stat command test [Failed]"
0013 err=1
0014 return
0015 fi
0016 echo "Basic stat command test [Success]"
0017 }
0018
0019 test_stat_record_report() {
0020 echo "stat record and report test"
0021 if ! perf stat record -o - true | perf stat report -i - 2>&1 | \
0022 egrep -q "Performance counter stats for 'pipe':"
0023 then
0024 echo "stat record and report test [Failed]"
0025 err=1
0026 return
0027 fi
0028 echo "stat record and report test [Success]"
0029 }
0030
0031 test_stat_repeat_weak_groups() {
0032 echo "stat repeat weak groups test"
0033 if ! perf stat -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}' \
0034 true 2>&1 | grep -q 'seconds time elapsed'
0035 then
0036 echo "stat repeat weak groups test [Skipped event parsing failed]"
0037 return
0038 fi
0039 if ! perf stat -r2 -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}:W' \
0040 true > /dev/null 2>&1
0041 then
0042 echo "stat repeat weak groups test [Failed]"
0043 err=1
0044 return
0045 fi
0046 echo "stat repeat weak groups test [Success]"
0047 }
0048
0049 test_topdown_groups() {
0050
0051
0052 echo "Topdown event group test"
0053 if ! perf stat -e '{slots,topdown-retiring}' true > /dev/null 2>&1
0054 then
0055 echo "Topdown event group test [Skipped event parsing failed]"
0056 return
0057 fi
0058 if perf stat -e '{slots,topdown-retiring}' true 2>&1 | egrep -q "<not supported>"
0059 then
0060 echo "Topdown event group test [Failed events not supported]"
0061 err=1
0062 return
0063 fi
0064 if perf stat -e '{topdown-retiring,slots}' true 2>&1 | egrep -q "<not supported>"
0065 then
0066 echo "Topdown event group test [Failed slots not reordered first]"
0067 err=1
0068 return
0069 fi
0070 echo "Topdown event group test [Success]"
0071 }
0072
0073 test_topdown_weak_groups() {
0074
0075
0076
0077 echo "Topdown weak groups test"
0078 ok_grouping="{slots,topdown-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring},branch-instructions,branch-misses,bus-cycles,cache-misses,cache-references,cpu-cycles,instructions,mem-loads,mem-stores,ref-cycles,cache-misses,cache-references"
0079 if ! perf stat --no-merge -e "$ok_grouping" true > /dev/null 2>&1
0080 then
0081 echo "Topdown weak groups test [Skipped event parsing failed]"
0082 return
0083 fi
0084 group_needs_break="{slots,topdown-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring,branch-instructions,branch-misses,bus-cycles,cache-misses,cache-references,cpu-cycles,instructions,mem-loads,mem-stores,ref-cycles,cache-misses,cache-references}:W"
0085 if perf stat --no-merge -e "$group_needs_break" true 2>&1 | egrep -q "<not supported>"
0086 then
0087 echo "Topdown weak groups test [Failed events not supported]"
0088 err=1
0089 return
0090 fi
0091 echo "Topdown weak groups test [Success]"
0092 }
0093
0094 test_default_stat
0095 test_stat_record_report
0096 test_stat_repeat_weak_groups
0097 test_topdown_groups
0098 test_topdown_weak_groups
0099 exit $err