eclone-2 bug fix
PATCH 1/1 eclone-2 bug fix
From: Sukadev Bhattiprolu <[email protected]>
Date: Mon, 3 May 2010 17:49:32 -0700
Subject: [PATCH 1/1] eclone-2 bug fix
When target-pid is in use, eclone() returns EBUSY, not EAGAIN. The test passes now because eclone() correctly fails, but the test case can do a better job of checking the errno.
--- eclone/eclone-2.c | 49 ++++++++++++++++++++++++------------------------- 1 files changed, 24 insertions(+), 25 deletions(-)
eclone/eclone-2.c +24 -25
@@ -64,14 +64,11 @@ static int do_eclone(int (*child_fn)(void *), void *child_arg,fflush (stdout); } -if (rc <0 && errno ==EAGAIN ) { -printf ("PASS: Unable to create a process with a pid that is " -"in use\n" ); -exit (0 ); - }else { -printf ("ERROR: eclone(): rc %d, errno %d\n" , rc, errno); -return rc; - } +if (rc <0 ) + rc = -errno; + +return rc; + }int main ()
@@ -90,27 +87,29 @@ int main() pid =do_eclone (do_child,CHILD_ARG , flags, nr_pids, pids); -if (verbose) { -printf ("[%d, %d]: Parent waiting for %d\n" ,getpid (), -gettid (), pid); +if (pid == -EBUSY ) { +printf ("PASS: Unable to create a process with a pid that is " +"in use\n" ); +return 0 ; + }else if (pid <0 ) { +printf ("ERROR: eclone(): errno %d\n" , pid); +return 1 ; } +printf ("[%d, %d]: Parent waiting for %d\n" ,getpid (),gettid (), pid); + rc =waitpid (pid, &status, __WALL); -if (rc <0 ) { -printf ("ERROR: " ); - verbose =1 ; - } -if (verbose) { -printf ("\twaitpid(): child %d, rc %d, error %d, status 0x%x\n" , -getpid (), rc, errno, status); -if (rc >=0 ) { -if (WIFEXITED (status)) { -printf ("\t EXITED, %d\n" ,WEXITSTATUS (status)); - }else if (WIFSIGNALED (status)) { -printf ("\t SIGNALED, %d\n" ,WTERMSIG (status)); - } +printf ("\twaitpid(): child %d, rc %d, error %d, status 0x%x\n" , +getpid (), rc, errno, status); + +if (rc >=0 ) { +if (WIFEXITED (status)) { +printf ("\t EXITED, %d\n" ,WEXITSTATUS (status)); + }else if (WIFSIGNALED (status)) { +printf ("\t SIGNALED, %d\n" ,WTERMSIG (status)); } } -return 0 ; + +return 1 ; }
Signature · 1 line
1.6.6.1
A message that is not in the archive (sent off-list or not yet received): 20100504020919.GB5098-r/[email protected]
eclone/eclone-2.c int main() · line 96
Quoted 12 lines · Sukadev Bhattiprolu
eclone/eclone-2.c +7
-3pid =do_eclone (do_child,CHILD_ARG , flags, nr_pids, pids); -if (verbose) { -printf ("[%d, %d]: Parent waiting for %d\n" ,getpid (), -gettid (), pid); +if (pid == -EBUSY ) { +printf ("PASS: Unable to create a process with a pid that is " +"in use\n" ); +return 0 ; + }else if (pid <0 ) { +printf ("ERROR: eclone(): errno %d\n" , pid); +return 1 ;
Note that if pid > 0 you don't print out an error msg. I pushed a trivial patch on top of this one to do so. Pls let me know if I misunderstood and that wasn't right.
thanks,
-serge
A message that is not in the archive (sent off-list or not yet received): 20100504133328.GA10214-r/[email protected]
Serge E. Hallyn [serue-r/[email protected]] wrote:
| Note that if pid > 0 you don't print out an error msg. I pushed a | trivial patch on top of this one to do so. Pls let me know if I | misunderstood and that wasn't right.
Well, if the child was created (i.e pid > 0) do_child() prints a "FAIL" message and the test exits with 1. But the message does not hurt, although for consistency we should mark it "FAIL" rather than "ERROR".
Thanks,
Sukadev
A message that is not in the archive (sent off-list or not yet received): 20100504173051.GA11116-r/[email protected]
Quoted 7 lines · Sukadev Bhattiprolu
Serge E. Hallyn [serue-r/[email protected]] wrote:
| Note that if pid > 0 you don't print out an error msg. I pushed a | trivial patch on top of this one to do so. Pls let me know if I | misunderstood and that wasn't right.Well, if the child was created (i.e pid > 0)
do_child()prints a "FAIL" message and the test exits with 1. But the message does not hurt, although
Thinking in terms of future ltp integration, I'm not sure whether the child doing a TFAIL will result in parent test reporting failure on exit or not, so I prefer the parent report failure when possible.
Quoted 1 line
for consistency we should mark it "FAIL" rather than "ERROR".
Uh, I guess I was following you example :)
I've changed both and pushed.
thanks,
-serge
A message that is not in the archive (sent off-list or not yet received): 20100504193934.GA4781-r/[email protected]
Serge E. Hallyn [serue-r/[email protected]] wrote:
| Quoting Sukadev Bhattiprolu ([email protected]): | > Serge E. Hallyn [serue-r/[email protected]] wrote: | > | Note that if pid > 0 you don't print out an error msg. I pushed a | > | trivial patch on top of this one to do so. Pls let me know if I | > | misunderstood and that wasn't right. | > | > Well, if the child was created (i.e pid > 0) do_child() prints a "FAIL" | > message and the test exits with 1. But the message does not hurt, although | | Thinking in terms of future ltp integration, I'm not sure whether the | child doing a TFAIL will result in parent test reporting failure on | exit or not, so I prefer the parent report failure when possible.
Ok. I guess we can remove the printf() from do_child().
| | > for consistency we should mark it "FAIL" rather than "ERROR". | | Uh, I guess I was following you example :)
In cr-tests, I have been using ERROR for BROK and FAIL for actual failure. If we want to use BROK, there is one other "ERROR" that could be changed too. Here is a patch.
Thanks,
---
From: Sukadev Bhattiprolu <[email protected]>
Date: Tue, 4 May 2010 18:55:32 -0700
Subject: [PATCH 1/1] Use BROK for error messages
Use BROK instead of ERROR for error messages and remove an extra printf() in the child.
--- eclone/eclone-2.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
eclone/eclone-2.c +1 -4
@@ -22,9 +22,6 @@ pid_t pids[2];int do_child (void *arg) { -printf ("FAIL: Child created with [%d, %d], but we expected child " -"creation to fail since pid is in use\n" ,gettid (), -getpid ());exit (2 ); }
@@ -37,7 +34,7 @@ static int do_eclone(int (*child_fn)(void *), void *child_arg, stack =genstack_alloc (STACKSIZE );if (!stack) { -printf ("ERROR: genstack_alloc() returns NULL for size %d\n" , +printf ("BROK: genstack_alloc() returns NULL for size %d\n" ,STACKSIZE );exit (1 ); }
Signature · 1 line
1.6.6.1
A message that is not in the archive (sent off-list or not yet received): 20100505020404.GA19821-r/[email protected]
Serge E. Hallyn
Appliedthanks, applied.
Note that I'm also unhappy with tests which test for too specific an error value (see reported sysctl03 breakage in ltp just today). It's fragile. But I don't feel like tweaking this any more right now, and it's not like I'm sure that letting any <0 errno mean PASS is the way to go either. It's just that it's a maintenance pain... and I guess ltp should come to some conclusion about how to handle it.
thanks,
-serge