diff mbox series

ltp: replace the retry loops by new exponential backoff macro

Message ID 20180517062943.13178-1-liwang@redhat.com
State Accepted
Delegated to: Petr Vorel
Headers show
Series ltp: replace the retry loops by new exponential backoff macro | expand

Commit Message

Li Wang May 17, 2018, 6:29 a.m. UTC
Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Petr Vorel <pvorel@suse.cz>
Cc: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/commands/mkswap/mkswap01.sh | 17 ++++------
 testcases/kernel/numa/numa01.sh       | 58 +++++++++++++++--------------------
 2 files changed, 31 insertions(+), 44 deletions(-)

Comments

Petr Vorel June 12, 2018, 3:56 p.m. UTC | #1
Hi Li,

> Signed-off-by: Li Wang <liwang@redhat.com>
> Cc: Petr Vorel <pvorel@suse.cz>
> Cc: Cyril Hrubis <chrubis@suse.cz>
> ---
>  testcases/commands/mkswap/mkswap01.sh | 17 ++++------
>  testcases/kernel/numa/numa01.sh       | 58 +++++++++++++++--------------------

Thanks for your patch, applied with diff bellow.

I changed:
* fix mixing quotes when calling check_for_file. This was also broken on dash
  (testing with /bin/sh as symlink to /bin/dash and using checkbashisms.pl
  script helps).
* simplify check_for_file + remove TINFO message as it was unnecessarily verbose
  (see bellow)

Kind regards,
Petr

tst_device.c:83: INFO: Found free device '/dev/loop0'
mkswap01 1 TPASS: 'mkswap   /dev/loop0 ' passed.
mkswap01 2 TPASS: 'mkswap   /dev/loop0 262140' passed.
mkswap01 3 TINFO: Can not do swapon on /dev/loop0.
mkswap01 3 TINFO: Device size specified by 'mkswap' greater than real size.
mkswap01 3 TINFO: Swapon failed expectedly.
mkswap01 3 TPASS: 'mkswap -f  /dev/loop0 262148' passed.
mkswap01 4 TPASS: 'mkswap -c  /dev/loop0 ' passed.
mkswap01 5 TINFO: Can not do swapon on /dev/loop0.
mkswap01 5 TINFO: Page size specified by 'mkswap -p' is not equal to system's page size.
mkswap01 5 TINFO: Swapon failed expectedly.
mkswap01 5 TPASS: 'mkswap -p 2048 /dev/loop0 ' passed.
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
mkswap01 6 TPASS: 'mkswap -L ltp_testswap /dev/loop0 ' passed.
mkswap01 7 TPASS: 'mkswap -v1  /dev/loop0 ' passed.
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
mkswap01 8 TPASS: 'mkswap -U b20a69ef-cf9d-49fb-a313-284df6ddd794 /dev/loop0 ' passed.
mkswap01 9 TPASS: 'mkswap -V  /dev/loop0 ' passed.
mkswap01 10 TPASS: 'mkswap -h  /dev/loop0 ' passed.

diff --git testcases/commands/mkswap/mkswap01.sh testcases/commands/mkswap/mkswap01.sh
index fc07933ae..5ead4cdc5 100755
--- testcases/commands/mkswap/mkswap01.sh
+++ testcases/commands/mkswap/mkswap01.sh
@@ -41,15 +41,9 @@ check_for_file()
 {
 	local path="$1"
 
-	if [ -z "$path" ]; then
+	if [ -z "$path" -o -e "$path" ]; then
 		return
 	fi
-
-	if [ -e "$path" ]; then
-		return 0
-	fi
-
-	tst_res TINFO "The file $path haven't appeared"
 	return 1
 }
 
@@ -70,7 +64,7 @@ mkswap_verify()
 		local pagesize=$PAGE_SIZE
 	fi
 
-	TST_RETRY_FUNC "check_for_file "$dev_file"" 0
+	TST_RETRY_FUNC "check_for_file $dev_file" 0
 
 	swapon $swapfile 2>/dev/null
 
diff --git testcases/kernel/numa/numa01.sh testcases/kernel/numa/numa01.sh
index f8d8f303c..da2f80ddd 100755
--- testcases/kernel/numa/numa01.sh
+++ testcases/kernel/numa/numa01.sh
@@ -302,11 +302,7 @@ test7()
 
 check_ltp_numa_test8_log()
 {
-	if grep -m1 -q '.' ltp_numa_test8.log; then
-		return 0
-	fi
-
-	return 1
+	grep -m1 -q '.' ltp_numa_test8.log
 }
 
 # Verification of memhog with interleave policy
Shuang Qiu Aug. 7, 2018, 9:35 p.m. UTC | #2
Hi,

Referring to commit 8435d0c7283,some version of swapon will not create 
the symlink of the device.
So it changed TWARN to TINFO so that the test will not break by it.
We need to handler such situation in the new patch,or revert the change 
for swap01.sh.

Thanks
Shuang

