All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] Clean up hugemmap02 testcase
@ 2016-01-08  8:20 shuang.qiu
  2016-01-11 11:47 ` Alexey Kodanev
  0 siblings, 1 reply; 3+ messages in thread
From: shuang.qiu @ 2016-01-08  8:20 UTC (permalink / raw)
  To: ltp

From: Shuang Qiu <shuang.qiu@oracle.com>

It misses the cleanup when continue in the loop.
And it also needs to munmap() addr2 for 32-bit.

Signed-off-by: Shuang Qiu <shuang.qiu@oracle.com>
---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
index 1a44993..8c2a9b2 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
@@ -155,24 +155,20 @@ int main(int ac, char **av)
 		addr2 = mmap((void *)low_addr2, map_sz, PROT_READ | PROT_WRITE,
 			     MAP_SHARED, fildes, 0);
 #if __WORDSIZE == 64		/* 64-bit process */
-		if (addr2 == MAP_FAILED) {
+		if (addr2 == MAP_FAILED)
 			tst_resm(TFAIL | TERRNO, "huge mmap failed unexpectedly"
 				 " with %s (64-bit)", TEMPFILE);
-			close(fildes);
-			continue;
-		} else {
+		else {
 			tst_resm(TPASS, "huge mmap succeeded (64-bit)");
 		}
 #else /* 32-bit process */
 		if (addr2 == MAP_FAILED)
 			tst_resm(TFAIL | TERRNO, "huge mmap failed unexpectedly"
 				 " with %s (32-bit)", TEMPFILE);
-		else if (addr2 > 0) {
+		else if (addr2 > 0)
 			tst_resm(TCONF,
 				 "huge mmap failed to test the scenario");
-			close(fildes);
-			continue;
-		} else if (addr == 0)
+		else if (addr == 0)
 			tst_resm(TPASS, "huge mmap succeeded (32-bit)");
 #endif
 
@@ -183,10 +179,8 @@ int main(int ac, char **av)
 					 "munmap of addrlist[%d] failed", i);
 		}
 
-#if __WORDSIZE == 64
 		if (munmap(addr2, map_sz) == -1)
 			tst_brkm(TFAIL | TERRNO, NULL, "huge munmap failed");
-#endif
 		if (munmap(addr, page_sz) == -1)
 			tst_brkm(TFAIL | TERRNO, NULL, "munmap failed");
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] Clean up hugemmap02 testcase
  2016-01-08  8:20 [LTP] [PATCH] Clean up hugemmap02 testcase shuang.qiu
@ 2016-01-11 11:47 ` Alexey Kodanev
  2016-01-13  4:30   ` Shuang Qiu
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Kodanev @ 2016-01-11 11:47 UTC (permalink / raw)
  To: ltp

Hi,
On 01/08/2016 11:20 AM, shuang.qiu@oracle.com wrote:
> From: Shuang Qiu <shuang.qiu@oracle.com>
>
> It misses the cleanup when continue in the loop.
> And it also needs to munmap() addr2 for 32-bit.
>
> Signed-off-by: Shuang Qiu <shuang.qiu@oracle.com>
> ---
>   testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c |   14 ++++----------
>   1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
> index 1a44993..8c2a9b2 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
> @@ -155,24 +155,20 @@ int main(int ac, char **av)
>   		addr2 = mmap((void *)low_addr2, map_sz, PROT_READ | PROT_WRITE,
>   			     MAP_SHARED, fildes, 0);
>   #if __WORDSIZE == 64		/* 64-bit process */
> -		if (addr2 == MAP_FAILED) {
> +		if (addr2 == MAP_FAILED)
>   			tst_resm(TFAIL | TERRNO, "huge mmap failed unexpectedly"
>   				 " with %s (64-bit)", TEMPFILE);
> -			close(fildes);
> -			continue;
> -		} else {
> +		else {
>   			tst_resm(TPASS, "huge mmap succeeded (64-bit)");

Looking at the test, there is one more fd ("nfildes") that stays not 
closed after each loop iteration...  we can move open("/dev/zero",...)  
to setup() or close it in the end of the loop, what do you think?

Best regards,
Alexey


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] Clean up hugemmap02 testcase
  2016-01-11 11:47 ` Alexey Kodanev
@ 2016-01-13  4:30   ` Shuang Qiu
  0 siblings, 0 replies; 3+ messages in thread
From: Shuang Qiu @ 2016-01-13  4:30 UTC (permalink / raw)
  To: ltp

On 01/11/2016 07:47 PM, Alexey Kodanev wrote:
> Hi,
> On 01/08/2016 11:20 AM, shuang.qiu@oracle.com wrote:
>> From: Shuang Qiu <shuang.qiu@oracle.com>
>>
>> It misses the cleanup when continue in the loop.
>> And it also needs to munmap() addr2 for 32-bit.
>>
>> Signed-off-by: Shuang Qiu <shuang.qiu@oracle.com>
>> ---
>>   testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c |   14 
>> ++++----------
>>   1 file changed, 4 insertions(+), 10 deletions(-)
>>
>> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c 
>> b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
>> index 1a44993..8c2a9b2 100644
>> --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
>> +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
>> @@ -155,24 +155,20 @@ int main(int ac, char **av)
>>           addr2 = mmap((void *)low_addr2, map_sz, PROT_READ | 
>> PROT_WRITE,
>>                    MAP_SHARED, fildes, 0);
>>   #if __WORDSIZE == 64        /* 64-bit process */
>> -        if (addr2 == MAP_FAILED) {
>> +        if (addr2 == MAP_FAILED)
>>               tst_resm(TFAIL | TERRNO, "huge mmap failed unexpectedly"
>>                    " with %s (64-bit)", TEMPFILE);
>> -            close(fildes);
>> -            continue;
>> -        } else {
>> +        else {
>>               tst_resm(TPASS, "huge mmap succeeded (64-bit)");
>
> Looking at the test, there is one more fd ("nfildes") that stays not 
> closed after each loop iteration...  we can move 
> open("/dev/zero",...)  to setup() or close it in the end of the loop, 
> what do you think?
Yes,thanks for reminder.
I will send another patch to close it in the end of the loop.

Thanks
Shuang
>
> Best regards,
> Alexey
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-13  4:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-08  8:20 [LTP] [PATCH] Clean up hugemmap02 testcase shuang.qiu
2016-01-11 11:47 ` Alexey Kodanev
2016-01-13  4:30   ` Shuang Qiu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.