setuid03.c: using TST_EXP_FAIL() and SAFE_SETUID() macros
PATCH 1/1 setuid03.c: using TST_EXP_FAIL() and SAFE_SETUID() macros
use TST_EXP_FAIL() with expected errno code, use SAFE_SETUID() in setup and turn comment into docparse
Signed-off-by Avinesh Kumar <[email protected]>
--- testcases/kernel/syscalls/setuid/setuid03.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
testcases/kernel/syscalls/setuid/setuid03.c +5 -15
@@ -3,7 +3,9 @@* Copyright (c) International Business Machines Corp., 2001 */ -/* DESCRIPTION +/* +* [Description] +* * This test will switch to nobody user for correct error code collection. * Verify setuid returns errno EPERM when it switches to root_user. */
@@ -19,16 +21,7 @@static void verify_setuid (void ) { -TEST (SETUID (ROOT_USER )); -if (TST_RET !=-1 ) { -tst_res (TFAIL |TTERRNO ,"setuid() succeeded unexpectedly" ); -return ; - } - -if (TST_ERR ==EPERM ) -tst_res (TPASS ,"setuid() returned errno EPERM" ); -else -tst_res (TFAIL |TTERRNO ,"setuid() returned unexpected errno" ); +TST_EXP_FAIL (SETUID (ROOT_USER ),EPERM ); }static void setup (void )
@@ -39,10 +32,7 @@ static void setup(void) pw =SAFE_GETPWNAM ("nobody" ); uid = pw->pw_uid; -if (SETUID (uid) ==-1 ) { -tst_brk (TBROK , -"setuid() failed to set the effective uid to %d" , uid); - } +SAFE_SETUID (uid);umask (0 ); }
Signature · 5 lines
2.36.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Sent a v2 for this with correct docparse format and updated copyright.
Quoted 44 lines · IST Avinesh Kumar
use
TST_EXP_FAIL()with expected errno code, useSAFE_SETUID()in setup and turn comment into docparseSigned-off-by Avinesh Kumar <[email protected]>--- testcases/kernel/syscalls/setuid/setuid03.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)testcases/kernel/syscalls/setuid/setuid03.c +4
-11@@ -3,7 +3,9 @@* Copyright (c) International Business Machines Corp., 2001 */ -/* DESCRIPTION +/* +* [Description] +* * This test will switch to nobody user for correct error code collection. * Verify setuid returns errno EPERM when it switches to root_user. */ @@ -19,16 +21,7 @@static void verify_setuid (void ) { -TEST (SETUID (ROOT_USER )); -if (TST_RET !=-1 ) { -tst_res (TFAIL |TTERRNO ,"setuid() succeeded unexpectedly" ); -return ; - } - -if (TST_ERR ==EPERM ) -tst_res (TPASS ,"setuid() returned errno EPERM" ); -else -tst_res (TFAIL |TTERRNO ,"setuid() returned unexpected errno" ); +TST_EXP_FAIL (SETUID (ROOT_USER ),EPERM ); }static void setup (void )@@ -39,10 +32,7 @@ static void setup(void) pw =SAFE_GETPWNAM ("nobody" );
testcases/kernel/syscalls/setuid/setuid03.c static void setup(void) · line 38
Quoted 10 lines
testcases/kernel/syscalls/setuid/setuid03.c +1
-4uid = pw->pw_uid; -if (SETUID (uid) ==-1 ) { -tst_brk (TBROK , -"setuid() failed to set the effective uid to %d" , uid); - } +SAFE_SETUID (uid);umask (0 ); }
Regards,
Avinesh
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp