From: Subrata <sub...@us...> - 2009-04-18 19:05:26
|
Update of /cvsroot/ltp/ltp/testcases/kernel/syscalls/pselect In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14948/ltp/testcases/kernel/syscalls/pselect Modified Files: pselect01.c Log Message: First, there was bug in test - it used seconds part of struct timespec structure, because total_sec was 5 from previous loop, and 1..4 millions of nanoseconds in addition to these 5 seconds did nothing in test result, checking sleep time for correctness also used total_sec. Also pselect takes struct timespec as its argument, not struct timeval, now code in test uses struct timeval as argument of pselect and suppose second field of this structure is microseconds instead of nanoseconds. Let's fix this part of test - I suggest to set nanoseconds to 1e8 ... 4e8 with step 1e8 and check sleep time differs from expected value no more than 10% of it. Signed-Off-By: Dmitry Guryanov <dgu...@pa...>. Index: pselect01.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/pselect/pselect01.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** pselect01.c 23 Mar 2009 13:36:01 -0000 1.12 --- pselect01.c 18 Apr 2009 19:05:23 -0000 1.13 *************** *** 61,70 **** int main() { ! int ret_pselect, total_sec, fd, total_usec; fd_set readfds; ! struct timeval tv; int retval; time_t t; unsigned start, end; setup(); --- 61,72 ---- int main() { ! int ret_pselect, total_sec, fd, total_nsec; fd_set readfds; ! struct timespec tv; int retval; time_t t; unsigned start, end; + struct timeval tv_start, tv_end; + int real_usec; setup(); *************** *** 79,85 **** FD_SET(fd, &readfds); tv.tv_sec = 0; ! tv.tv_usec = 0; ! ret_pselect = pselect(fd, &readfds, 0, 0, (struct timespec *)&tv, NULL); if (ret_pselect >= 0) { tst_resm(TPASS, "Basic pselect syscall testing....OK"); --- 81,87 ---- FD_SET(fd, &readfds); tv.tv_sec = 0; ! tv.tv_nsec = 0; ! ret_pselect = pselect(fd, &readfds, 0, 0, &tv, NULL); if (ret_pselect >= 0) { tst_resm(TPASS, "Basic pselect syscall testing....OK"); *************** *** 96,100 **** tv.tv_sec = total_sec; ! tv.tv_usec = 0; tst_resm(TINFO, --- 98,102 ---- tv.tv_sec = total_sec; ! tv.tv_nsec = 0; tst_resm(TINFO, *************** *** 115,140 **** #ifdef DEBUG ! tst_resm(TINFO, "Now checking usec sleep precision"); #endif ! for (total_usec = 1; total_usec <= LOOP_COUNT; total_usec++) { FD_ZERO(&readfds); FD_SET(0, &readfds); ! tv.tv_sec = total_sec; ! tv.tv_usec = total_usec * 1000000; tst_resm(TINFO, ! "Testing basic pselect sanity,Sleeping for %d micro secs", ! tv.tv_usec); ! start = time(&t); retval = ! pselect(0, &readfds, NULL, NULL, (struct timespec *)&tv, NULL); ! end = time(&t); /* Changed total_sec compare to an at least vs an exact compare */ ! if (((end - start) >= total_sec) ! && ((end - start) <= total_sec + 1)) tst_resm(TPASS, "Sleep time was correct"); else { --- 117,145 ---- #ifdef DEBUG ! tst_resm(TINFO, "Now checking nsec sleep precision"); #endif ! for (total_nsec = 1e8; total_nsec <= LOOP_COUNT * 1e8; total_nsec += 1e8) { FD_ZERO(&readfds); FD_SET(0, &readfds); ! tv.tv_sec = 0; ! tv.tv_nsec = total_nsec; tst_resm(TINFO, ! "Testing basic pselect sanity,Sleeping for %d nano secs", ! tv.tv_nsec); ! gettimeofday(&tv_start, NULL); retval = ! pselect(0, &readfds, NULL, NULL, &tv, NULL); ! gettimeofday(&tv_end, NULL); /* Changed total_sec compare to an at least vs an exact compare */ ! real_usec = (tv_end.tv_sec - tv_start.tv_sec) * 1e6 + ! tv_end.tv_usec - tv_start.tv_usec; ! ! /* allow 10% error*/ ! if (abs(real_usec - tv.tv_nsec / 1000) < 0.1 * total_nsec / 1000) tst_resm(TPASS, "Sleep time was correct"); else { *************** *** 144,149 **** "due to the limitation of the way it calculates the"); tst_resm(TWARN, "system call execution time."); ! tst_resm(TFAIL, "Sleep time was incorrect:%d != %d", ! total_sec, (end - start)); } } --- 149,155 ---- "due to the limitation of the way it calculates the"); tst_resm(TWARN, "system call execution time."); ! tst_resm(TFAIL, ! "Sleep time was incorrect:%d usec vs expected %d usec", ! real_usec, total_nsec / 1000); } } |