KVM: PPC: Book3S HV: Avoid preemptibility warning in module initialization
[linux/fpc-iii.git] / tools / testing / selftests / cpufreq / main.sh
blob01bac76ac0ec71e8c9aa1371e45ee3736ecc1d24
1 #!/bin/bash
3 source cpu.sh
4 source cpufreq.sh
5 source governor.sh
6 source module.sh
7 source special-tests.sh
9 FUNC=basic # do basic tests by default
10 OUTFILE=cpufreq_selftest
11 SYSFS=
12 CPUROOT=
13 CPUFREQROOT=
15 helpme()
17 printf "Usage: $0 [-h] [-todg args]
18 [-h <help>]
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>\"]
30 \n"
31 exit 2
34 prerequisite()
36 msg="skip all tests:"
38 if [ $UID != 0 ]; then
39 echo $msg must be run as root >&2
40 exit 2
43 taskset -p 01 $$
45 SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
47 if [ ! -d "$SYSFS" ]; then
48 echo $msg sysfs is not mounted >&2
49 exit 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
57 exit 2
60 if ! ls $CPUROOT/cpufreq > /dev/null 2>&1; then
61 echo $msg cpufreq directory not available in sysfs >&2
62 exit 2
66 parse_arguments()
68 while getopts ht:o:d:g: arg
70 case $arg in
71 h) # --help
72 helpme
75 t) # --func_type (Function to perform: basic, suspend, hibernate, modtest, sptest1/2/3/4 (default: basic))
76 FUNC=$OPTARG
79 o) # --output-file (Output file to store dumps)
80 OUTFILE=$OPTARG
83 d) # --driver-mod-name (Name of the driver module)
84 DRIVER_MOD=$OPTARG
87 g) # --governor-mod-name (Name of the governor module)
88 GOVERNOR_MOD=$OPTARG
91 \?)
92 helpme
94 esac
95 done
98 do_test()
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"
105 exit 2;
108 case "$FUNC" in
109 "basic")
110 cpufreq_basic_tests
113 "suspend")
114 do_suspend "suspend" 1
117 "hibernate")
118 do_suspend "hibernate" 1
121 "modtest")
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"
125 exit 2;
128 if [ $DRIVER_MOD ]; then
129 if [ $GOVERNOR_MOD ]; then
130 module_test $DRIVER_MOD $GOVERNOR_MOD
131 else
132 module_driver_test $DRIVER_MOD
134 else
135 if [ $count = 0 ]; then
136 echo "No cpu is managed by cpufreq core, exiting"
137 exit 2;
140 module_governor_test $GOVERNOR_MOD
144 "sptest1")
145 simple_lockdep
148 "sptest2")
149 concurrent_lockdep
152 "sptest3")
153 governor_race
156 "sptest4")
157 hotplug_with_updates
161 echo "Invalid [-f] function type"
162 helpme
164 esac
167 # clear dumps
168 # $1: file name
169 clear_dumps()
171 echo "" > $1.txt
172 echo "" > $1.dmesg_cpufreq.txt
173 echo "" > $1.dmesg_full.txt
176 # $1: output file name
177 dmesg_dumps()
179 dmesg | grep cpufreq >> $1.dmesg_cpufreq.txt
181 # We may need the full logs as well
182 dmesg >> $1.dmesg_full.txt
185 # Parse arguments
186 parse_arguments $@
188 # Make sure all requirements are met
189 prerequisite
191 # Run requested functions
192 clear_dumps $OUTFILE
193 do_test >> $OUTFILE.txt
194 dmesg_dumps $OUTFILE