~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/cpufreq/main.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/cpufreq/main.sh (Version linux-6.12-rc7) and /tools/testing/selftests/cpufreq/main.sh (Version linux-6.10.14)


  1 #!/bin/bash                                         1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3                                                     3 
  4 source cpu.sh                                       4 source cpu.sh
  5 source cpufreq.sh                                   5 source cpufreq.sh
  6 source governor.sh                                  6 source governor.sh
  7 source module.sh                                    7 source module.sh
  8 source special-tests.sh                             8 source special-tests.sh
  9                                                     9 
 10 DIR="$(dirname $(readlink -f "$0"))"               10 DIR="$(dirname $(readlink -f "$0"))"
 11 source "${DIR}"/../kselftest/ktap_helpers.sh       11 source "${DIR}"/../kselftest/ktap_helpers.sh
 12                                                    12 
 13 FUNC=basic      # do basic tests by default        13 FUNC=basic      # do basic tests by default
 14 OUTFILE=cpufreq_selftest                           14 OUTFILE=cpufreq_selftest
 15 SYSFS=                                             15 SYSFS=
 16 CPUROOT=                                           16 CPUROOT=
 17 CPUFREQROOT=                                       17 CPUFREQROOT=
 18                                                    18 
 19 helpme()                                           19 helpme()
 20 {                                                  20 {
 21         printf "Usage: $0 [-h] [-todg args]        21         printf "Usage: $0 [-h] [-todg args]
 22         [-h <help>]                                22         [-h <help>]
 23         [-o <output-file-for-dump>]                23         [-o <output-file-for-dump>]
 24         [-t <basic: Basic cpufreq testing          24         [-t <basic: Basic cpufreq testing
 25              suspend: suspend/resume,              25              suspend: suspend/resume,
 26              hibernate: hibernate/resume,          26              hibernate: hibernate/resume,
 27              suspend_rtc: suspend/resume back  << 
 28              hibernate_rtc: hibernate/resume b << 
 29              modtest: test driver or governor      27              modtest: test driver or governor modules. Only to be used with -d or -g options,
 30              sptest1: Simple governor switch t     28              sptest1: Simple governor switch to produce lockdep.
 31              sptest2: Concurrent governor swit     29              sptest2: Concurrent governor switch to produce lockdep.
 32              sptest3: Governor races, shuffle      30              sptest3: Governor races, shuffle between governors quickly.
 33              sptest4: CPU hotplugs with update     31              sptest4: CPU hotplugs with updates to cpufreq files.>]
 34         [-d <driver's module name: only with \     32         [-d <driver's module name: only with \"-t modtest>\"]
 35         [-g <governor's module name: only with     33         [-g <governor's module name: only with \"-t modtest>\"]
 36         \n"                                        34         \n"
 37         exit "${KSFT_FAIL}"                        35         exit "${KSFT_FAIL}"
 38 }                                                  36 }
 39                                                    37 
 40 prerequisite()                                     38 prerequisite()
 41 {                                                  39 {
 42         msg="skip all tests:"                      40         msg="skip all tests:"
 43                                                    41 
 44         if [ $UID != 0 ]; then                     42         if [ $UID != 0 ]; then
 45                 ktap_skip_all "$msg must be ru     43                 ktap_skip_all "$msg must be run as root"
 46                 exit "${KSFT_SKIP}"                44                 exit "${KSFT_SKIP}"
 47         fi                                         45         fi
 48                                                    46 
 49         taskset -p 01 $$                           47         taskset -p 01 $$
 50                                                    48 
 51         SYSFS=`mount -t sysfs | head -1 | awk      49         SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
 52                                                    50 
 53         if [ ! -d "$SYSFS" ]; then                 51         if [ ! -d "$SYSFS" ]; then
 54                 ktap_skip_all "$msg sysfs is n     52                 ktap_skip_all "$msg sysfs is not mounted"
 55                 exit "${KSFT_SKIP}"                53                 exit "${KSFT_SKIP}"
 56         fi                                         54         fi
 57                                                    55 
 58         CPUROOT=$SYSFS/devices/system/cpu          56         CPUROOT=$SYSFS/devices/system/cpu
 59         CPUFREQROOT="$CPUROOT/cpufreq"             57         CPUFREQROOT="$CPUROOT/cpufreq"
 60                                                    58 
 61         if ! ls $CPUROOT/cpu* > /dev/null 2>&1     59         if ! ls $CPUROOT/cpu* > /dev/null 2>&1; then
 62                 ktap_skip_all "$msg cpus not a     60                 ktap_skip_all "$msg cpus not available in sysfs"
 63                 exit "${KSFT_SKIP}"                61                 exit "${KSFT_SKIP}"
 64         fi                                         62         fi
 65                                                    63 
 66         if ! ls $CPUROOT/cpufreq > /dev/null 2     64         if ! ls $CPUROOT/cpufreq > /dev/null 2>&1; then
 67                 ktap_skip_all "$msg cpufreq di     65                 ktap_skip_all "$msg cpufreq directory not available in sysfs"
 68                 exit "${KSFT_SKIP}"                66                 exit "${KSFT_SKIP}"
 69         fi                                         67         fi
 70 }                                                  68 }
 71                                                    69 
 72 parse_arguments()                                  70 parse_arguments()
 73 {                                                  71 {
 74         while getopts ht:o:d:g: arg                72         while getopts ht:o:d:g: arg
 75         do                                         73         do
 76                 case $arg in                       74                 case $arg in
 77                         h) # --help                75                         h) # --help
 78                                 helpme             76                                 helpme
 79                                 ;;                 77                                 ;;
 80                                                    78 
 81                         t) # --func_type (Func !!  79                         t) # --func_type (Function to perform: basic, suspend, hibernate, modtest, sptest1/2/3/4 (default: basic))
 82                            # suspend_rtc, hibe << 
 83                                 FUNC=$OPTARG       80                                 FUNC=$OPTARG
 84                                 ;;                 81                                 ;;
 85                                                    82 
 86                         o) # --output-file (Ou     83                         o) # --output-file (Output file to store dumps)
 87                                 OUTFILE=$OPTAR     84                                 OUTFILE=$OPTARG
 88                                 ;;                 85                                 ;;
 89                                                    86 
 90                         d) # --driver-mod-name     87                         d) # --driver-mod-name (Name of the driver module)
 91                                 DRIVER_MOD=$OP     88                                 DRIVER_MOD=$OPTARG
 92                                 ;;                 89                                 ;;
 93                                                    90 
 94                         g) # --governor-mod-na     91                         g) # --governor-mod-name (Name of the governor module)
 95                                 GOVERNOR_MOD=$     92                                 GOVERNOR_MOD=$OPTARG
 96                                 ;;                 93                                 ;;
 97                                                    94 
 98                         \?)                        95                         \?)
 99                                 helpme             96                                 helpme
100                                 ;;                 97                                 ;;
101                 esac                               98                 esac
102         done                                       99         done
103 }                                                 100 }
104                                                   101 
105 do_test()                                         102 do_test()
106 {                                                 103 {
107         # Check if CPUs are managed by cpufreq    104         # Check if CPUs are managed by cpufreq or not
108         count=$(count_cpufreq_managed_cpus)       105         count=$(count_cpufreq_managed_cpus)
109                                                   106 
110         if [ $count = 0 -a $FUNC != "modtest"     107         if [ $count = 0 -a $FUNC != "modtest" ]; then
111                 ktap_exit_fail_msg "No cpu is     108                 ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting"
112         fi                                        109         fi
113                                                   110 
114         case "$FUNC" in                           111         case "$FUNC" in
115                 "basic")                          112                 "basic")
116                 cpufreq_basic_tests               113                 cpufreq_basic_tests
117                 ;;                                114                 ;;
118                                                   115 
119                 "suspend")                        116                 "suspend")
120                 do_suspend "suspend" 1            117                 do_suspend "suspend" 1
121                 ;;                                118                 ;;
122                                                   119 
123                 "hibernate")                      120                 "hibernate")
124                 do_suspend "hibernate" 1          121                 do_suspend "hibernate" 1
125                 ;;                                122                 ;;
126                                                << 
127                 "suspend_rtc")                 << 
128                 do_suspend "suspend" 1 rtc     << 
129                 ;;                             << 
130                                                << 
131                 "hibernate_rtc")               << 
132                 do_suspend "hibernate" 1 rtc   << 
133                 ;;                             << 
134                                                   123 
135                 "modtest")                        124                 "modtest")
136                 # Do we have modules in place?    125                 # Do we have modules in place?
137                 if [ -z $DRIVER_MOD ] && [ -z     126                 if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then
138                         ktap_exit_fail_msg "No    127                         ktap_exit_fail_msg "No driver or governor module passed with -d or -g"
139                 fi                                128                 fi
140                                                   129 
141                 if [ $DRIVER_MOD ]; then          130                 if [ $DRIVER_MOD ]; then
142                         if [ $GOVERNOR_MOD ];     131                         if [ $GOVERNOR_MOD ]; then
143                                 module_test $D    132                                 module_test $DRIVER_MOD $GOVERNOR_MOD
144                         else                      133                         else
145                                 module_driver_    134                                 module_driver_test $DRIVER_MOD
146                         fi                        135                         fi
147                 else                              136                 else
148                         if [ $count = 0 ]; the    137                         if [ $count = 0 ]; then
149                                 ktap_exit_fail    138                                 ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting"
150                         fi                        139                         fi
151                                                   140 
152                         module_governor_test $    141                         module_governor_test $GOVERNOR_MOD
153                 fi                                142                 fi
154                 ;;                                143                 ;;
155                                                   144 
156                 "sptest1")                        145                 "sptest1")
157                 simple_lockdep                    146                 simple_lockdep
158                 ;;                                147                 ;;
159                                                   148 
160                 "sptest2")                        149                 "sptest2")
161                 concurrent_lockdep                150                 concurrent_lockdep
162                 ;;                                151                 ;;
163                                                   152 
164                 "sptest3")                        153                 "sptest3")
165                 governor_race                     154                 governor_race
166                 ;;                                155                 ;;
167                                                   156 
168                 "sptest4")                        157                 "sptest4")
169                 hotplug_with_updates              158                 hotplug_with_updates
170                 ;;                                159                 ;;
171                                                   160 
172                 *)                                161                 *)
173                 ktap_print_msg "Invalid [-f] f    162                 ktap_print_msg "Invalid [-f] function type"
174                 helpme                            163                 helpme
175                 ;;                                164                 ;;
176         esac                                      165         esac
177 }                                                 166 }
178                                                   167 
179 # clear dumps                                     168 # clear dumps
180 # $1: file name                                   169 # $1: file name
181 clear_dumps()                                     170 clear_dumps()
182 {                                                 171 {
183         echo "" > $1.txt                          172         echo "" > $1.txt
184         echo "" > $1.dmesg_cpufreq.txt            173         echo "" > $1.dmesg_cpufreq.txt
185         echo "" > $1.dmesg_full.txt               174         echo "" > $1.dmesg_full.txt
186 }                                                 175 }
187                                                   176 
188 # $1: output file name                            177 # $1: output file name
189 dmesg_dumps()                                     178 dmesg_dumps()
190 {                                                 179 {
191         dmesg | grep cpufreq >> $1.dmesg_cpufr    180         dmesg | grep cpufreq >> $1.dmesg_cpufreq.txt
192                                                   181 
193         # We may need the full logs as well       182         # We may need the full logs as well
194         dmesg >> $1.dmesg_full.txt                183         dmesg >> $1.dmesg_full.txt
195 }                                                 184 }
196                                                   185 
197 ktap_print_header                                 186 ktap_print_header
198                                                   187 
199 # Parse arguments                                 188 # Parse arguments
200 parse_arguments $@                                189 parse_arguments $@
201                                                   190 
202 ktap_set_plan 1                                   191 ktap_set_plan 1
203                                                   192 
204 # Make sure all requirements are met              193 # Make sure all requirements are met
205 prerequisite                                      194 prerequisite
206                                                   195 
207 # Run requested functions                         196 # Run requested functions
208 clear_dumps $OUTFILE                              197 clear_dumps $OUTFILE
209 do_test | tee -a $OUTFILE.txt                     198 do_test | tee -a $OUTFILE.txt
210 if [ "${PIPESTATUS[0]}" -ne 0 ]; then             199 if [ "${PIPESTATUS[0]}" -ne 0 ]; then
211     exit ${PIPESTATUS[0]};                        200     exit ${PIPESTATUS[0]};
212 fi                                                201 fi
213 dmesg_dumps $OUTFILE                              202 dmesg_dumps $OUTFILE
214                                                   203 
215 ktap_test_pass "Completed successfully"           204 ktap_test_pass "Completed successfully"
216                                                   205 
217 ktap_print_totals                                 206 ktap_print_totals
218 exit "${KSFT_PASS}"                               207 exit "${KSFT_PASS}"
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php