public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] "nanosleep{02〜04}" testcase failed
@ 2009-12-21  7:18 Mitani
  2009-12-22  2:45 ` [LTP] "nanosleep{02~04}" " Garrett Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Mitani @ 2009-12-21  7:18 UTC (permalink / raw)
  To: ltp-list

Hi,

I found that "nanosleep{02〜04}" testcase failed like follow example.
----------
nanosleep02    1  TFAIL  :  child process exited abnormally
----------

In ${LTPROOT}/testcases/kernel/syscalls/nanosleep/nanosleep{02〜04}.c, 
WEXITSTATUS(status) is used to judge whether child process did exit 
normally.
But WEXITSTATUS macro is used only when WIFEXITED macro returned "true".
So, it cannot get the correct results and it terminated with the above
error. 

To solve this problem, I thought that we had better use WIFEXITED macro
instead of the WEXITSTATUS macro.
Here are patches to fix these problem:
============
--- nanosleep02.c	2009-11-02 22:57:17.000000000 +0900
+++ nanosleep02.c.new	2009-12-21 14:15:19.000000000 +0900
@@ -162,10 +162,10 @@
 
 		/* Wait for child to execute */
 		wait(&status);
-		if (WEXITSTATUS(status) == 0) {
+		if (WIFEXITED(status)) {
 			tst_resm(TPASS, "Functionality of nanosleep() "
 				 "is correct");
-		} else if (WEXITSTATUS(status) == 1) {
+		} else if (!WIFEXITED(status)) {
 			tst_resm(TFAIL, "child process exited abnormally");
 		}
 	}			/* End for TEST_LOOPING */

============

============
--- nanosleep03.c	2009-11-02 22:57:17.000000000 +0900
+++ nanosleep03.c.new	2009-12-21 15:03:52.000000000 +0900
@@ -143,10 +143,10 @@
 
 		/* Wait for child to execute */
 		wait(&status);
-		if (WEXITSTATUS(status) == 0) {
+		if (WIFEXITED(status)) {
 			tst_resm(TPASS, "nanosleep() fails, interrupted"
 				 " by signal, error:%d", EINTR);
-		} else if (WEXITSTATUS(status) == 1) {
+		} else if (!WIFEXITED(status)) {
 			tst_resm(TFAIL, "child process exited abnormally");
 		}
 	}			/* End for TEST_LOOPING */

============

============
--- nanosleep04.c	2009-11-02 22:57:17.000000000 +0900
+++ nanosleep04.c.new	2009-12-21 15:04:24.000000000 +0900
@@ -147,10 +147,10 @@
 
 		/* Wait for child to execute */
 		wait(&status);
-		if (WEXITSTATUS(status) == 0) {
+		if (WIFEXITED(status)) {
 			tst_resm(TPASS, "nanosleep() fails, invalid pause "
 				 "time, error:%d", EINVAL);
-		} else if (WEXITSTATUS(status) == 1) {
+		} else if (!WIFEXITED(status)) {
 			tst_resm(TFAIL, "child process exited abnormally");
 		}
 	}			/* End for TEST_LOOPING */
============



------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] "nanosleep{02~04}" testcase failed
  2009-12-21  7:18 [LTP] "nanosleep{02〜04}" testcase failed Mitani
@ 2009-12-22  2:45 ` Garrett Cooper
  2009-12-22  5:17   ` Mitani
  0 siblings, 1 reply; 4+ messages in thread
From: Garrett Cooper @ 2009-12-22  2:45 UTC (permalink / raw)
  To: Mitani; +Cc: ltp-list

2009/12/20 Mitani <mitani@ryobi.co.jp>:
> Hi,
>
> I found that "nanosleep{02~04}" testcase failed like follow example.
> ----------
> nanosleep02    1  TFAIL  :  child process exited abnormally
> ----------
>
> In ${LTPROOT}/testcases/kernel/syscalls/nanosleep/nanosleep{02~04}.c,
> WEXITSTATUS(status) is used to judge whether child process did exit
> normally.
> But WEXITSTATUS macro is used only when WIFEXITED macro returned "true".
> So, it cannot get the correct results and it terminated with the above
> error.
>
> To solve this problem, I thought that we had better use WIFEXITED macro
> instead of the WEXITSTATUS macro.
> Here are patches to fix these problem:
> ============
> --- nanosleep02.c       2009-11-02 22:57:17.000000000 +0900
> +++ nanosleep02.c.new   2009-12-21 14:15:19.000000000 +0900
> @@ -162,10 +162,10 @@
>
>                /* Wait for child to execute */
>                wait(&status);
> -               if (WEXITSTATUS(status) == 0) {
> +               if (WIFEXITED(status)) {
>                        tst_resm(TPASS, "Functionality of nanosleep() "
>                                 "is correct");
> -               } else if (WEXITSTATUS(status) == 1) {
> +               } else if (!WIFEXITED(status)) {
>                        tst_resm(TFAIL, "child process exited abnormally");
>                }
>        }                       /* End for TEST_LOOPING */
>
> ============
>
> ============
> --- nanosleep03.c       2009-11-02 22:57:17.000000000 +0900
> +++ nanosleep03.c.new   2009-12-21 15:03:52.000000000 +0900
> @@ -143,10 +143,10 @@
>
>                /* Wait for child to execute */
>                wait(&status);
> -               if (WEXITSTATUS(status) == 0) {
> +               if (WIFEXITED(status)) {
>                        tst_resm(TPASS, "nanosleep() fails, interrupted"
>                                 " by signal, error:%d", EINTR);
> -               } else if (WEXITSTATUS(status) == 1) {
> +               } else if (!WIFEXITED(status)) {
>                        tst_resm(TFAIL, "child process exited abnormally");
>                }
>        }                       /* End for TEST_LOOPING */
>
> ============
>
> ============
> --- nanosleep04.c       2009-11-02 22:57:17.000000000 +0900
> +++ nanosleep04.c.new   2009-12-21 15:04:24.000000000 +0900
> @@ -147,10 +147,10 @@
>
>                /* Wait for child to execute */
>                wait(&status);
> -               if (WEXITSTATUS(status) == 0) {
> +               if (WIFEXITED(status)) {
>                        tst_resm(TPASS, "nanosleep() fails, invalid pause "
>                                 "time, error:%d", EINVAL);
> -               } else if (WEXITSTATUS(status) == 1) {
> +               } else if (!WIFEXITED(status)) {
>                        tst_resm(TFAIL, "child process exited abnormally");
>                }
>        }                       /* End for TEST_LOOPING */
> ============

I agree that the test's validation step is written incorrectly, as per
the wait(2) manpage:


       WIFEXITED(status)
              returns true if the child terminated normally, that is, by call-
              ing exit(3) or _exit(2), or by returning from main().

       WEXITSTATUS(status)
              returns the exit status of the  child.   This  consists  of  the
              least  significant  8 bits of the status argument that the child
              specified in a call to exit(3) or _exit(2) or  as  the  argument
              for  a  return  statement  in main().  This macro should only be
              employed if WIFEXITED returned true.

    in particular the precondition for calling WEXITSTATUS, but should
it be WIFEXITED(status) && WEXITSTATUS(status) == 0 => PASS, else
FAIL?

Thanks,
-Garrett
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] "nanosleep{02~04}" testcase failed
  2009-12-22  2:45 ` [LTP] "nanosleep{02~04}" " Garrett Cooper
