7 source special-tests.sh
9 FUNC
=basic
# do basic tests by default
10 OUTFILE
=cpufreq_selftest
17 printf "Usage: $0 [-h] [-todg args]
19 [-o <output-file-for-dump>]
20 [-t <basic: Basic cpufreq testing
21 suspend: suspend/resume,
22 hibernate: hibernate/resume,
23 modtest: test driver or governor modules. Only to be used with -d or -g options,
24 sptest1: Simple governor switch to produce lockdep.
25 sptest2: Concurrent governor switch to produce lockdep.
26 sptest3: Governor races, shuffle between governors quickly.
27 sptest4: CPU hotplugs with updates to cpufreq files.>]
28 [-d <driver's module name: only with \"-t modtest>\"]
29 [-g <governor's module name: only with \"-t modtest>\"]
38 if [ $UID != 0 ]; then
39 echo $msg must be run as root
>&2
45 SYSFS
=`mount -t sysfs | head -1 | awk '{ print $3 }'`
47 if [ ! -d "$SYSFS" ]; then
48 echo $msg sysfs is not mounted
>&2
52 CPUROOT
=$SYSFS/devices
/system
/cpu
53 CPUFREQROOT
="$CPUROOT/cpufreq"
55 if ! ls $CPUROOT/cpu
* > /dev
/null
2>&1; then
56 echo $msg cpus not available
in sysfs
>&2
60 if ! ls $CPUROOT/cpufreq
> /dev
/null
2>&1; then
61 echo $msg cpufreq directory not available
in sysfs
>&2
68 while getopts ht
:o
:d
:g
: arg
75 t
) # --func_type (Function to perform: basic, suspend, hibernate, modtest, sptest1/2/3/4 (default: basic))
79 o
) # --output-file (Output file to store dumps)
83 d
) # --driver-mod-name (Name of the driver module)
87 g
) # --governor-mod-name (Name of the governor module)
100 # Check if CPUs are managed by cpufreq or not
101 count
=$
(count_cpufreq_managed_cpus
)
103 if [ $count = 0 -a $FUNC != "modtest" ]; then
104 echo "No cpu is managed by cpufreq core, exiting"
114 do_suspend
"suspend" 1
118 do_suspend
"hibernate" 1
122 # Do we have modules in place?
123 if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then
124 echo "No driver or governor module passed with -d or -g"
128 if [ $DRIVER_MOD ]; then
129 if [ $GOVERNOR_MOD ]; then
130 module_test
$DRIVER_MOD $GOVERNOR_MOD
132 module_driver_test
$DRIVER_MOD
135 if [ $count = 0 ]; then
136 echo "No cpu is managed by cpufreq core, exiting"
140 module_governor_test
$GOVERNOR_MOD
161 echo "Invalid [-f] function type"
172 echo "" > $1.dmesg_cpufreq.txt
173 echo "" > $1.dmesg_full.txt
176 # $1: output file name
179 dmesg |
grep cpufreq
>> $1.dmesg_cpufreq.txt
181 # We may need the full logs as well
182 dmesg
>> $1.dmesg_full.txt
188 # Make sure all requirements are met
191 # Run requested functions
193 do_test
>> $OUTFILE.txt