On 06/12/2018 11:56 PM, Petr Vorel wrote:
> Hi Li,
>
>> Signed-off-by: Li Wang <liwang@redhat.com>
>> Cc: Petr Vorel <pvorel@suse.cz>
>> Cc: Cyril Hrubis <chrubis@suse.cz>
>> ---
>>   testcases/commands/mkswap/mkswap01.sh | 17 ++++------
>>   testcases/kernel/numa/numa01.sh       | 58 +++++++++++++++--------------------
> Thanks for your patch, applied with diff bellow.
>
> I changed:
> * fix mixing quotes when calling check_for_file. This was also broken on dash
>    (testing with /bin/sh as symlink to /bin/dash and using checkbashisms.pl
>    script helps).
> * simplify check_for_file + remove TINFO message as it was unnecessarily verbose
>    (see bellow)
>
> Kind regards,
> Petr
>
> tst_device.c:83: INFO: Found free device '/dev/loop0'
> mkswap01 1 TPASS: 'mkswap   /dev/loop0 ' passed.
> mkswap01 2 TPASS: 'mkswap   /dev/loop0 262140' passed.
> mkswap01 3 TINFO: Can not do swapon on /dev/loop0.
> mkswap01 3 TINFO: Device size specified by 'mkswap' greater than real size.
> mkswap01 3 TINFO: Swapon failed expectedly.
> mkswap01 3 TPASS: 'mkswap -f  /dev/loop0 262148' passed.
> mkswap01 4 TPASS: 'mkswap -c  /dev/loop0 ' passed.
> mkswap01 5 TINFO: Can not do swapon on /dev/loop0.
> mkswap01 5 TINFO: Page size specified by 'mkswap -p' is not equal to system's page size.
> mkswap01 5 TINFO: Swapon failed expectedly.
> mkswap01 5 TPASS: 'mkswap -p 2048 /dev/loop0 ' passed.
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't appeared
> mkswap01 6 TPASS: 'mkswap -L ltp_testswap /dev/loop0 ' passed.
> mkswap01 7 TPASS: 'mkswap -v1  /dev/loop0 ' passed.
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't appeared
> mkswap01 8 TPASS: 'mkswap -U b20a69ef-cf9d-49fb-a313-284df6ddd794 /dev/loop0 ' passed.
> mkswap01 9 TPASS: 'mkswap -V  /dev/loop0 ' passed.
> mkswap01 10 TPASS: 'mkswap -h  /dev/loop0 ' passed.
>
> diff --git testcases/commands/mkswap/mkswap01.sh testcases/commands/mkswap/mkswap01.sh
> index fc07933ae..5ead4cdc5 100755
> --- testcases/commands/mkswap/mkswap01.sh
> +++ testcases/commands/mkswap/mkswap01.sh
> @@ -41,15 +41,9 @@ check_for_file()
>   {
>   	local path="$1"
>   
> -	if [ -z "$path" ]; then
> +	if [ -z "$path" -o -e "$path" ]; then
>   		return
>   	fi
> -
> -	if [ -e "$path" ]; then
> -		return 0
> -	fi
> -
> -	tst_res TINFO "The file $path haven't appeared"
>   	return 1
>   }
>   
> @@ -70,7 +64,7 @@ mkswap_verify()
>   		local pagesize=$PAGE_SIZE
>   	fi
>   
> -	TST_RETRY_FUNC "check_for_file "$dev_file"" 0
> +	TST_RETRY_FUNC "check_for_file $dev_file" 0
>   
>   	swapon $swapfile 2>/dev/null
>   
> diff --git testcases/kernel/numa/numa01.sh testcases/kernel/numa/numa01.sh
> index f8d8f303c..da2f80ddd 100755
> --- testcases/kernel/numa/numa01.sh
> +++ testcases/kernel/numa/numa01.sh
> @@ -302,11 +302,7 @@ test7()
>   
>   check_ltp_numa_test8_log()
>   {
> -	if grep -m1 -q '.' ltp_numa_test8.log; then
> -		return 0
> -	fi
> -
> -	return 1
> +	grep -m1 -q '.' ltp_numa_test8.log
>   }
>   
>   # Verification of memhog with interleave policy
>
Li Wang Aug. 8, 2018, 6:08 a.m. UTC | #3
Hi Shuang,

Which LTP version do you use?

If I remember correctly, YANG Xiao has already reported this issue and
fixed in:

commit 72c52581747301939340af5b1971dea569248226
Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
Date:   Sun Jun 24 13:59:43 2018 +0800

    commands/mkswap01.sh: Fix unexisted "/dev/disk/by-*" files on old
kernels


On Wed, Aug 8, 2018 at 5:35 AM, Shuang Qiu <shuang.qiu@oracle.com> wrote:

> Hi,
>
> Referring to commit 8435d0c7283,some version of swapon will not create the
> symlink of the device.
> So it changed TWARN to TINFO so that the test will not break by it.
> We need to handler such situation in the new patch,or revert the change
> for swap01.sh.
>
> Thanks
> Shuang
>
>
> On 06/12/2018 11:56 PM, Petr Vorel wrote:
>
>> Hi Li,
>>
>> Signed-off-by: Li Wang <liwang@redhat.com>
>>> Cc: Petr Vorel <pvorel@suse.cz>
>>> Cc: Cyril Hrubis <chrubis@suse.cz>
>>> ---
>>>   testcases/commands/mkswap/mkswap01.sh | 17 ++++------
>>>   testcases/kernel/numa/numa01.sh       | 58
>>> +++++++++++++++--------------------
>>>
>> Thanks for your patch, applied with diff bellow.
>>
>> I changed:
>> * fix mixing quotes when calling check_for_file. This was also broken on
>> dash
>>    (testing with /bin/sh as symlink to /bin/dash and using
>> checkbashisms.pl
>>    script helps).
>> * simplify check_for_file + remove TINFO message as it was unnecessarily
>> verbose
>>    (see bellow)
>>
>> Kind regards,
>> Petr
>>
>> tst_device.c:83: INFO: Found free device '/dev/loop0'
>> mkswap01 1 TPASS: 'mkswap   /dev/loop0 ' passed.
>> mkswap01 2 TPASS: 'mkswap   /dev/loop0 262140' passed.
>> mkswap01 3 TINFO: Can not do swapon on /dev/loop0.
>> mkswap01 3 TINFO: Device size specified by 'mkswap' greater than real
>> size.
>> mkswap01 3 TINFO: Swapon failed expectedly.
>> mkswap01 3 TPASS: 'mkswap -f  /dev/loop0 262148' passed.
>> mkswap01 4 TPASS: 'mkswap -c  /dev/loop0 ' passed.
>> mkswap01 5 TINFO: Can not do swapon on /dev/loop0.
>> mkswap01 5 TINFO: Page size specified by 'mkswap -p' is not equal to
>> system's page size.
>> mkswap01 5 TINFO: Swapon failed expectedly.
>> mkswap01 5 TPASS: 'mkswap -p 2048 /dev/loop0 ' passed.
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap haven't
>> appeared
>> mkswap01 6 TPASS: 'mkswap -L ltp_testswap /dev/loop0 ' passed.
>> mkswap01 7 TPASS: 'mkswap -v1  /dev/loop0 ' passed.
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TINFO: The file /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794
>> haven't appeared
>> mkswap01 8 TPASS: 'mkswap -U b20a69ef-cf9d-49fb-a313-284df6ddd794
>> /dev/loop0 ' passed.
>> mkswap01 9 TPASS: 'mkswap -V  /dev/loop0 ' passed.
>> mkswap01 10 TPASS: 'mkswap -h  /dev/loop0 ' passed.
>>
>> diff --git testcases/commands/mkswap/mkswap01.sh
>> testcases/commands/mkswap/mkswap01.sh
>> index fc07933ae..5ead4cdc5 100755
>> --- testcases/commands/mkswap/mkswap01.sh
>> +++ testcases/commands/mkswap/mkswap01.sh
>> @@ -41,15 +41,9 @@ check_for_file()
>>   {
>>         local path="$1"
>>   -     if [ -z "$path" ]; then
>> +       if [ -z "$path" -o -e "$path" ]; then
>>                 return
>>         fi
>> -
>> -       if [ -e "$path" ]; then
>> -               return 0
>> -       fi
>> -
>> -       tst_res TINFO "The file $path haven't appeared"
>>         return 1
>>   }
>>   @@ -70,7 +64,7 @@ mkswap_verify()
>>                 local pagesize=$PAGE_SIZE
>>         fi
>>   -     TST_RETRY_FUNC "check_for_file "$dev_file"" 0
>> +       TST_RETRY_FUNC "check_for_file $dev_file" 0
>>         swapon $swapfile 2>/dev/null
>>   diff --git testcases/kernel/numa/numa01.sh
>> testcases/kernel/numa/numa01.sh
>> index f8d8f303c..da2f80ddd 100755
>> --- testcases/kernel/numa/numa01.sh
>> +++ testcases/kernel/numa/numa01.sh
>> @@ -302,11 +302,7 @@ test7()
>>     check_ltp_numa_test8_log()
>>   {
>> -       if grep -m1 -q '.' ltp_numa_test8.log; then
>> -               return 0
>> -       fi
>> -
>> -       return 1
>> +       grep -m1 -q '.' ltp_numa_test8.log
>>   }
>>     # Verification of memhog with interleave policy
>>
>>
>
Shuang Qiu Aug. 8, 2018, 7:09 a.m. UTC | #4
Oh,yes,Xiao's patch is related to it.
===cut===
if tst_kvcmp -lt "2.6.35" && [ -n "$dev_file" ]; then
===
But looks like the missing symlink issue is not only related with kernel 
version or loop devices,but sometimes related with mkswap version or 
udev rules.
The testcase sometimes will also fail with new version of kernels.

Thanks
Shuang
On 08/08/2018 02:08 PM, Li Wang wrote:
> Hi Shuang,
>
> Which LTP version do you use?
>
> If I remember correctly, YANG Xiao has already reported this issue and 
> fixed in:
>
> commit 72c52581747301939340af5b1971dea569248226
> Author: Xiao Yang <yangx.jy@cn.fujitsu.com 
> <mailto:yangx.jy@cn.fujitsu.com>>
> Date:  Sun Jun 24 13:59:43 2018 +0800
>
> commands/mkswap01.sh: Fix unexisted "/dev/disk/by-*" files on old kernels
>
>
> On Wed, Aug 8, 2018 at 5:35 AM, Shuang Qiu <shuang.qiu@oracle.com 
> <mailto:shuang.qiu@oracle.com>> wrote:
>
>     Hi,
>
>     Referring to commit 8435d0c7283,some version of swapon will not
>     create the symlink of the device.
>     So it changed TWARN to TINFO so that the test will not break by it.
>     We need to handler such situation in the new patch,or revert the
>     change for swap01.sh.
>
>     Thanks
>     Shuang
>
>
>     On 06/12/2018 11:56 PM, Petr Vorel wrote:
>
>         Hi Li,
>
>             Signed-off-by: Li Wang <liwang@redhat.com
>             <mailto:liwang@redhat.com>>
>             Cc: Petr Vorel <pvorel@suse.cz <mailto:pvorel@suse.cz>>
>             Cc: Cyril Hrubis <chrubis@suse.cz <mailto:chrubis@suse.cz>>
>             ---
>               testcases/commands/mkswap/mkswap01.sh | 17 ++++------
>               testcases/kernel/numa/numa01.sh       | 58
>             +++++++++++++++--------------------
>
>         Thanks for your patch, applied with diff bellow.
>
>         I changed:
>         * fix mixing quotes when calling check_for_file. This was also
>         broken on dash
>            (testing with /bin/sh as symlink to /bin/dash and using
>         checkbashisms.pl <http://checkbashisms.pl>
>            script helps).
>         * simplify check_for_file + remove TINFO message as it was
>         unnecessarily verbose
>            (see bellow)
>
>         Kind regards,
>         Petr
>
>         tst_device.c:83: INFO: Found free device '/dev/loop0'
>         mkswap01 1 TPASS: 'mkswap   /dev/loop0 ' passed.
>         mkswap01 2 TPASS: 'mkswap   /dev/loop0 262140' passed.
>         mkswap01 3 TINFO: Can not do swapon on /dev/loop0.
>         mkswap01 3 TINFO: Device size specified by 'mkswap' greater
>         than real size.
>         mkswap01 3 TINFO: Swapon failed expectedly.
>         mkswap01 3 TPASS: 'mkswap -f  /dev/loop0 262148' passed.
>         mkswap01 4 TPASS: 'mkswap -c  /dev/loop0 ' passed.
>         mkswap01 5 TINFO: Can not do swapon on /dev/loop0.
>         mkswap01 5 TINFO: Page size specified by 'mkswap -p' is not
>         equal to system's page size.
>         mkswap01 5 TINFO: Swapon failed expectedly.
>         mkswap01 5 TPASS: 'mkswap -p 2048 /dev/loop0 ' passed.
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TINFO: The file /dev/disk/by-label/ltp_testswap
>         haven't appeared
>         mkswap01 6 TPASS: 'mkswap -L ltp_testswap /dev/loop0 ' passed.
>         mkswap01 7 TPASS: 'mkswap -v1  /dev/loop0 ' passed.
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TINFO: The file
>         /dev/disk/by-uuid/b20a69ef-cf9d-49fb-a313-284df6ddd794 haven't
>         appeared
>         mkswap01 8 TPASS: 'mkswap -U
>         b20a69ef-cf9d-49fb-a313-284df6ddd794 /dev/loop0 ' passed.
>         mkswap01 9 TPASS: 'mkswap -V  /dev/loop0 ' passed.
>         mkswap01 10 TPASS: 'mkswap -h  /dev/loop0 ' passed.
>
>         diff --git testcases/commands/mkswap/mkswap01.sh
>         testcases/commands/mkswap/mkswap01.sh
>         index fc07933ae..5ead4cdc5 100755
>         --- testcases/commands/mkswap/mkswap01.sh
>         +++ testcases/commands/mkswap/mkswap01.sh
>         @@ -41,15 +41,9 @@ check_for_file()
>           {
>                 local path="$1"
>           -     if [ -z "$path" ]; then
>         +       if [ -z "$path" -o -e "$path" ]; then
>                         return
>                 fi
>         -
>         -       if [ -e "$path" ]; then
>         -               return 0
>         -       fi
>         -
>         -       tst_res TINFO "The file $path haven't appeared"
>                 return 1
>           }
>           @@ -70,7 +64,7 @@ mkswap_verify()
>                         local pagesize=$PAGE_SIZE
>                 fi
>           -     TST_RETRY_FUNC "check_for_file "$dev_file"" 0
>         +       TST_RETRY_FUNC "check_for_file $dev_file" 0
>                 swapon $swapfile 2>/dev/null
>           diff --git testcases/kernel/numa/numa01.sh
>         testcases/kernel/numa/numa01.sh
>         index f8d8f303c..da2f80ddd 100755
>         --- testcases/kernel/numa/numa01.sh
>         +++ testcases/kernel/numa/numa01.sh
>         @@ -302,11 +302,7 @@ test7()
>             check_ltp_numa_test8_log()
>           {
>         -       if grep -m1 -q '.' ltp_numa_test8.log; then
>         -               return 0
>         -       fi
>         -
>         -       return 1
>         +       grep -m1 -q '.' ltp_numa_test8.log
>           }
>             # Verification of memhog with interleave policy
>
>
>
>
>
> -- 
> Regards,
> Li Wang
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Oh,yes,Xiao's patch is related to it.<br>
      ===cut===<br>
      if tst_kvcmp -lt "2.6.35" &amp;&amp; [ -n "$dev_file" ]; then<br>
      ===<br>
      But looks like the missing symlink issue is not only related with
      kernel version or loop devices,but sometimes related with mkswap
      version or udev rules.<br>
      The testcase sometimes will also fail with new version of kernels.
      <br>
      <br>
      Thanks<br>
      Shuang<br>
      On 08/08/2018 02:08 PM, Li Wang wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAEemH2ebjH3BJwXEhmKgkL+0+im-0eQhrCQFczU3WLKHi9m1dg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <div dir="ltr">
        <div class="gmail_default" style="font-size:small">Hi Shuang,</div>
        <div class="gmail_default" style="font-size:small"><br>
        </div>
        <div class="gmail_default" style="font-size:small">Which LTP
          version do you use?</div>
        <div class="gmail_default" style="font-size:small"><br>
        </div>
        <div class="gmail_default" style="font-size:small"><span
style="color:rgb(51,51,51);font-family:arial;font-size:13.91px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">If I remember correctly,
            YANG Xiao has already reported this issue and fixed in:</span><br>
        </div>
        <div class="gmail_default" style="font-size:small"><span
style="color:rgb(51,51,51);font-family:arial;font-size:13.91px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
          </span></div>
        <div class="gmail_default"><span
style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">
            <div class="gmail_default"><font face="arial"
                color="#333333"><span style="font-size:13.91px">commit
                  72c52581747301939340af5b1971dea569248226</span></font></div>
            <div class="gmail_default"><font face="arial"
                color="#333333"><span style="font-size:13.91px">Author:
                  Xiao Yang &lt;<a href="mailto:yangx.jy@cn.fujitsu.com"
                    moz-do-not-send="true">yangx.jy@cn.fujitsu.com</a>&gt;</span></font></div>
            <div class="gmail_default"><font face="arial"
                color="#333333"><span style="font-size:13.91px">Date: 
                   Sun Jun 24 13:59:43 2018 +0800</span></font></div>
            <div class="gmail_default"><font face="arial"
                color="#333333"><span style="font-size:13.91px"><br>
                </span></font></div>
            <div class="gmail_default"><font face="arial"
                color="#333333"><span style="font-size:13.91px">   
                  commands/mkswap01.sh: Fix unexisted "/dev/disk/by-*"
                  files on old kernels</span></font></div>
            <div
              style="color:rgb(51,51,51);font-family:arial;font-size:13.91px"><br>
            </div>
          </span></div>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Wed, Aug 8, 2018 at 5:35 AM,
            Shuang Qiu <span dir="ltr">&lt;<a
                href="mailto:shuang.qiu@oracle.com" target="_blank"
                moz-do-not-send="true">shuang.qiu@oracle.com</a>&gt;</span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
              <br>
              Referring to commit 8435d0c7283,some version of swapon
              will not create the symlink of the device.<br>
              So it changed TWARN to TINFO so that the test will not
              break by it.<br>
              We need to handler such situation in the new patch,or
              revert the change for swap01.sh.<br>
              <br>
              Thanks<span class="HOEnZb"><font color="#888888"><br>
                  Shuang</font></span>
              <div class="HOEnZb">
                <div class="h5"><br>
                  <br>
                  On 06/12/2018 11:56 PM, Petr Vorel wrote:<br>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    Hi Li,<br>
                    <br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      Signed-off-by: Li Wang &lt;<a
                        href="mailto:liwang@redhat.com" target="_blank"
                        moz-do-not-send="true">liwang@redhat.com</a>&gt;<br>
                      Cc: Petr Vorel &lt;<a href="mailto:pvorel@suse.cz"
                        target="_blank" moz-do-not-send="true">pvorel@suse.cz</a>&gt;<br>
                      Cc: Cyril Hrubis &lt;<a
                        href="mailto:chrubis@suse.cz" target="_blank"
                        moz-do-not-send="true">chrubis@suse.cz</a>&gt;<br>
                      ---<br>
                        testcases/commands/mkswap/mksw<wbr>ap01.sh | 17
                      ++++------<br>
                        testcases/kernel/numa/numa01.s<wbr>h       | 58
                      +++++++++++++++---------------<wbr>-----<br>
                    </blockquote>
                    Thanks for your patch, applied with diff bellow.<br>
                    <br>
                    I changed:<br>
                    * fix mixing quotes when calling check_for_file.
                    This was also broken on dash<br>
                       (testing with /bin/sh as symlink to /bin/dash and
                    using <a href="http://checkbashisms.pl"
                      rel="noreferrer" target="_blank"
                      moz-do-not-send="true">checkbashisms.pl</a><br>
                       script helps).<br>
                    * simplify check_for_file + remove TINFO message as
                    it was unnecessarily verbose<br>
                       (see bellow)<br>
                    <br>
                    Kind regards,<br>
                    Petr<br>
                    <br>
                    tst_device.c:83: INFO: Found free device
                    '/dev/loop0'<br>
                    mkswap01 1 TPASS: 'mkswap   /dev/loop0 ' passed.<br>
                    mkswap01 2 TPASS: 'mkswap   /dev/loop0 262140'
                    passed.<br>
                    mkswap01 3 TINFO: Can not do swapon on /dev/loop0.<br>
                    mkswap01 3 TINFO: Device size specified by 'mkswap'
                    greater than real size.<br>
                    mkswap01 3 TINFO: Swapon failed expectedly.<br>
                    mkswap01 3 TPASS: 'mkswap -f  /dev/loop0 262148'
                    passed.<br>
                    mkswap01 4 TPASS: 'mkswap -c  /dev/loop0 ' passed.<br>
                    mkswap01 5 TINFO: Can not do swapon on /dev/loop0.<br>
                    mkswap01 5 TINFO: Page size specified by 'mkswap -p'
                    is not equal to system's page size.<br>
                    mkswap01 5 TINFO: Swapon failed expectedly.<br>
                    mkswap01 5 TPASS: 'mkswap -p 2048 /dev/loop0 '
                    passed.<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TINFO: The file
                    /dev/disk/by-label/ltp_testswa<wbr>p haven't
                    appeared<br>
                    mkswap01 6 TPASS: 'mkswap -L ltp_testswap /dev/loop0
                    ' passed.<br>
                    mkswap01 7 TPASS: 'mkswap -v1  /dev/loop0 ' passed.<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TINFO: The file
                    /dev/disk/by-uuid/b20a69ef-cf9<wbr>d-49fb-a313-284df6ddd794
                    haven't appeared<br>
                    mkswap01 8 TPASS: 'mkswap -U
                    b20a69ef-cf9d-49fb-a313-284df6<wbr>ddd794 /dev/loop0
                    ' passed.<br>
                    mkswap01 9 TPASS: 'mkswap -V  /dev/loop0 ' passed.<br>
                    mkswap01 10 TPASS: 'mkswap -h  /dev/loop0 ' passed.<br>
                    <br>
                    diff --git testcases/commands/mkswap/mksw<wbr>ap01.sh
                    testcases/commands/mkswap/mksw<wbr>ap01.sh<br>
                    index fc07933ae..5ead4cdc5 100755<br>
                    --- testcases/commands/mkswap/mksw<wbr>ap01.sh<br>
                    +++ testcases/commands/mkswap/mksw<wbr>ap01.sh<br>
                    @@ -41,15 +41,9 @@ check_for_file()<br>
                      {<br>
                            local path="$1"<br>
                      -     if [ -z "$path" ]; then<br>
                    +       if [ -z "$path" -o -e "$path" ]; then<br>
                                    return<br>
                            fi<br>
                    -<br>
                    -       if [ -e "$path" ]; then<br>
                    -               return 0<br>
                    -       fi<br>
                    -<br>
                    -       tst_res TINFO "The file $path haven't
                    appeared"<br>
                            return 1<br>
                      }<br>
                      @@ -70,7 +64,7 @@ mkswap_verify()<br>
                                    local pagesize=$PAGE_SIZE<br>
                            fi<br>
                      -     TST_RETRY_FUNC "check_for_file "$dev_file""
                    0<br>
                    +       TST_RETRY_FUNC "check_for_file $dev_file" 0<br>
                            swapon $swapfile 2&gt;/dev/null<br>
                      diff --git testcases/kernel/numa/numa01.s<wbr>h
                    testcases/kernel/numa/numa01.s<wbr>h<br>
                    index f8d8f303c..da2f80ddd 100755<br>
                    --- testcases/kernel/numa/numa01.s<wbr>h<br>
                    +++ testcases/kernel/numa/numa01.s<wbr>h<br>
                    @@ -302,11 +302,7 @@ test7()<br>
                        check_ltp_numa_test8_log()<br>
                      {<br>
                    -       if grep -m1 -q '.' ltp_numa_test8.log; then<br>
                    -               return 0<br>
                    -       fi<br>
                    -<br>
                    -       return 1<br>
                    +       grep -m1 -q '.' ltp_numa_test8.log<br>
                      }<br>
                        # Verification of memhog with interleave policy<br>
                    <br>
                  </blockquote>
                  <br>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
          <br clear="all">
          <div><br>
          </div>
          -- <br>
          <div class="gmail_signature" data-smartmail="gmail_signature">
            <div dir="ltr">
              <div>Regards,<br>
              </div>
              <div>Li Wang<br>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>
Li Wang Aug. 8, 2018, 7:35 a.m. UTC | #5
Shuang Qiu <shuang.qiu@oracle.com> wrote:

> Oh,yes,Xiao's patch is related to it.
> ===cut===
> if tst_kvcmp -lt "2.6.35" && [ -n "$dev_file" ]; then
> ===
> But looks like the missing symlink issue is not only related with kernel
> version or loop devices,but sometimes related with mkswap version or udev
> rules.
> The testcase sometimes will also fail with new version of kernels.
>

Hmm, if that is true. We may need to rewrite the judgement according the
real situation.

check_symlink_support()
{
        if support symlink
                return 0
        else
                return 1
}

if ! check_symlink_support ; then
        tst_res TINFO "Waiting for $dev_file to appear"
        tst_sleep 100ms
else
        TST_RETRY_FUNC "check_for_file $dev_file" 0
fi

Or, any better idea?
Shuang Qiu Aug. 10, 2018, 7:04 a.m. UTC | #6
On 08/08/2018 03:35 PM, Li Wang wrote:
>
> Shuang Qiu <shuang.qiu@oracle.com <mailto:shuang.qiu@oracle.com>> wrote:
>
>     Oh,yes,Xiao's patch is related to it.
>     ===cut===
>     if tst_kvcmp -lt "2.6.35" && [ -n "$dev_file" ]; then
>     ===
>     But looks like the missing symlink issue is not only related with
>     kernel version or loop devices,but sometimes related with mkswap
>     version or udev rules.
>     The testcase sometimes will also fail with new version of kernels.
>
>
> Hmm, if that is true. We may need to rewrite the judgement according 
> the real situation.
>
> check_symlink_support()
> {
> if support symlink
>         return 0
> else
>         return 1
> }
>
> if ! check_symlink_support ; then
>         tst_res TINFO "Waiting for $dev_file to appear"
>         tst_sleep 100ms
> else
>         TST_RETRY_FUNC "check_for_file $dev_file" 0
> fi
>
> Or, any better idea?
Yes,this is a great solution.
But it is really hard to define the support symlink situation for 
different releases and userspace versions.
The simplest way is revert the patch for mkswap01

Thanks
Shuang
>
> -- 
> Regards,
> Li Wang
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 08/08/2018 03:35 PM, Li Wang wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAEemH2cHh94s_DSwN73GoTv0zOeS3xK0AsOFpq6iNKggvzG1Lw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <div dir="ltr">
        <div class="gmail_default" style="font-size:small"><br>
        </div>
        <div class="gmail_extra">
          <div class="gmail_quote">Shuang Qiu <span dir="ltr">&lt;<a
                href="mailto:shuang.qiu@oracle.com" target="_blank"
                moz-do-not-send="true">shuang.qiu@oracle.com</a>&gt;</span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">
              <div bgcolor="#FFFFFF">
                <div
                  class="m_-5268066355035292330gmail-m_1519280404302380598moz-cite-prefix">Oh,yes,Xiao's
                  patch is related to it.<br>
                  ===cut===<br>
                  if tst_kvcmp -lt "2.6.35" &amp;&amp; [ -n "$dev_file"
                  ]; then<br>
                  ===<br>
                  But looks like the missing symlink issue is not only
                  related with kernel version or loop devices,but
                  sometimes related with mkswap version or udev rules.<br>
                  The testcase sometimes will also fail with new version
                  of kernels.
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>
              <div class="gmail_default" style="font-size:small">Hmm, if
                that is true. We may need to rewrite the judgement
                according the real situation.</div>
            </div>
            <div>
              <div class="gmail_default" style="font-size:small"><br>
              </div>
            </div>
            <div>
              <div class="gmail_default" style="font-size:small">check_symlink_support()</div>
              <div class="gmail_default" style="font-size:small">{</div>
              <div class="gmail_default" style="font-size:small">       
                if support symlink</div>
              <div class="gmail_default" style="font-size:small">       
                        return 0</div>
              <div class="gmail_default" style="font-size:small">       
                else</div>
              <div class="gmail_default" style="font-size:small">       
                        return 1</div>
              <div class="gmail_default" style="font-size:small">}</div>
              <br>
            </div>
            <div>
              <div class="gmail_default" style="font-size:small">if !
                check_symlink_support ; then</div>
              <div class="gmail_default">        tst_res TINFO "Waiting
                for $dev_file to appear"</div>
              <div class="gmail_default">        tst_sleep 100ms</div>
              <div class="gmail_default">else</div>
              <div class="gmail_default">        TST_RETRY_FUNC
                "check_for_file $dev_file" 0</div>
              <div class="gmail_default">fi</div>
            </div>
            <div class="gmail_default" style="font-size:small"><br>
            </div>
            <div>
              <div class="gmail_default" style="font-size:small">Or, any
                better idea?</div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    Yes,this is a great solution.<br>
    But it is really hard to define the support symlink situation for
    different releases and userspace versions.<br>
    The simplest way is revert the patch for mkswap01<br>
    <br>
    Thanks<br>
    Shuang<br>
    <blockquote type="cite"
cite="mid:CAEemH2cHh94s_DSwN73GoTv0zOeS3xK0AsOFpq6iNKggvzG1Lw@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_extra">
          <div><br>
          </div>
          -- <br>
          <div class="m_-5268066355035292330gmail_signature">
            <div dir="ltr">
              <div>Regards,<br>
              </div>
              <div>Li Wang<br>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>
diff mbox series

Patch

diff --git a/testcases/commands/mkswap/mkswap01.sh b/testcases/commands/mkswap/mkswap01.sh
index 1c01c86..fc07933 100755
--- a/testcases/commands/mkswap/mkswap01.sh
+++ b/testcases/commands/mkswap/mkswap01.sh
@@ -37,25 +37,20 @@  setup()
 	DEVICE_SIZE=$((($real_size/$PAGE_SIZE * $PAGE_SIZE)/1024))
 }
 
-wait_for_file()
+check_for_file()
 {
 	local path="$1"
-	local retries=10
 
 	if [ -z "$path" ]; then
 		return
 	fi
 
-	while [ $retries -gt 0 ]; do
-		if [ -e "$path" ]; then
-			return
-		fi
-		tst_res TINFO "Waiting for $path to appear"
-		retries=$((retries - 1))
-		tst_sleep 10ms
-	done
+	if [ -e "$path" ]; then
+		return 0
+	fi
 
 	tst_res TINFO "The file $path haven't appeared"
+	return 1
 }
 
 mkswap_verify()
@@ -75,7 +70,7 @@  mkswap_verify()
 		local pagesize=$PAGE_SIZE
 	fi
 
