From: Subrata <sub...@us...> - 2009-08-25 07:39:23
|
Update of /cvsroot/ltp/ltp/testcases/kernel/syscalls/unshare In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23971/ltp/testcases/kernel/syscalls/unshare Modified Files: unshare01.c Log Message: Fix unshare01: v3: simplify reporting by using TERRNO. v2: remove unneeded linux_syscall_numbers.h and simplify the checking of errno according to Mike's suggestion. When no unshare function found during the build-time checking or the kernel returns ENOSYS, it reports TCONF. It also simplify logic a little bit and fix some coding style issues. Signed-off-by: CAI Qian <ca...@cc...>. Index: unshare01.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/unshare/unshare01.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** unshare01.c 29 May 2009 12:32:43 -0000 1.1 --- unshare01.c 25 Aug 2009 07:39:15 -0000 1.2 *************** *** 93,97 **** #include "test.h" #include "usctest.h" ! #include "linux_syscall_numbers.h" /* Extern Global Variables */ --- 93,97 ---- #include "test.h" #include "usctest.h" ! #include "config.h" /* Extern Global Variables */ *************** *** 104,107 **** --- 104,109 ---- int TST_TOTAL =1; /* total number of tests in this file. */ + #ifdef HAVE_UNSHARE + /* Extern Global Functions */ /******************************************************************************/ *************** *** 178,222 **** * */ TEST(pid1=fork()); //call to fork() ! if (TEST_RETURN == -1){ ! tst_resm(TFAIL, "fork() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup(); tst_exit(); ! }else if (TEST_RETURN == 0){ ! if((TEST_RETURN = unshare(CLONE_FILES)) == 0) { ! tst_resm(TPASS, "unshare with CLONE_FILES call succeeded"); tst_exit(); - }else if (TEST_RETURN == -1 ) - tst_resm(TFAIL,"unshare Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); - tst_exit(); }else{ } TEST(pid1=fork()); //call to fork() ! if (TEST_RETURN == -1){ ! tst_resm(TFAIL, "fork() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup(); tst_exit(); ! }else if (TEST_RETURN == 0){ ! if((TEST_RETURN = unshare(CLONE_FS)) == 0) { ! tst_resm(TPASS, "unshare with CLONE_FS call succeeded"); ! tst_exit(); ! }else if (TEST_RETURN == -1 ) ! tst_resm(TFAIL,"unshare Failed 2, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); ! tst_exit(); }else{ } TEST(pid1=fork()); //call to fork() ! if (TEST_RETURN == -1){ ! tst_resm(TFAIL, "fork() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup(); tst_exit(); ! }else if (TEST_RETURN == 0){ ! if((TEST_RETURN = unshare(CLONE_NEWNS)) == 0) { ! tst_resm(TPASS, "unshare call with CLONE_NEWNS succeeded"); ! tst_exit(); ! }else if (TEST_RETURN == -1 ) ! tst_resm(TFAIL,"unshare Failed 2, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); ! tst_exit(); }else{ } --- 180,254 ---- * */ TEST(pid1=fork()); //call to fork() ! if (TEST_RETURN == -1) { ! tst_resm(TFAIL|TTERRNO, "fork() failed."); cleanup(); tst_exit(); ! } else if (TEST_RETURN == 0) { ! TEST_RETURN = unshare(CLONE_FS); ! if (TEST_RETURN == 0) ! tst_resm(TPASS, ! "unshare with CLONE_FILES call " ! "succeeded"); ! else if (TEST_RETURN == -1) { ! if (errno == ENOSYS) ! tst_resm(TCONF, ! "unshare is not " ! "implemented in kernel." ! ); ! else ! tst_resm(TFAIL|TERRNO, ! "unshare failed."); ! } tst_exit(); }else{ } TEST(pid1=fork()); //call to fork() ! if (TEST_RETURN == -1) { ! tst_resm(TFAIL|TTERRNO, "fork() failed."); cleanup(); tst_exit(); ! } else if (TEST_RETURN == 0) { ! TEST_RETURN = unshare(CLONE_FS); ! if (TEST_RETURN == 0) ! tst_resm(TPASS, ! "unshare with CLONE_FS call " ! "succeeded"); ! else if (TEST_RETURN == -1) { ! if (errno == ENOSYS) ! tst_resm(TCONF, ! "unshare is not " ! "implemented in kernel." ! ); ! else ! tst_resm(TFAIL|TERRNO, ! "unshare failed 2."); ! } ! tst_exit(); }else{ } TEST(pid1=fork()); //call to fork() ! if (TEST_RETURN == -1) { ! tst_resm(TFAIL|TTERRNO, "fork() failed."); cleanup(); tst_exit(); ! } else if (TEST_RETURN == 0) { ! TEST_RETURN = unshare(CLONE_NEWNS); ! if (TEST_RETURN == 0) { ! tst_resm(TPASS, ! "unshare call with CLONE_NEWNS " ! "succeeded"); ! } else if (TEST_RETURN == -1) { ! if (errno == ENOSYS) ! tst_resm(TCONF, ! "unshare is not " ! "implemented in kernel." ! ); ! else ! tst_resm(TFAIL|TERRNO, ! "unshare failed 2."); ! } ! tst_exit(); }else{ } *************** *** 229,231 **** tst_exit(); } ! --- 261,269 ---- tst_exit(); } ! #else ! int main(void) ! { ! tst_resm(TCONF, "unshare is undefined."); ! return 0; ! } ! #endif |