From: Subrata <sub...@us...> - 2009-03-23 14:46:27
|
Update of /cvsroot/ltp/ltp/testcases/kernel/syscalls/fdatasync In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14647/ltp/testcases/kernel/syscalls/fdatasync Modified Files: fdatasync01.c fdatasync02.c Log Message: Coding Syle Cleanups. Signed-Off-By: <mic...@pe...>. Index: fdatasync02.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/fdatasync/fdatasync02.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fdatasync02.c 26 Feb 2009 12:02:55 -0000 1.3 --- fdatasync02.c 23 Mar 2009 13:35:41 -0000 1.4 *************** *** 84,96 **** #define SPL_FILE "/dev/null" ! struct test_case_t { /* test case structure */ ! int experrno; /* expected errno */ ! char *desc; ! int (*setup)(void); /* Individual setup routine */ ! void (*cleanup)(void); /* Individual cleanup routine */ }; char *TCID = "fdatasync02"; ! static int exp_enos[] = {EBADF, EINVAL, 0}; static int testno; static int fd; --- 84,96 ---- #define SPL_FILE "/dev/null" ! struct test_case_t { /* test case structure */ ! int experrno; /* expected errno */ ! char *desc; ! int (*setup) (void); /* Individual setup routine */ ! void (*cleanup) (void); /* Individual cleanup routine */ }; char *TCID = "fdatasync02"; ! static int exp_enos[] = { EBADF, EINVAL, 0 }; static int testno; static int fd; *************** *** 102,120 **** static void cleanup2(void); ! static struct test_case_t tdat[] = { ! { EBADF, "invalid file descriptor", setup1, NULL}, ! { EINVAL, "file descriptor to a special file", setup2, cleanup2}, }; int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]); ! int ! main(int argc, char **argv) { ! int lc; /* loop counter */ ! char *msg; /* message returned from parse_opts */ /* parse standard options */ ! if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != (char *)NULL) { tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); --- 102,119 ---- static void cleanup2(void); ! static struct test_case_t tdat[] = { ! {EBADF, "invalid file descriptor", setup1, NULL}, ! {EINVAL, "file descriptor to a special file", setup2, cleanup2}, }; int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]); ! int main(int argc, char **argv) { ! int lc; /* loop counter */ ! char *msg; /* message returned from parse_opts */ /* parse standard options */ ! if ((msg = parse_opts(argc, argv, (option_t *) NULL, NULL)) != (char *)NULL) { tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); *************** *** 129,133 **** for (testno = 0; testno < TST_TOTAL; ++testno) { ! if( (tdat[testno].setup) && (tdat[testno].setup()) ) { /* setup() failed, skip this test */ continue; --- 128,132 ---- for (testno = 0; testno < TST_TOTAL; ++testno) { ! if ((tdat[testno].setup) && (tdat[testno].setup())) { /* setup() failed, skip this test */ continue; *************** *** 137,153 **** TEST(fdatasync(fd)); TEST_ERROR_LOG(TEST_ERRNO); ! if ( (TEST_RETURN == EXP_RET_VAL) && ! (TEST_ERRNO == tdat[testno].experrno) ) { tst_resm(TPASS, "Expected failure for %s, " ! "errno: %d", tdat[testno].desc, ! TEST_ERRNO); } else { tst_resm(TFAIL, "Unexpected results for %s ; " ! "returned %d (expected %d), errno %d " ! "(expected %d)", tdat[testno].desc, ! TEST_RETURN, EXP_RET_VAL, ! TEST_ERRNO, tdat[testno].experrno); } ! if(tdat[testno].cleanup) { tdat[testno].cleanup(); } --- 136,152 ---- TEST(fdatasync(fd)); TEST_ERROR_LOG(TEST_ERRNO); ! if ((TEST_RETURN == EXP_RET_VAL) && ! (TEST_ERRNO == tdat[testno].experrno)) { tst_resm(TPASS, "Expected failure for %s, " ! "errno: %d", tdat[testno].desc, ! TEST_ERRNO); } else { tst_resm(TFAIL, "Unexpected results for %s ; " ! "returned %d (expected %d), errno %d " ! "(expected %d)", tdat[testno].desc, ! TEST_RETURN, EXP_RET_VAL, ! TEST_ERRNO, tdat[testno].experrno); } ! if (tdat[testno].cleanup) { tdat[testno].cleanup(); } *************** *** 156,165 **** cleanup(); ! /*NOTREACHED*/ ! return 0; } ! int ! setup1(void) { fd = -1; --- 155,162 ---- cleanup(); ! /*NOTREACHED*/ return 0; } ! int setup1(void) { fd = -1; *************** *** 167,172 **** } ! int ! setup2(void) { /* Open special file */ --- 164,168 ---- } ! int setup2(void) { /* Open special file */ *************** *** 178,183 **** } ! void ! cleanup2(void) { /* close special file */ --- 174,178 ---- } ! void cleanup2(void) { /* close special file */ *************** *** 187,197 **** } - /* * setup() * performs all ONE TIME setup for this test */ ! void ! setup(void) { /* capture signals */ --- 182,190 ---- } /* * setup() * performs all ONE TIME setup for this test */ ! void setup(void) { /* capture signals */ *************** *** 213,218 **** * completion or premature exit */ ! void ! cleanup(void) { /* --- 206,210 ---- * completion or premature exit */ ! void cleanup(void) { /* *************** *** 224,227 **** /* exit with return code appropriate for results */ tst_exit(); ! /*NOTREACHED*/ ! } --- 216,218 ---- /* exit with return code appropriate for results */ tst_exit(); ! /*NOTREACHED*/} Index: fdatasync01.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/fdatasync/fdatasync01.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** fdatasync01.c 26 Feb 2009 12:02:55 -0000 1.6 --- fdatasync01.c 23 Mar 2009 13:35:41 -0000 1.7 *************** *** 83,88 **** int TST_TOTAL = 1; /* Total number of test cases. */ ! int ! main(int argc, char **argv) { int lc; /* loop counter */ --- 83,87 ---- int TST_TOTAL = 1; /* Total number of test cases. */ ! int main(int argc, char **argv) { int lc; /* loop counter */ *************** *** 90,95 **** /* parse standard options */ ! if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != ! (char *)NULL) { tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); } --- 89,94 ---- /* parse standard options */ ! if ((msg = parse_opts(argc, argv, (option_t *) NULL, NULL)) != ! (char *)NULL) { tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); } *************** *** 110,114 **** if (TEST_RETURN == -1) { tst_resm(TFAIL, "fdatasync() failed, errno=%d : %s", ! TEST_ERRNO, strerror(TEST_ERRNO)); } else { /* No Functional verification yet */ --- 109,113 ---- if (TEST_RETURN == -1) { tst_resm(TFAIL, "fdatasync() failed, errno=%d : %s", ! TEST_ERRNO, strerror(TEST_ERRNO)); } else { /* No Functional verification yet */ *************** *** 120,131 **** cleanup(); ! /*NOTREACHED*/ ! return 0; ! } /* End main */ /* setup() - performs all ONE TIME setup for this test */ ! void ! setup(void) { /* capture signals */ --- 119,128 ---- cleanup(); ! /*NOTREACHED*/ return 0; ! } /* End main */ /* setup() - performs all ONE TIME setup for this test */ ! void setup(void) { /* capture signals */ *************** *** 141,156 **** /* Initialize unique filename for each child process */ ! if( sprintf(filename, "fdatasync_%d", getpid()) <= 0) { tst_brkm(TBROK, cleanup, "Failed to initialize filename"); ! /*NOTREACHED*/ ! } ! if((fd = open(filename, O_CREAT|O_WRONLY, 0777)) == -1) { //mode must be specified when O_CREATE is in the flag tst_brkm(TBROK, cleanup, "open() failed"); ! /*NOTREACHED*/ ! } ! if((write(fd, filename, strlen(filename) + 1)) == -1) { tst_brkm(TBROK, cleanup, "write() failed"); ! /*NOTREACHED*/ ! } } --- 138,150 ---- /* Initialize unique filename for each child process */ ! if (sprintf(filename, "fdatasync_%d", getpid()) <= 0) { tst_brkm(TBROK, cleanup, "Failed to initialize filename"); ! /*NOTREACHED*/} ! if ((fd = open(filename, O_CREAT | O_WRONLY, 0777)) == -1) { //mode must be specified when O_CREATE is in the flag tst_brkm(TBROK, cleanup, "open() failed"); ! /*NOTREACHED*/} ! if ((write(fd, filename, strlen(filename) + 1)) == -1) { tst_brkm(TBROK, cleanup, "write() failed"); ! /*NOTREACHED*/} } *************** *** 160,165 **** * completion or premature exit */ ! void ! cleanup(void) { /* --- 154,158 ---- * completion or premature exit */ ! void cleanup(void) { /* *************** *** 167,171 **** * print errno log if that option was specified. */ ! close(fd); TEST_CLEANUP; --- 160,164 ---- * print errno log if that option was specified. */ ! close(fd); TEST_CLEANUP; *************** *** 176,180 **** /* exit with return code appropriate for results */ tst_exit(); ! /*NOTREACHED*/ ! } ! --- 169,171 ---- /* exit with return code appropriate for results */ tst_exit(); ! /*NOTREACHED*/} |