fstat02.c: simplify using TST_EXP_*() macros
PATCH v2 1/1 fstat02.c: simplify using TST_EXP_*() macros
Signed-off-by Avinesh Kumar <[email protected]>
--- testcases/kernel/syscalls/fstat/fstat02.c | 60 ++++------------------- 1 file changed, 10 insertions(+), 50 deletions(-)
testcases/kernel/syscalls/fstat/fstat02.c +10 -50
@@ -4,17 +4,15 @@* 07/2001 Ported by Wayne Boyer * 05/2019 Ported to new library: Christian Amann <[email protected]> */ -/* + +/*\ +* [Description] +* * Tests if fstat() returns correctly and reports correct file information * using the stat structure. */ -#include <errno.h> -#include <unistd.h> -#include <sys/stat.h> -#include <sys/types.h> #include "tst_test.h" -#include "tst_safe_macros.h" #define TESTFILE "test_file"#define LINK_TESTFILE "link_test_file"
@@ -29,50 +27,12 @@ static int fildes;static void run (void ) { -int fail =0 ; - -TEST (fstat (fildes, &stat_buf)); - -if (TST_RET !=0 ) { -tst_res (TFAIL |TTERRNO ,"fstat() failed" ); -return ; - } - - fail =0 ; -if (stat_buf.st_uid != user_id) { -tst_res (TFAIL ,"stat_buf.st_uid = %i expected %i" , - stat_buf.st_uid, user_id); - fail++; - } - -if (stat_buf.st_gid != group_id) { -tst_res (TFAIL ,"stat_buf.st_gid = %i expected %i" , - stat_buf.st_gid, group_id); - fail++; - } - -if (stat_buf.st_size !=FILE_SIZE ) { -tst_res (TFAIL ,"stat_buf.st_size = %li expected %i" , - (long )stat_buf.st_size,FILE_SIZE ); - fail++; - } - -if ((stat_buf.st_mode &0777 ) !=FILE_MODE ) { -tst_res (TFAIL ,"stat_buf.st_mode = %o expected %o" , - (stat_buf.st_mode &0777 ),FILE_MODE ); - fail++; - } - -if (stat_buf.st_nlink !=NLINK ) { -tst_res (TFAIL ,"stat_buf.st_nlink = %li expected %i" , - (long )stat_buf.st_nlink,NLINK ); - fail++; - } - -if (fail) -return ; - -tst_res (TPASS ,"fstat() reported correct values." ); +TST_EXP_PASS (fstat (fildes, &stat_buf)); +TST_EXP_EQ_LU (stat_buf.st_uid, user_id); +TST_EXP_EQ_LU (stat_buf.st_gid, group_id); +TST_EXP_EQ_LI (stat_buf.st_size,FILE_SIZE ); +TST_EXP_EQ_LU (stat_buf.st_mode &0777 ,FILE_MODE ); +TST_EXP_EQ_LU (stat_buf.st_nlink,NLINK ); }static void setup (void )
Signature · 5 lines
2.36.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Avinesh,
thanks, merged!
+1 for fixing my points.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp