Skip to content

Commit ec90610

Browse files
Thomas Richteracmel
authored andcommitted
perf test: Fix "perf stat CSV output linter" test on s390
perf test -F 83 ("perf stat CSV output linter") fails on s390. Reason is the wrong number of fields for certain CPU core/die/socket related output. On x84_64 the output of command: # ./perf stat -x, -A -a --no-merge true CPU0,1.50,msec,cpu-clock,1502781,100.00,1.052,CPUs utilized CPU1,1.48,msec,cpu-clock,1476113,100.00,1.034,CPUs utilized ... results in 8 fields with 7 comma separators. On s390 the output of command: # ./perf stat -x, -A -a --no-merge -- true 0.95,msec,cpu-clock,949800,100.00,1.060,CPUs utilized ... results in 7 fields with 6 comma separators. Therefore this tests fails on s390. Similar issues exist for per-die and per-socket output which is not supported on s390. I have rewritten the python program to count commas in each output line into a bash function to achieve the same result. I hope this makes it a bit easier. Output before: # ./perf test -F 83 83: perf stat CSV output linter : Checking CSV output: no args [Success] Checking CSV output: system wide [Success] Checking CSV output: system wide Checking CSV output: \ system wide no aggregation 6.92,msec,cpu-clock,\ 6918131,100.00,6.972,CPUs utilized ... RuntimeError: wrong number of fields. expected 7 in \ 6.92,msec,cpu-clock,6918131,100.00,6.972,CPUs utilized FAILED! # Output after: # ./perf test -F 83 83: perf stat CSV output linter : Checking CSV output: no args [Success] Checking CSV output: system wide [Success] Checking CSV output: system wide Checking CSV output:\ system wide no aggregation [Success] Checking CSV output: interval [Success] Checking CSV output: event [Success] Checking CSV output: per core [Success] Checking CSV output: per thread [Success] Checking CSV output: per die [Success] Checking CSV output: per node [Success] Checking CSV output: per socket [Success] Ok # Committer notes: Continues to work on x86_64 $ perf test lint 89: perf stat CSV output linter : Ok $ perf test -v lint Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc 89: perf stat CSV output linter : --- start --- test child forked, pid 53133 Checking CSV output: no args [Success] Checking CSV output: system wide [Skip] paranoid and not root Checking CSV output: system wide [Skip] paranoid and not root Checking CSV output: interval [Success] Checking CSV output: event [Success] Checking CSV output: per core [Skip] paranoid and not root Checking CSV output: per thread [Skip] paranoid and not root Checking CSV output: per die [Skip] paranoid and not root Checking CSV output: per node [Skip] paranoid and not root Checking CSV output: per socket [Skip] paranoid and not root test child finished with 0 ---- end ---- perf stat CSV output linter: Ok $ Signed-off-by: Thomas Richter <tmricht@linux.ibm.com> Acked-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Claire Jensen <cjense@google.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Sumanth Korikkar <sumanthk@linux.ibm.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: linux390-list@tuxmaker.boeblingen.de.ibm.com Link: https://lore.kernel.org/r/20220603113034.2009728-1-tmricht@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 1d98cdf commit ec90610

2 files changed

Lines changed: 45 additions & 72 deletions

File tree

tools/perf/tests/shell/lib/perf_csv_output_lint.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

tools/perf/tests/shell/stat+csv_output.sh

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,41 @@
66

77
set -e
88

9-
pythonchecker=$(dirname $0)/lib/perf_csv_output_lint.py
10-
if [ "x$PYTHON" == "x" ]
11-
then
12-
if which python3 > /dev/null
13-
then
14-
PYTHON=python3
15-
elif which python > /dev/null
16-
then
17-
PYTHON=python
18-
else
19-
echo Skipping test, python not detected please set environment variable PYTHON.
20-
exit 2
21-
fi
22-
fi
9+
function commachecker()
10+
{
11+
local -i cnt=0 exp=0
12+
13+
case "$1"
14+
in "--no-args") exp=6
15+
;; "--system-wide") exp=6
16+
;; "--event") exp=6
17+
;; "--interval") exp=7
18+
;; "--per-thread") exp=7
19+
;; "--system-wide-no-aggr") exp=7
20+
[ $(uname -m) = "s390x" ] && exp=6
21+
;; "--per-core") exp=8
22+
;; "--per-socket") exp=8
23+
;; "--per-node") exp=8
24+
;; "--per-die") exp=8
25+
esac
26+
27+
while read line
28+
do
29+
# Check for lines beginning with Failed
30+
x=${line:0:6}
31+
[ "$x" = "Failed" ] && continue
32+
33+
# Count the number of commas
34+
x=$(echo $line | tr -d -c ',')
35+
cnt="${#x}"
36+
# echo $line $cnt
37+
[ "$cnt" -ne "$exp" ] && {
38+
echo "wrong number of fields. expected $exp in $line" 1>&2
39+
exit 1;
40+
}
41+
done
42+
return 0
43+
}
2344

2445
# Return true if perf_event_paranoid is > $1 and not running as root.
2546
function ParanoidAndNotRoot()
@@ -30,7 +51,7 @@ function ParanoidAndNotRoot()
3051
check_no_args()
3152
{
3253
echo -n "Checking CSV output: no args "
33-
perf stat -x, true 2>&1 | $PYTHON $pythonchecker --no-args
54+
perf stat -x, true 2>&1 | commachecker --no-args
3455
echo "[Success]"
3556
}
3657

@@ -42,7 +63,7 @@ check_system_wide()
4263
echo "[Skip] paranoid and not root"
4364
return
4465
fi
45-
perf stat -x, -a true 2>&1 | $PYTHON $pythonchecker --system-wide
66+
perf stat -x, -a true 2>&1 | commachecker --system-wide
4667
echo "[Success]"
4768
}
4869

@@ -55,22 +76,22 @@ check_system_wide_no_aggr()
5576
return
5677
fi
5778
echo -n "Checking CSV output: system wide no aggregation "
58-
perf stat -x, -A -a --no-merge true 2>&1 | $PYTHON $pythonchecker --system-wide-no-aggr
79+
perf stat -x, -A -a --no-merge true 2>&1 | commachecker --system-wide-no-aggr
5980
echo "[Success]"
6081
}
6182

6283
check_interval()
6384
{
6485
echo -n "Checking CSV output: interval "
65-
perf stat -x, -I 1000 true 2>&1 | $PYTHON $pythonchecker --interval
86+
perf stat -x, -I 1000 true 2>&1 | commachecker --interval
6687
echo "[Success]"
6788
}
6889

6990

7091
check_event()
7192
{
7293
echo -n "Checking CSV output: event "
73-
perf stat -x, -e cpu-clock true 2>&1 | $PYTHON $pythonchecker --event
94+
perf stat -x, -e cpu-clock true 2>&1 | commachecker --event
7495
echo "[Success]"
7596
}
7697

@@ -82,7 +103,7 @@ check_per_core()
82103
echo "[Skip] paranoid and not root"
83104
return
84105
fi
85-
perf stat -x, --per-core -a true 2>&1 | $PYTHON $pythonchecker --per-core
106+
perf stat -x, --per-core -a true 2>&1 | commachecker --per-core
86107
echo "[Success]"
87108
}
88109

@@ -94,7 +115,7 @@ check_per_thread()
94115
echo "[Skip] paranoid and not root"
95116
return
96117
fi
97-
perf stat -x, --per-thread -a true 2>&1 | $PYTHON $pythonchecker --per-thread
118+
perf stat -x, --per-thread -a true 2>&1 | commachecker --per-thread
98119
echo "[Success]"
99120
}
100121

@@ -106,7 +127,7 @@ check_per_die()
106127
echo "[Skip] paranoid and not root"
107128
return
108129
fi
109-
perf stat -x, --per-die -a true 2>&1 | $PYTHON $pythonchecker --per-die
130+
perf stat -x, --per-die -a true 2>&1 | commachecker --per-die
110131
echo "[Success]"
111132
}
112133

@@ -118,7 +139,7 @@ check_per_node()
118139
echo "[Skip] paranoid and not root"
119140
return
120141
fi
121-
perf stat -x, --per-node -a true 2>&1 | $PYTHON $pythonchecker --per-node
142+
perf stat -x, --per-node -a true 2>&1 | commachecker --per-node
122143
echo "[Success]"
123144
}
124145

@@ -130,7 +151,7 @@ check_per_socket()
130151
echo "[Skip] paranoid and not root"
131152
return
132153
fi
133-
perf stat -x, --per-socket -a true 2>&1 | $PYTHON $pythonchecker --per-socket
154+
perf stat -x, --per-socket -a true 2>&1 | commachecker --per-socket
134155
echo "[Success]"
135156
}
136157

0 commit comments

Comments
 (0)