2 # SPDX-License-Identifier: GPL-2.0
8 source special-tests.sh
10 FUNC
=basic
# do basic tests by default
11 OUTFILE
=cpufreq_selftest
18 printf "Usage: $0 [-h] [-todg args]
20 [-o <output-file-for-dump>]
21 [-t <basic: Basic cpufreq testing
22 suspend: suspend/resume,
23 hibernate: hibernate/resume,
24 modtest: test driver or governor modules. Only to be used with -d or -g options,
25 sptest1: Simple governor switch to produce lockdep.
26 sptest2: Concurrent governor switch to produce lockdep.
27 sptest3: Governor races, shuffle between governors quickly.
28 sptest4: CPU hotplugs with updates to cpufreq files.>]
29 [-d <driver's module name: only with \"-t modtest>\"]
30 [-g <governor's module name: only with \"-t modtest>\"]
39 if [ $UID != 0 ]; then
40 echo $msg must be run as root
>&2
46 SYSFS
=`mount -t sysfs | head -1 | awk '{ print $3 }'`
48 if [ ! -d "$SYSFS" ]; then
49 echo $msg sysfs is not mounted
>&2
53 CPUROOT
=$SYSFS/devices
/system
/cpu
54 CPUFREQROOT
="$CPUROOT/cpufreq"
56 if ! ls $CPUROOT/cpu
* > /dev
/null
2>&1; then
57 echo $msg cpus not available
in sysfs
>&2
61 if ! ls $CPUROOT/cpufreq
> /dev
/null
2>&1; then
62 echo $msg cpufreq directory not available
in sysfs
>&2
69 while getopts ht
:o
:d
:g
: arg
76 t
) # --func_type (Function to perform: basic, suspend, hibernate, modtest, sptest1/2/3/4 (default: basic))
80 o
) # --output-file (Output file to store dumps)
84 d
) # --driver-mod-name (Name of the driver module)
88 g
) # --governor-mod-name (Name of the governor module)
101 # Check if CPUs are managed by cpufreq or not
102 count
=$
(count_cpufreq_managed_cpus
)
104 if [ $count = 0 -a $FUNC != "modtest" ]; then
105 echo "No cpu is managed by cpufreq core, exiting"
115 do_suspend
"suspend" 1
119 do_suspend
"hibernate" 1
123 # Do we have modules in place?
124 if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then
125 echo "No driver or governor module passed with -d or -g"
129 if [ $DRIVER_MOD ]; then
130 if [ $GOVERNOR_MOD ]; then
131 module_test
$DRIVER_MOD $GOVERNOR_MOD
133 module_driver_test
$DRIVER_MOD
136 if [ $count = 0 ]; then
137 echo "No cpu is managed by cpufreq core, exiting"
141 module_governor_test
$GOVERNOR_MOD
162 echo "Invalid [-f] function type"
173 echo "" > $1.dmesg_cpufreq.txt
174 echo "" > $1.dmesg_full.txt
177 # $1: output file name
180 dmesg |
grep cpufreq
>> $1.dmesg_cpufreq.txt
182 # We may need the full logs as well
183 dmesg
>> $1.dmesg_full.txt
189 # Make sure all requirements are met
192 # Run requested functions
194 do_test
>> $OUTFILE.txt