Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test: Fix test case 83 ('perf stat CSV output linter') on s390

Perf test case 83: perf stat CSV output linter might fail
on s390.
The reason for this is the output of the command

./perf stat -x, -A -a --no-merge true

which depends on a .config file setting. When CONFIG_SCHED_TOPOLOGY
is set, the output of above perf command is

CPU0,1.50,msec,cpu-clock,1502781,100.00,1.052,CPUs utilized

When CONFIG_SCHED_TOPOLOGY is *NOT* set the output of above perf
command is

0.95,msec,cpu-clock,949800,100.00,1.060,CPUs utilized

Fix the test case to accept both output formats.

Output before:
# perf test 83
83: perf stat CSV output linter : FAILED!
#

Output after:
# ./perf test 83
83: perf stat CSV output linter : Ok
#

Fixes: ec906102e5b7d339 ("perf test: Fix "perf stat CSV output linter" test on s390")
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-by: Ian Rogers <irogers@google.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: https://lore.kernel.org/r/20220720123419.220953-1-tmricht@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Thomas Richter and committed by
Arnaldo Carvalho de Melo
87abe344 2c91cd88

+4 -3
+4 -3
tools/perf/tests/shell/stat+csv_output.sh
··· 8 8 9 9 function commachecker() 10 10 { 11 - local -i cnt=0 exp=0 11 + local -i cnt=0 12 + local exp=0 12 13 13 14 case "$1" 14 15 in "--no-args") exp=6 ··· 18 17 ;; "--interval") exp=7 19 18 ;; "--per-thread") exp=7 20 19 ;; "--system-wide-no-aggr") exp=7 21 - [ $(uname -m) = "s390x" ] && exp=6 20 + [ $(uname -m) = "s390x" ] && exp='^[6-7]$' 22 21 ;; "--per-core") exp=8 23 22 ;; "--per-socket") exp=8 24 23 ;; "--per-node") exp=8 ··· 35 34 x=$(echo $line | tr -d -c ',') 36 35 cnt="${#x}" 37 36 # echo $line $cnt 38 - [ "$cnt" -ne "$exp" ] && { 37 + [[ ! "$cnt" =~ $exp ]] && { 39 38 echo "wrong number of fields. expected $exp in $line" 1>&2 40 39 exit 1; 41 40 }