[LTP] [PATCH] runpwtests03: fix for module name retrieval

Xiao Yang ice_yangxiao@163.com
Thu Jun 27 16:24:15 CEST 2019


On 06/26/2019 04:17 PM, Po-Hsu Lin wrote:
> The -l flag for modprobe has been deprecated in newer packages.
> This will induce some noise during the execution:
>      modprobe: invalid option -- 'l'
>
> And making the "Loading and Unloading of governor kernel modules" test
> not doing module load / unload operations.
>
> Fix this by using the find command to retrieve module names instead.
>
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> ---
>   testcases/kernel/power_management/runpwtests03.sh | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/kernel/power_management/runpwtests03.sh b/testcases/kernel/power_management/runpwtests03.sh
> index 11197937f..81d44f9b1 100755
> --- a/testcases/kernel/power_management/runpwtests03.sh
> +++ b/testcases/kernel/power_management/runpwtests03.sh
> @@ -118,8 +118,8 @@ pwkm_load_unload() {
>   	RC=0
>   	loaded_governor=`cat \
>   		/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`
> -	for module in `modprobe -l | grep cpufreq_ | \
> -		cut -f8 -d"/" | cut -f1 -d"."`
> +	for module in `find /lib/modules/$(uname -r) -name "*cpufreq_*.ko" \
> +		-printf "%f\n" | cut -f1 -d"."`
Hi,

We may install compressed kernel modules(e.g. cpufreq_userspace.ko.xz) 
so we should match
these different formats.

There are still other issues(e.g. test is skipped if CPU_FREQ is built 
as a module) in the old code.
We should rewrite it to new API first and fix these issues including 
invalid "-l" option by the way.

Best Regards,
Xiao Yang
>   	do
>   		#echo -n "Loading $module ... "
>   		if [ $module != "cpufreq_$loaded_governor" ]; then
> @@ -131,8 +131,8 @@ pwkm_load_unload() {
>   			fi
>   		fi
>   	done
> -	for module in `modprobe -l | grep cpufreq_ | \
> -		cut -f8 -d"/" | cut -f1 -d"."`
> +	for module in `find /lib/modules/$(uname -r) -name "*cpufreq_*.ko" \
> +		-printf "%f\n" | cut -f1 -d"."`
>   		do
>   		#echo -n "Unloading $module ... "
>   		if [ $module != "cpufreq_$loaded_governor" ]; then




More information about the ltp mailing list