-	wait_for_file "$dev_file"
+	TST_RETRY_FUNC "check_for_file "$dev_file"" 0
 
 	swapon $swapfile 2>/dev/null
 
diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
index 27a2f2f..f8d8f30 100755
--- a/testcases/kernel/numa/numa01.sh
+++ b/testcases/kernel/numa/numa01.sh
@@ -59,25 +59,17 @@  extract_numastat_p()
 	echo $(numastat -p $pid |awk '/^Total/ {print $'$node'}')
 }
 
-wait_for_support_numa()
+check_for_support_numa()
 {
 	local pid=$1
-	local retries=20
 
-	while [ $retries -gt 0 ]; do
-		local state=$(awk '{print $3}' /proc/$pid/stat)
+	local state=$(awk '{print $3}' /proc/$pid/stat)
 
-		if [ $state = 'T' ]; then
-			break
-		fi
-
-		retries=$((retries-1))
-		tst_sleep 50ms
-	done
-
-	if [ $retries -le 0 ]; then
-		tst_brk TBROK "Timeouted while waiting for support_numa ($pid)"
+	if [ $state = 'T' ]; then
+		return 0
 	fi
+
+	return 1
 }
 
 setup()
@@ -109,7 +101,7 @@  test1()
 		numactl --cpunodebind=$node --membind=$node support_numa alloc_1MB &
 		pid=$!
 
-		wait_for_support_numa $pid
+		TST_RETRY_FUNC "check_for_support_numa $pid" 0
 
 		Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
 		if [ $(echo "$Mem_curr < $MB" | bc) -eq 1 ]; then
@@ -143,7 +135,7 @@  test2()
 		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa alloc_1MB &
 		pid=$!
 
-		wait_for_support_numa $pid
+		TST_RETRY_FUNC "check_for_support_numa $pid" 0
 
 		Mem_curr=$(echo "$(extract_numastat_p $pid $Preferred_node) * $MB" |bc)
 		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
@@ -179,7 +171,7 @@  test3()
 		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa alloc_1MB_shared &
 		pid=$!
 
-		wait_for_support_numa $pid
+		TST_RETRY_FUNC "check_for_support_numa $pid" 0
 
 		Mem_curr=$(echo "$(extract_numastat_p $pid $Preferred_node) * $MB" |bc)
 		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
@@ -206,7 +198,7 @@  test4()
 	numactl --interleave=all support_numa alloc_1MB &
 	pid=$!
 
-	wait_for_support_numa $pid
+	TST_RETRY_FUNC "check_for_support_numa $pid" 0
 
 	for node in $nodes_list; do
 		Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
@@ -233,7 +225,7 @@  test5()
 	numactl --interleave=all support_numa alloc_1MB_shared &
 	pid=$!
 
-	wait_for_support_numa $pid
+	TST_RETRY_FUNC "check_for_support_numa $pid" 0
 
 	for node in $nodes_list; do
 		Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
@@ -292,7 +284,7 @@  test7()
 		numactl --cpunodebind=$node --localalloc support_numa alloc_1MB &
 		pid=$!
 
-		wait_for_support_numa $pid
+		TST_RETRY_FUNC "check_for_support_numa $pid" 0
 
 		Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
 		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
@@ -308,6 +300,15 @@  test7()
 	tst_res TPASS "NUMA local node allocation"
 }
 
+check_ltp_numa_test8_log()
+{
+	if grep -m1 -q '.' ltp_numa_test8.log; then
+		return 0
+	fi
+
+	return 1
+}
+
 # Verification of memhog with interleave policy
 test8()
 {
@@ -318,16 +319,7 @@  test8()
 	numactl --interleave=all memhog -r1000000 1MB >ltp_numa_test8.log 2>&1 &
 	pid=$!
 
-	local retries=20
-	while [ $retries -gt 0 ]; do
-
-		if grep -m1 -q '.' ltp_numa_test8.log; then
-			break
-		fi
-
-		retries=$((retries-1))
-		tst_sleep 50ms
-	done
+	TST_RETRY_FUNC "check_ltp_numa_test8_log" 0
 
 	for node in $nodes_list; do
 		Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
@@ -396,7 +388,7 @@  test10()
 		numactl --preferred=$node support_numa alloc_1MB &
 		pid=$!
 
-		wait_for_support_numa $pid
+		TST_RETRY_FUNC "check_for_support_numa $pid" 0
 
 		migratepages $pid $node $Preferred_node
 
@@ -439,7 +431,7 @@  test11()
 
 		numactl --cpunodebind=$node --membind=$node support_numa alloc_1huge_page &
 		pid=$!
-		wait_for_support_numa $pid
+		TST_RETRY_FUNC "check_for_support_numa $pid" 0
 
 		Mem_huge=$(echo $(numastat -p $pid |awk '/^Huge/ {print $'$((node+2))'}'))
 		Mem_huge=$((${Mem_huge%.*} * 1024))
@@ -482,7 +474,7 @@  test12()
 		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa alloc_2HPSZ_THP &
 		pid=$!
 
-		wait_for_support_numa $pid
+		TST_RETRY_FUNC "check_for_support_numa $pid" 0
 
 		Mem_curr=$(echo "$(extract_numastat_p $pid $Preferred_node) * 1024" |bc)
 		if [ $(echo "$Mem_curr < $HPAGE_SIZE * 2" |bc ) -eq 1 ]; then