@ 2009-12-22  5:17   ` Mitani
  2009-12-22 17:35     ` Garrett Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Mitani @ 2009-12-22  5:17 UTC (permalink / raw)
  To: 'Garrett Cooper'; +Cc: ltp-list


I revised patch into "WIFEXITED(status) && WEXITSTATUS(status) == 0", and tried to test.
After that, "nanosleep" could work correctly.
I agree with your proposal. 

Thank you for your help!

-Tomonori Mitani

-----Original Message-----
From: Garrett Cooper [mailto:yanegomi@gmail.com] 
Sent: Tuesday, December 22, 2009 11:45 AM
To: Mitani
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] "nanosleep{02~04}" testcase failed

2009/12/20 Mitani <mitani@ryobi.co.jp>:
> Hi,
>
> I found that "nanosleep{02~04}" testcase failed like follow example.
> ----------
> nanosleep02    1  TFAIL  :  child process exited abnormally
> ----------
>
> In ${LTPROOT}/testcases/kernel/syscalls/nanosleep/nanosleep{02~04}.c,
> WEXITSTATUS(status) is used to judge whether child process did exit
> normally.
> But WEXITSTATUS macro is used only when WIFEXITED macro returned "true".
> So, it cannot get the correct results and it terminated with the above
> error.
>
> To solve this problem, I thought that we had better use WIFEXITED macro
> instead of the WEXITSTATUS macro.
> Here are patches to fix these problem:
> ============
> --- nanosleep02.c       2009-11-02 22:57:17.000000000 +0900
> +++ nanosleep02.c.new   2009-12-21 14:15:19.000000000 +0900
> @@ -162,10 +162,10 @@
>
>                /* Wait for child to execute */
>                wait(&status);
> -               if (WEXITSTATUS(status) == 0) {
> +               if (WIFEXITED(status)) {
>                        tst_resm(TPASS, "Functionality of nanosleep() "
>                                 "is correct");
> -               } else if (WEXITSTATUS(status) == 1) {
> +               } else if (!WIFEXITED(status)) {
>                        tst_resm(TFAIL, "child process exited abnormally");
>                }
>        }                       /* End for TEST_LOOPING */
>
> ============
>
> ============
> --- nanosleep03.c       2009-11-02 22:57:17.000000000 +0900
> +++ nanosleep03.c.new   2009-12-21 15:03:52.000000000 +0900
> @@ -143,10 +143,10 @@
>
>                /* Wait for child to execute */
>                wait(&status);
> -               if (WEXITSTATUS(status) == 0) {
> +               if (WIFEXITED(status)) {
>                        tst_resm(TPASS, "nanosleep() fails, interrupted"
>                                 " by signal, error:%d", EINTR);
> -               } else if (WEXITSTATUS(status) == 1) {
> +               } else if (!WIFEXITED(status)) {
>                        tst_resm(TFAIL, "child process exited abnormally");
>                }
>        }                       /* End for TEST_LOOPING */
>
> ============
>
> ============
> --- nanosleep04.c       2009-11-02 22:57:17.000000000 +0900
> +++ nanosleep04.c.new   2009-12-21 15:04:24.000000000 +0900
> @@ -147,10 +147,10 @@
>
>                /* Wait for child to execute */
>                wait(&status);
> -               if (WEXITSTATUS(status) == 0) {
> +               if (WIFEXITED(status)) {
>                        tst_resm(TPASS, "nanosleep() fails, invalid pause "
>                                 "time, error:%d", EINVAL);
> -               } else if (WEXITSTATUS(status) == 1) {
> +               } else if (!WIFEXITED(status)) {
>                        tst_resm(TFAIL, "child process exited abnormally");
>                }
>        }                       /* End for TEST_LOOPING */
> ============

