drm/rockchip: Don't change hdmi reference clock rate
[drm/drm-misc.git] / tools / perf / tests / shell / stat+csv_output.sh
blobfc2d8cc6e5e0b1e5b47378b4de3e079cacc32674
1 #!/bin/bash
2 # perf stat CSV output linter
3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
4 # Tests various perf stat CSV output commands for the
5 # correct number of fields and the CSV separator set to ','.
7 set -e
9 # shellcheck source=lib/stat_output.sh
10 . "$(dirname $0)"/lib/stat_output.sh
12 csv_sep=@
14 stat_output=$(mktemp /tmp/__perf_test.stat_output.csv.XXXXX)
16 cleanup() {
17 rm -f "${stat_output}"
19 trap - EXIT TERM INT
22 trap_cleanup() {
23 cleanup
24 exit 1
26 trap trap_cleanup EXIT TERM INT
28 function commachecker()
30 local -i cnt=0
31 local exp=0
33 case "$1"
34 in "--no-args") exp=6
35 ;; "--system-wide") exp=6
36 ;; "--event") exp=6
37 ;; "--interval") exp=7
38 ;; "--per-thread") exp=7
39 ;; "--system-wide-no-aggr") exp=7
40 [ "$(uname -m)" = "s390x" ] && exp='^[6-7]$'
41 ;; "--per-core") exp=8
42 ;; "--per-socket") exp=8
43 ;; "--per-node") exp=8
44 ;; "--per-die") exp=8
45 ;; "--per-cluster") exp=8
46 ;; "--per-cache") exp=8
47 esac
49 while read line
51 # Ignore initial "started on" comment.
52 x=${line:0:1}
53 [ "$x" = "#" ] && continue
54 # Ignore initial blank line.
55 [ "$line" = "" ] && continue
57 # Count the number of commas
58 x=$(echo $line | tr -d -c $csv_sep)
59 cnt="${#x}"
60 # echo $line $cnt
61 [[ ! "$cnt" =~ $exp ]] && {
62 echo "wrong number of fields. expected $exp in $line" 1>&2
63 exit 1;
65 done < "${stat_output}"
66 return 0
69 perf_cmd="-x$csv_sep -o ${stat_output}"
71 skip_test=$(check_for_topology)
72 check_no_args "CSV" "$perf_cmd"
73 check_system_wide "CSV" "$perf_cmd"
74 check_interval "CSV" "$perf_cmd"
75 check_event "CSV" "$perf_cmd"
76 check_per_thread "CSV" "$perf_cmd"
77 check_per_node "CSV" "$perf_cmd"
78 if [ $skip_test -ne 1 ]
79 then
80 check_system_wide_no_aggr "CSV" "$perf_cmd"
81 check_per_core "CSV" "$perf_cmd"
82 check_per_cache_instance "CSV" "$perf_cmd"
83 check_per_cluster "CSV" "$perf_cmd"
84 check_per_die "CSV" "$perf_cmd"
85 check_per_socket "CSV" "$perf_cmd"
86 else
87 echo "[Skip] Skipping tests for system_wide_no_aggr, per_core, per_die and per_socket since socket id exposed via topology is invalid"
89 cleanup
90 exit 0