diff mbox series

runpwtests03: fix for module name retrieval

Message ID 20190626081735.31327-1-po-hsu.lin@canonical.com
State Rejected
Headers show
Series runpwtests03: fix for module name retrieval | expand

Commit Message

Po-Hsu Lin June 26, 2019, 8:17 a.m. UTC
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(-)

Comments

Xiao Yang June 27, 2019, 2:24 p.m. UTC | #1
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
Xiao Yang June 27, 2019, 2:38 p.m. UTC | #2
On 06/27/2019 10:24 PM, Xiao Yang wrote:
> 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.
Hi,

PS: test is skipped if CONFIG_X86_ACPI_CPUFREQ instead of CPU_FREQ is 
built as a module and is not loaded.

> 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
>
>
>
diff mbox series

Patch

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"."`
 	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