0001
0002
0003
0004 source cpu.sh
0005 source cpufreq.sh
0006 source governor.sh
0007 source module.sh
0008 source special-tests.sh
0009
0010 FUNC=basic
0011 OUTFILE=cpufreq_selftest
0012 SYSFS=
0013 CPUROOT=
0014 CPUFREQROOT=
0015
0016
0017 ksft_skip=4
0018
0019 helpme()
0020 {
0021 printf "Usage: $0 [-h] [-todg args]
0022 [-h <help>]
0023 [-o <output-file-for-dump>]
0024 [-t <basic: Basic cpufreq testing
0025 suspend: suspend/resume,
0026 hibernate: hibernate/resume,
0027 modtest: test driver or governor modules. Only to be used with -d or -g options,
0028 sptest1: Simple governor switch to produce lockdep.
0029 sptest2: Concurrent governor switch to produce lockdep.
0030 sptest3: Governor races, shuffle between governors quickly.
0031 sptest4: CPU hotplugs with updates to cpufreq files.>]
0032 [-d <driver's module name: only with \"-t modtest>\"]
0033 [-g <governor's module name: only with \"-t modtest>\"]
0034 \n"
0035 exit 2
0036 }
0037
0038 prerequisite()
0039 {
0040 msg="skip all tests:"
0041
0042 if [ $UID != 0 ]; then
0043 echo $msg must be run as root >&2
0044 exit $ksft_skip
0045 fi
0046
0047 taskset -p 01 $$
0048
0049 SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
0050
0051 if [ ! -d "$SYSFS" ]; then
0052 echo $msg sysfs is not mounted >&2
0053 exit 2
0054 fi
0055
0056 CPUROOT=$SYSFS/devices/system/cpu
0057 CPUFREQROOT="$CPUROOT/cpufreq"
0058
0059 if ! ls $CPUROOT/cpu* > /dev/null 2>&1; then
0060 echo $msg cpus not available in sysfs >&2
0061 exit 2
0062 fi
0063
0064 if ! ls $CPUROOT/cpufreq > /dev/null 2>&1; then
0065 echo $msg cpufreq directory not available in sysfs >&2
0066 exit 2
0067 fi
0068 }
0069
0070 parse_arguments()
0071 {
0072 while getopts ht:o:d:g: arg
0073 do
0074 case $arg in
0075 h)
0076 helpme
0077 ;;
0078
0079 t)
0080 FUNC=$OPTARG
0081 ;;
0082
0083 o)
0084 OUTFILE=$OPTARG
0085 ;;
0086
0087 d)
0088 DRIVER_MOD=$OPTARG
0089 ;;
0090
0091 g)
0092 GOVERNOR_MOD=$OPTARG
0093 ;;
0094
0095 \?)
0096 helpme
0097 ;;
0098 esac
0099 done
0100 }
0101
0102 do_test()
0103 {
0104
0105 count=$(count_cpufreq_managed_cpus)
0106
0107 if [ $count = 0 -a $FUNC != "modtest" ]; then
0108 echo "No cpu is managed by cpufreq core, exiting"
0109 exit 2;
0110 fi
0111
0112 case "$FUNC" in
0113 "basic")
0114 cpufreq_basic_tests
0115 ;;
0116
0117 "suspend")
0118 do_suspend "suspend" 1
0119 ;;
0120
0121 "hibernate")
0122 do_suspend "hibernate" 1
0123 ;;
0124
0125 "modtest")
0126
0127 if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then
0128 echo "No driver or governor module passed with -d or -g"
0129 exit 2;
0130 fi
0131
0132 if [ $DRIVER_MOD ]; then
0133 if [ $GOVERNOR_MOD ]; then
0134 module_test $DRIVER_MOD $GOVERNOR_MOD
0135 else
0136 module_driver_test $DRIVER_MOD
0137 fi
0138 else
0139 if [ $count = 0 ]; then
0140 echo "No cpu is managed by cpufreq core, exiting"
0141 exit 2;
0142 fi
0143
0144 module_governor_test $GOVERNOR_MOD
0145 fi
0146 ;;
0147
0148 "sptest1")
0149 simple_lockdep
0150 ;;
0151
0152 "sptest2")
0153 concurrent_lockdep
0154 ;;
0155
0156 "sptest3")
0157 governor_race
0158 ;;
0159
0160 "sptest4")
0161 hotplug_with_updates
0162 ;;
0163
0164 *)
0165 echo "Invalid [-f] function type"
0166 helpme
0167 ;;
0168 esac
0169 }
0170
0171
0172
0173 clear_dumps()
0174 {
0175 echo "" > $1.txt
0176 echo "" > $1.dmesg_cpufreq.txt
0177 echo "" > $1.dmesg_full.txt
0178 }
0179
0180
0181 dmesg_dumps()
0182 {
0183 dmesg | grep cpufreq >> $1.dmesg_cpufreq.txt
0184
0185
0186 dmesg >> $1.dmesg_full.txt
0187 }
0188
0189
0190 parse_arguments $@
0191
0192
0193 prerequisite
0194
0195
0196 clear_dumps $OUTFILE
0197 do_test | tee -a $OUTFILE.txt
0198 dmesg_dumps $OUTFILE