2 # SPDX-License-Identifier: GPL-2.0
8 source special-tests.sh
10 FUNC
=basic
# do basic tests by default
11 OUTFILE
=cpufreq_selftest
16 # Kselftest framework requirement - SKIP code is 4.
21 printf "Usage: $0 [-h] [-todg args]
23 [-o <output-file-for-dump>]
24 [-t <basic: Basic cpufreq testing
25 suspend: suspend/resume,
26 hibernate: hibernate/resume,
27 modtest: test driver or governor modules. Only to be used with -d or -g options,
28 sptest1: Simple governor switch to produce lockdep.
29 sptest2: Concurrent governor switch to produce lockdep.
30 sptest3: Governor races, shuffle between governors quickly.
31 sptest4: CPU hotplugs with updates to cpufreq files.>]
32 [-d <driver's module name: only with \"-t modtest>\"]
33 [-g <governor's module name: only with \"-t modtest>\"]
42 if [ $UID != 0 ]; then
43 echo $msg must be run as root
>&2
49 SYSFS
=`mount -t sysfs | head -1 | awk '{ print $3 }'`
51 if [ ! -d "$SYSFS" ]; then
52 echo $msg sysfs is not mounted
>&2
56 CPUROOT
=$SYSFS/devices
/system
/cpu
57 CPUFREQROOT
="$CPUROOT/cpufreq"
59 if ! ls $CPUROOT/cpu
* > /dev
/null
2>&1; then
60 echo $msg cpus not available
in sysfs
>&2
64 if ! ls $CPUROOT/cpufreq
> /dev
/null
2>&1; then
65 echo $msg cpufreq directory not available
in sysfs
>&2
72 while getopts ht
:o
:d
:g
: arg
79 t
) # --func_type (Function to perform: basic, suspend, hibernate, modtest, sptest1/2/3/4 (default: basic))
83 o
) # --output-file (Output file to store dumps)
87 d
) # --driver-mod-name (Name of the driver module)
91 g
) # --governor-mod-name (Name of the governor module)
104 # Check if CPUs are managed by cpufreq or not
105 count
=$
(count_cpufreq_managed_cpus
)
107 if [ $count = 0 -a $FUNC != "modtest" ]; then
108 echo "No cpu is managed by cpufreq core, exiting"
118 do_suspend
"suspend" 1
122 do_suspend
"hibernate" 1
126 # Do we have modules in place?
127 if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then
128 echo "No driver or governor module passed with -d or -g"
132 if [ $DRIVER_MOD ]; then
133 if [ $GOVERNOR_MOD ]; then
134 module_test
$DRIVER_MOD $GOVERNOR_MOD
136 module_driver_test
$DRIVER_MOD
139 if [ $count = 0 ]; then
140 echo "No cpu is managed by cpufreq core, exiting"
144 module_governor_test
$GOVERNOR_MOD
165 echo "Invalid [-f] function type"
176 echo "" > $1.dmesg_cpufreq.txt
177 echo "" > $1.dmesg_full.txt
180 # $1: output file name
183 dmesg |
grep cpufreq
>> $1.dmesg_cpufreq.txt
185 # We may need the full logs as well
186 dmesg
>> $1.dmesg_full.txt
192 # Make sure all requirements are met
195 # Run requested functions
197 do_test
>> $OUTFILE.txt