From: Subrata <sub...@us...> - 2009-03-23 14:45:56
|
Update of /cvsroot/ltp/ltp/testcases/kernel/syscalls/wait In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14647/ltp/testcases/kernel/syscalls/wait Modified Files: wait02.c Log Message: Coding Syle Cleanups. Signed-Off-By: <mic...@pe...>. Index: wait02.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/wait/wait02.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** wait02.c 26 Feb 2009 12:17:06 -0000 1.5 --- wait02.c 23 Mar 2009 13:36:15 -0000 1.6 *************** *** 60,80 **** * TEST CASES * ! * 1.) wait(2) returns...(See Description) * * INPUT SPECIFICATIONS ! * The standard options for system call tests are accepted. * (See the parse_opts(3) man page). * * OUTPUT SPECIFICATIONS ! * * DURATION ! * Terminates - with frequency and infinite modes. * * SIGNALS ! * Uses SIGUSR1 to pause before test if option set. ! * (See the parse_opts(3) man page). * * RESOURCES ! * None * * ENVIRONMENTAL NEEDS --- 60,80 ---- * TEST CASES * ! * 1.) wait(2) returns...(See Description) * * INPUT SPECIFICATIONS ! * The standard options for system call tests are accepted. * (See the parse_opts(3) man page). * * OUTPUT SPECIFICATIONS ! * * DURATION ! * Terminates - with frequency and infinite modes. * * SIGNALS ! * Uses SIGUSR1 to pause before test if option set. ! * (See the parse_opts(3) man page). * * RESOURCES ! * None * * ENVIRONMENTAL NEEDS *************** *** 82,89 **** * * SPECIAL PROCEDURAL REQUIREMENTS ! * None * * INTERCASE DEPENDENCIES ! * None * * DETAILED DESCRIPTION --- 82,89 ---- * * SPECIAL PROCEDURAL REQUIREMENTS ! * None * * INTERCASE DEPENDENCIES ! * None * * DETAILED DESCRIPTION *************** *** 93,109 **** * wait(2). * ! * Setup: ! * Setup signal handling. * Pause for SIGUSR1 if option specified. * ! * Test: * Loop if the proper options are given. ! * Execute system call * Check return code, if system call failed (return=-1) * Log the errno and Issue a FAIL message. * Otherwise, Issue a PASS message. * ! * Cleanup: ! * Print errno log and/or timing stats if options given * * --- 93,109 ---- * wait(2). * ! * Setup: ! * Setup signal handling. * Pause for SIGUSR1 if option specified. * ! * Test: * Loop if the proper options are given. ! * Execute system call * Check return code, if system call failed (return=-1) * Log the errno and Issue a FAIL message. * Otherwise, Issue a PASS message. * ! * Cleanup: ! * Print errno log and/or timing stats if options given * * *************** *** 122,214 **** void cleanup(); ! ! ! char *TCID="wait02"; /* Test program identifier. */ ! int TST_TOTAL=1; /* Total number of test cases. */ extern int Tst_count; /* Test Case counter for tst_* routines */ ! int exp_enos[]={0, 0}; int fork_pid, ret_code; void trapper(); ! int ! main(int ac, char **av) { ! 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); /*************************************************************** * perform global setup for test ***************************************************************/ ! setup(); - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - /*************************************************************** * check looping state if -c option given ***************************************************************/ ! for (lc=0; TEST_LOOPING(lc); lc++) { ! /* reset Tst_count in case we are looping. */ ! Tst_count=0; ! /* create a child to wait for */ ! if ((fork_pid=FORK_OR_VFORK()) == -1) { ! tst_brkm(TBROK, cleanup, "fork() Failure. errno=%d : %s", errno, strerror(errno)); ! } else if (fork_pid == 0) { ! /* Child, sleep a second then exit */ ! sleep(1); ! exit(1); ! } ! /* Parent, wait for child to die */ ! TEST(wait(&ret_code)); ! /* check return code */ ! if ( TEST_RETURN == -1 ) { ! TEST_ERROR_LOG(TEST_ERRNO); ! tst_resm(TFAIL, "wait(1) Failed, errno=%d : %s", ! TEST_ERRNO, strerror(TEST_ERRNO)); ! } else { /*************************************************************** * only perform functional verification if flag set (-f not given) ***************************************************************/ ! if ( STD_FUNCTIONAL_TEST ) { ! /* No Verification test, yet... */ ! tst_resm(TPASS, "wait(&ret_code) returned %d", TEST_RETURN); ! } ! } ! } /* End for TEST_LOOPING */ /*************************************************************** * cleanup and exit ***************************************************************/ ! cleanup(); ! return 0; ! } /* End main */ /*************************************************************** * setup() - performs all ONE TIME setup for this test. ***************************************************************/ ! void ! setup() { ! /* capture signals */ ! tst_sig(FORK, DEF_HANDLER, cleanup); ! ! /* Pause if that option was specified */ ! TEST_PAUSE; ! } /* End setup() */ /*************************************************************** --- 122,212 ---- void cleanup(); ! char *TCID = "wait02"; /* Test program identifier. */ ! int TST_TOTAL = 1; /* Total number of test cases. */ extern int Tst_count; /* Test Case counter for tst_* routines */ ! int exp_enos[] = { 0, 0 }; int fork_pid, ret_code; void trapper(); ! int main(int ac, char **av) { ! 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); /*************************************************************** * perform global setup for test ***************************************************************/ ! setup(); ! ! /* set the expected errnos... */ ! TEST_EXP_ENOS(exp_enos); /*************************************************************** * check looping state if -c option given ***************************************************************/ ! for (lc = 0; TEST_LOOPING(lc); lc++) { ! /* reset Tst_count in case we are looping. */ ! Tst_count = 0; ! /* create a child to wait for */ ! if ((fork_pid = FORK_OR_VFORK()) == -1) { ! tst_brkm(TBROK, cleanup, ! "fork() Failure. errno=%d : %s", errno, ! strerror(errno)); ! } else if (fork_pid == 0) { ! /* Child, sleep a second then exit */ ! sleep(1); ! exit(1); ! } ! /* Parent, wait for child to die */ ! TEST(wait(&ret_code)); ! /* check return code */ ! if (TEST_RETURN == -1) { ! TEST_ERROR_LOG(TEST_ERRNO); ! tst_resm(TFAIL, "wait(1) Failed, errno=%d : %s", ! TEST_ERRNO, strerror(TEST_ERRNO)); ! } else { /*************************************************************** * only perform functional verification if flag set (-f not given) ***************************************************************/ ! if (STD_FUNCTIONAL_TEST) { ! /* No Verification test, yet... */ ! tst_resm(TPASS, "wait(&ret_code) returned %d", ! TEST_RETURN); ! } ! } ! } /* End for TEST_LOOPING */ /*************************************************************** * cleanup and exit ***************************************************************/ ! cleanup(); ! return 0; ! } /* End main */ /*************************************************************** * setup() - performs all ONE TIME setup for this test. ***************************************************************/ ! void setup() { ! /* capture signals */ ! tst_sig(FORK, DEF_HANDLER, cleanup); ! /* Pause if that option was specified */ ! TEST_PAUSE; + } /* End setup() */ /*************************************************************** *************** *** 216,231 **** * completion or premature exit. ***************************************************************/ ! void ! cleanup() { ! /* ! * print timing stats if that option was specified. ! * print errno log if that option was specified. ! */ ! TEST_CLEANUP; ! ! /* exit with return code appropriate for results */ ! tst_exit(); ! } /* End cleanup() */ ! --- 214,226 ---- * completion or premature exit. ***************************************************************/ ! void cleanup() { ! /* ! * print timing stats if that option was specified. ! * print errno log if that option was specified. ! */ ! TEST_CLEANUP; + /* exit with return code appropriate for results */ + tst_exit(); + } /* End cleanup() */ |