diff options
Diffstat (limited to 'tools/perf/tests/shell')
-rwxr-xr-x | tools/perf/tests/shell/stat+shadow_stat.sh | 80 | ||||
-rwxr-xr-x | tools/perf/tests/shell/trace+probe_vfs_getname.sh | 2 |
2 files changed, 81 insertions, 1 deletions
diff --git a/tools/perf/tests/shell/stat+shadow_stat.sh b/tools/perf/tests/shell/stat+shadow_stat.sh new file mode 100755 index 000000000000..249dfe48cf6a --- /dev/null +++ b/tools/perf/tests/shell/stat+shadow_stat.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# perf stat metrics (shadow stat) test +# SPDX-License-Identifier: GPL-2.0 + +set -e + +# skip if system-wide mode is forbidden +perf stat -a true > /dev/null 2>&1 || exit 2 + +test_global_aggr() +{ + local cyc + + perf stat -a --no-big-num -e cycles,instructions sleep 1 2>&1 | \ + grep -e cycles -e instructions | \ + while read num evt hash ipc rest + do + # skip not counted events + if [[ $num == "<not" ]]; then + continue + fi + + # save cycles count + if [[ $evt == "cycles" ]]; then + cyc=$num + continue + fi + + # skip if no cycles + if [[ -z $cyc ]]; then + continue + fi + + # use printf for rounding and a leading zero + local res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)` + if [[ $ipc != $res ]]; then + echo "IPC is different: $res != $ipc ($num / $cyc)" + exit 1 + fi + done +} + +test_no_aggr() +{ + declare -A results + + perf stat -a -A --no-big-num -e cycles,instructions sleep 1 2>&1 | \ + grep ^CPU | \ + while read cpu num evt hash ipc rest + do + # skip not counted events + if [[ $num == "<not" ]]; then + continue + fi + + # save cycles count + if [[ $evt == "cycles" ]]; then + results[$cpu]=$num + continue + fi + + # skip if no cycles + local cyc=${results[$cpu]} + if [[ -z $cyc ]]; then + continue + fi + + # use printf for rounding and a leading zero + local res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)` + if [[ $ipc != $res ]]; then + echo "IPC is different for $cpu: $res != $ipc ($num / $cyc)" + exit 1 + fi + done +} + +test_global_aggr +test_no_aggr + +exit 0 diff --git a/tools/perf/tests/shell/trace+probe_vfs_getname.sh b/tools/perf/tests/shell/trace+probe_vfs_getname.sh index 11cc2af13f2b..3d31c1d560d6 100755 --- a/tools/perf/tests/shell/trace+probe_vfs_getname.sh +++ b/tools/perf/tests/shell/trace+probe_vfs_getname.sh @@ -20,7 +20,7 @@ skip_if_no_perf_trace || exit 2 file=$(mktemp /tmp/temporary_file.XXXXX) trace_open_vfs_getname() { - evts=$(echo $(perf list syscalls:sys_enter_open* 2>&1 | egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/') + evts=$(echo $(perf list syscalls:sys_enter_open* 2>/dev/null | egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/') perf trace -e $evts touch $file 2>&1 | \ egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$" } |