I agree that the test's validation step is written incorrectly, as per
the wait(2) manpage:


       WIFEXITED(status)
              returns true if the child terminated normally, that is, by call-
              ing exit(3) or _exit(2), or by returning from main().

       WEXITSTATUS(status)
              returns the exit status of the  child.   This  consists  of  the
              least  significant  8 bits of the status argument that the child
              specified in a call to exit(3) or _exit(2) or  as  the  argument
              for  a  return  statement  in main().  This macro should only be
              employed if WIFEXITED returned true.

    in particular the precondition for calling WEXITSTATUS, but should
it be WIFEXITED(status) && WEXITSTATUS(status) == 0 => PASS, else
FAIL?

Thanks,
-Garrett



------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] "nanosleep{02~04}" testcase failed
  2009-12-22  5:17   ` Mitani
@ 2009-12-22 17:35     ` Garrett Cooper
  0 siblings, 0 replies; 4+ messages in thread
From: Garrett Cooper @ 2009-12-22 17:35 UTC (permalink / raw)
  To: Mitani; +Cc: ltp-list

On Mon, Dec 21, 2009 at 9:17 PM, Mitani <mitani@ryobi.co.jp> wrote:
>
> I revised patch into "WIFEXITED(status) && WEXITSTATUS(status) == 0", and tried to test.
> After that, "nanosleep" could work correctly.
> I agree with your proposal.
>
> Thank you for your help!
>
> -Tomonori Mitani
>
> -----Original Message-----
> From: Garrett Cooper [mailto:yanegomi@gmail.com]
> Sent: Tuesday, December 22, 2009 11:45 AM
> To: Mitani
> Cc: ltp-list@lists.sourceforge.net
> Subject: Re: [LTP] "nanosleep{02~04}" testcase failed
>
> 2009/12/20 Mitani <mitani@ryobi.co.jp>:
>> Hi,
>>
>> I found that "nanosleep{02~04}" testcase failed like follow example.
>> ----------
>> nanosleep02    1  TFAIL  :  child process exited abnormally
>> ----------
>>
>> In ${LTPROOT}/testcases/kernel/syscalls/nanosleep/nanosleep{02~04}.c,
>> WEXITSTATUS(status) is used to judge whether child process did exit
>> normally.
>> But WEXITSTATUS macro is used only when WIFEXITED macro returned "true".
>> So, it cannot get the correct results and it terminated with the above
>> error.
>>
>> To solve this problem, I thought that we had better use WIFEXITED macro
>> instead of the WEXITSTATUS macro.
>> Here are patches to fix these problem:
>> ============
>> --- nanosleep02.c       2009-11-02 22:57:17.000000000 +0900
>> +++ nanosleep02.c.new   2009-12-21 14:15:19.000000000 +0900
>> @@ -162,10 +162,10 @@
>>
>>                /* Wait for child to execute */
>>                wait(&status);
>> -               if (WEXITSTATUS(status) == 0) {
>> +               if (WIFEXITED(status)) {
>>                        tst_resm(TPASS, "Functionality of nanosleep() "
>>                                 "is correct");
>> -               } else if (WEXITSTATUS(status) == 1) {
>> +               } else if (!WIFEXITED(status)) {
>>                        tst_resm(TFAIL, "child process exited abnormally");
>>                }
>>        }                       /* End for TEST_LOOPING */
>>
>> ============
>>
>> ============
>> --- nanosleep03.c       2009-11-02 22:57:17.000000000 +0900
>> +++ nanosleep03.c.new   2009-12-21 15:03:52.000000000 +0900
>> @@ -143,10 +143,10 @@
>>
>>                /* Wait for child to execute */
>>                wait(&status);
>> -               if (WEXITSTATUS(status) == 0) {
>> +               if (WIFEXITED(status)) {
>>                        tst_resm(TPASS, "nanosleep() fails, interrupted"
>>                                 " by signal, error:%d", EINTR);
>> -               } else if (WEXITSTATUS(status) == 1) {
>> +               } else if (!WIFEXITED(status)) {
>>                        tst_resm(TFAIL, "child process exited abnormally");
>>                }
>>        }                       /* End for TEST_LOOPING */
>>
>> ============
>>
>> ============
>> --- nanosleep04.c       2009-11-02 22:57:17.000000000 +0900
>> +++ nanosleep04.c.new   2009-12-21 15:04:24.000000000 +0900
>> @@ -147,10 +147,10 @@
>>
>>                /* Wait for child to execute */
>>                wait(&status);
>> -               if (WEXITSTATUS(status) == 0) {
>> +               if (WIFEXITED(status)) {
>>                        tst_resm(TPASS, "nanosleep() fails, invalid pause "
>>                                 "time, error:%d", EINVAL);
>> -               } else if (WEXITSTATUS(status) == 1) {
>> +               } else if (!WIFEXITED(status)) {
>>                        tst_resm(TFAIL, "child process exited abnormally");
>>                }
>>        }                       /* End for TEST_LOOPING */
>> ============
>
> I agree that the test's validation step is written incorrectly, as per
> the wait(2) manpage:
>
>
>       WIFEXITED(status)
>              returns true if the child terminated normally, that is, by call-
>              ing exit(3) or _exit(2), or by returning from main().
>
>       WEXITSTATUS(status)
>              returns the exit status of the  child.   This  consists  of  the
>              least  significant  8 bits of the status argument that the child
>              specified in a call to exit(3) or _exit(2) or  as  the  argument
>              for  a  return  statement  in main().  This macro should only be
>              employed if WIFEXITED returned true.
>
>    in particular the precondition for calling WEXITSTATUS, but should
> it be WIFEXITED(status) && WEXITSTATUS(status) == 0 => PASS, else
> FAIL?

Committed -- thanks!
-Garrett
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2009-12-22 17:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-21  7:18 [LTP] "nanosleep{02〜04}" testcase failed Mitani
2009-12-22  2:45 ` [LTP] "nanosleep{02~04}" " Garrett Cooper
2009-12-22  5:17   ` Mitani
2009-12-22 17:35     ` Garrett Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox