2 # SPDX-License-Identifier: GPL-2.0
4 # Modules specific tests cases
6 # protect against multiple inclusion
7 if [ $FILE_MODULE ]; then
17 # Check basic insmod/rmmod
19 test_basic_insmod_rmmod
()
21 printf "** Test: Running ${FUNCNAME[0]} **\n\n"
23 printf "Inserting $1 module\n"
27 ktap_exit_fail_msg
"Insmod $1 failed\n"
30 printf "Removing $1 module\n"
34 ktap_exit_fail_msg
"rmmod $1 failed\n"
40 # Insert cpufreq driver module and perform basic tests
41 # $1: cpufreq-driver module to insert
42 # $2: If we want to play with CPUs (1) or not (0)
43 module_driver_test_single
()
45 printf "** Test: Running ${FUNCNAME[0]} for driver $1 and cpus_hotplug=$2 **\n\n"
48 # offline all non-boot CPUs
49 for_each_non_boot_cpu offline_cpu
54 printf "Inserting $1 module\n\n"
57 printf "Insmod $1 failed\n"
62 # online all non-boot CPUs
63 for_each_non_boot_cpu online_cpu
71 printf "Removing $1 module\n\n"
74 printf "rmmod $1 failed\n"
78 # There shouldn't be any cpufreq directories now.
79 for_each_cpu cpu_should_not_have_cpufreq_directory
83 # $1: cpufreq-driver module to insert
86 printf "** Test: Running ${FUNCNAME[0]} **\n\n"
88 # check if module is present or not
91 printf "$1: not present in `pwd` folder\n"
95 # test basic module tests
96 test_basic_insmod_rmmod
$1
98 # Do simple module test
99 module_driver_test_single
$1 0
101 # Remove CPUs before inserting module and then bring them back
102 module_driver_test_single
$1 1
106 # find governor name based on governor module name
107 # $1: governor module name
110 if [ $1 = "cpufreq_ondemand.ko" ]; then
112 elif [ $1 = "cpufreq_conservative.ko" ]; then
113 printf "conservative"
114 elif [ $1 = "cpufreq_userspace.ko" ]; then
116 elif [ $1 = "cpufreq_performance.ko" ]; then
118 elif [ $1 = "cpufreq_powersave.ko" ]; then
120 elif [ $1 = "cpufreq_schedutil.ko" ]; then
125 # $1: governor string, $2: governor module, $3: policy
126 # example: module_governor_test_single "ondemand" "cpufreq_ondemand.ko" 2
127 module_governor_test_single
()
129 printf "** Test: Running ${FUNCNAME[0]} for $3 **\n\n"
133 # switch to new governor
134 printf "Switch from $CUR_GOV to $1\n"
135 switch_show_governor
$3 $1
137 # try removing module, it should fail as governor is used
138 printf "Removing $2 module\n\n"
141 printf "WARN: rmmod $2 succeeded even if governor is used\n"
144 printf "Pass: unable to remove $2 while it is being used\n\n"
147 # switch back to old governor
148 printf "Switchback to $CUR_GOV from $1\n"
153 # Insert cpufreq governor module and perform basic tests
154 # $1: cpufreq-governor module to insert
155 module_governor_test
()
157 printf "** Test: Running ${FUNCNAME[0]} **\n\n"
159 # check if module is present or not
162 printf "$1: not present in `pwd` folder\n"
166 # test basic module tests
167 test_basic_insmod_rmmod
$1
170 printf "Inserting $1 module\n\n"
173 printf "Insmod $1 failed\n"
177 # switch to new governor for each cpu
178 for_each_policy module_governor_test_single $
(find_gov_name
$1) $1
181 printf "Removing $1 module\n\n"
184 printf "rmmod $1 failed\n"
190 # test modules: driver and governor
191 # $1: driver module, $2: governor module
194 printf "** Test: Running ${FUNCNAME[0]} **\n\n"
196 # check if modules are present or not
199 printf "$1 or $2: is not present in `pwd` folder\n"
203 # TEST1: Insert gov after driver
204 # insert driver module
205 printf "Inserting $1 module\n\n"
208 printf "Insmod $1 failed\n"
213 module_governor_test
$2
215 # remove driver module
216 printf "Removing $1 module\n\n"
219 printf "rmmod $1 failed\n"
223 # TEST2: Insert driver after governor
224 # insert governor module
225 printf "Inserting $2 module\n\n"
228 printf "Insmod $2 failed\n"
233 module_driver_test
$1
235 # remove driver module
236 printf "Removing $2 module\n\n"
239 printf "rmmod $2 failed\n"