From: Subrata <sub...@us...> - 2009-08-07 09:38:56
|
Update of /cvsroot/ltp/ltp/testcases/kernel/syscalls/waitid In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv19139/ltp/testcases/kernel/syscalls/waitid Modified Files: waitid02.c Log Message: Pls find attached patch for waitid02 test case.I have modified the test case.I have also added 2 test scenarios in the test case using WSTOPPED and WNOWAIT. Note: The testcase was failing in LTP July, 2009 release. The warning- "implicit declaration of function 'getpgid", has been removed. Signed-off-by: rohit verma <roh...@gm...>. Index: waitid02.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/waitid/waitid02.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** waitid02.c 30 Jul 2009 15:15:25 -0000 1.2 --- waitid02.c 7 Aug 2009 09:38:47 -0000 1.3 *************** *** 59,63 **** char *TCID = "waitid02"; /* Test program identifier.*/ int testno; ! int TST_TOTAL = 7; /* total number of tests in this file. */ /* Extern Global Functions */ --- 59,63 ---- char *TCID = "waitid02"; /* Test program identifier.*/ int testno; ! int TST_TOTAL = 4; /* total number of tests in this file. */ /* Extern Global Functions */ *************** *** 107,114 **** /******************************************************************************/ void setup() { ! /* Capture signals if any */ ! /* Create temporary directories */ ! TEST_PAUSE; ! tst_tmpdir(); } --- 107,114 ---- /******************************************************************************/ void setup() { ! /* Capture signals if any */ ! /* Create temporary directories */ ! TEST_PAUSE; ! tst_tmpdir(); } *************** *** 116,219 **** int errnochoose(void){ //choose the relative errno ! switch (TEST_ERRNO){ ! case ECHILD: strerror((int)"ECHILD"); ! break; ! case EINTR: strerror((int)"EINTR"); ! break; ! case EINVAL: strerror((int)"EINVAL"); ! break; ! default: strerror((int)"Other Error"); ! } ! tst_exit() ; } int main(int ac, char **av) { ! id_t cpid; ! id_t id1,id2,id3; ! id_t gid1,gid2,gid3; ! siginfo_t infop; ! int i = 0; ! int lc; /* loop counter */ ! char *msg; /* message returned from parse_opts */ /* parse standard options */ ! if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ ! tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); ! tst_exit(); ! } ! setup(); ! /* Check looping state if -i option given */ ! for (lc = 0; TEST_LOOPING(lc); ++lc) { ! Tst_count = 0; ! for (testno = 0; testno < TST_TOTAL; ++testno) { ! ! TEST(waitid(P_ALL,0,&infop,WNOHANG)); ! if(TEST_RETURN == 0) ! tst_resm(TPASS,"Success !"); ! else{ ! tst_resm(TFAIL,"%s failed", TCID); ! errnochoose(); ! } ! // option == WEXITED | WCONTINUED | WSTOPPED | WNOHANG | WNOWAIT ; ! TEST(fork()); ! if(TEST_RETURN == 0){ ! tst_resm(TINFO,"I'm a child,my id is %d,gpid is %d",id1=getpid(),gid1=getpgid(0)); exit(5); ! } ! ! TEST(fork()); ! if(TEST_RETURN == 0){ ! tst_resm(TINFO,"I'm a child,my id is %d,gpid is %d",id2=getpid(),gid2=getpgid(0)); exit(7); ! } ! TEST(fork()); ! if(TEST_RETURN == 0){ ! tst_resm(TINFO,"I'm a child,my id is %d,gpid is %d",id3=getpid(),gid3=getpgid(0)); exit(6); ! } ! tst_resm(TINFO,"I'm a father %d",cpid=getpid()); ! TEST(waitid(P_PGID,cpid,&infop,WEXITED)); if(TEST_RETURN == 0){ ! tst_resm(TPASS,"Success ... 0 is returned."); ! tst_resm(TINFO,"si_pid = %d ; si_code = %d ; si_status = %d",infop.si_pid,infop.si_code,infop.si_status); ! }else { ! tst_resm(TFAIL,"Fail... %d is returned",TEST_RETURN); ! errnochoose(); ! } ! TEST(waitid(P_PGID,id2,&infop,WEXITED)); ! if(TEST_RETURN == 0){ //NOCHILD ! tst_resm(TINFO,"si_pid = %d ; si_code = %d ; si_status = %d",infop.si_pid,infop.si_code,infop.si_status); ! tst_resm(TPASS,"Success2 ... 0 is returned"); ! }else { ! tst_resm(TFAIL,"Fail... %d is returned",TEST_RETURN); ! errnochoose(); ! } - TEST(i = waitid(P_PID,id1,&infop,WCONTINUED)); - if(TEST_RETURN == 0){ //EINVAL - tst_resm(TINFO,"si_pid = %d ; si_code = %d ; si_status = %d",infop.si_pid,infop.si_code,infop.si_status); - tst_resm(TPASS,"Success3 ... 0 is returned"); - }else { - tst_resm(TFAIL,"Fail... %d is returned",i); - errnochoose(); - } - } - } - cleanup(); - tst_exit(); - } --- 116,250 ---- int errnochoose(void){ //choose the relative errno ! switch (TEST_ERRNO) { ! case ECHILD: strerror((int)"ECHILD"); ! break; ! case EINTR: strerror((int)"EINTR"); ! break; ! case EINVAL: strerror((int)"EINVAL"); ! break; ! default: strerror((int)"Other Error"); ! } ! tst_exit() ; } int main(int ac, char **av) { ! id_t pgid; ! id_t id1, id2, id3; ! siginfo_t infop; ! int i = 0; ! int lc; /* loop counter */ ! char *msg; /* message returned from parse_opts */ /* parse standard options */ ! msg = parse_opts(ac, av, (option_t *)NULL, NULL); ! if (msg != (char *)NULL) { ! tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); ! tst_exit(); ! } ! setup(); ! /* Check looping state if -i option given */ ! for (lc = 0; TEST_LOOPING(lc); ++lc) { ! Tst_count = 0; ! for (testno = 0; testno < TST_TOTAL; ++testno) { ! TEST(waitid(P_ALL, 0, &infop, WNOHANG)); ! if (TEST_RETURN == -1) ! tst_resm(TPASS, "Success1 ... -1 is returned. error is %d.", ! TEST_ERRNO); ! else { ! tst_resm(TFAIL, "%s Failed1 ...", TCID); ! } ! /* option == WEXITED | WCONTINUED | WSTOPPED | WNOHANG | WNOWAIT*/ ! TEST(id1 = fork()); ! if (TEST_RETURN == 0) { ! tst_resm(TINFO, "I'm a child 1,my id is %d,gpid is %d", ! id1 = getpid(), __getpgid(0)); ! sleep(1); exit(5); ! } ! ! TEST(id2 = fork()); ! if (TEST_RETURN == 0) { ! sleep(3); ! tst_resm(TINFO, "I'm a child 2,my id is %d,gpid is %d", ! id2 = getpid(), __getpgid(0)); exit(7); ! } ! TEST(id3 = fork()); ! if (TEST_RETURN == 0) { ! sleep(2); ! TEST(kill(id2, SIGCONT)); ! tst_resm(TINFO, "I'm a child 3,my id is %d,gpid is %d", ! id3 = getpid(), __getpgid(0)); exit(6); ! } ! TEST(waitid(P_ALL, 0, &infop, WNOHANG | WEXITED)); ! if (TEST_RETURN == 0) ! tst_resm(TPASS, "Success 2 ...0 is returned.. error is %d.", ! TEST_ERRNO); ! else { ! tst_resm(TFAIL, "%s Failed 2", TCID); ! errnochoose(); ! } ! tst_resm(TINFO, "I'm a Parent,my id is %d,gpid is %d", ! getpid(), pgid = __getpgid(0)); ! ! TEST(waitid(P_PGID, pgid, &infop, WEXITED)); if(TEST_RETURN == 0){ ! tst_resm(TPASS, "Success3 ... 0 is returned."); ! tst_resm(TINFO, "si_pid = %d ; si_code = %d ; si_status = %d", ! infop.si_pid, infop.si_code, infop.si_status); ! } else { ! tst_resm(TFAIL, "Fail3 ... %d is returned", TEST_RETURN); ! errnochoose(); ! } ! TEST(kill(id2, SIGSTOP)); ! ! TEST(i = waitid(P_PID, id2, &infop, WSTOPPED | WNOWAIT)); ! if (TEST_RETURN == 0) { /*EINVAL*/ ! tst_resm(TINFO, "si_pid = %d, si_code = %d, si_status = %d", ! infop.si_pid, infop.si_code, infop.si_status); ! tst_resm(TPASS, "Success4 ... 0 is returned"); ! } else { ! tst_resm(TFAIL, "Fail4 ... %d is returned", i); ! errnochoose(); ! } + TEST(waitid(P_PID, id3, &infop, WEXITED)); + if (TEST_RETURN == 0) { /*NOCHILD*/ + tst_resm(TINFO, "si_pid = %d, si_code = %d, si_status = %d", + infop.si_pid, infop.si_code, infop.si_status); + tst_resm(TPASS, "Success5 ... 0 is returned"); + } else { + tst_resm(TFAIL, "Fail5 ... %d is returned", TEST_RETURN); + errnochoose(); + } + TEST(i = waitid(P_PID, id2, &infop, WCONTINUED)); + if (TEST_RETURN == 0) { /*EINVAL*/ + tst_resm(TINFO, "si_pid = %d, si_code = %d, si_status = %d", + infop.si_pid, infop.si_code, infop.si_status); + tst_resm(TPASS, "Success6 ... 0 is returned"); + } else { + tst_resm(TFAIL, "Fail6 ... %d is returned", i); + errnochoose(); + } + sleep(3); + } + } + cleanup(); + tst_exit(); + } |