Message ID | 20230427120800.27849-1-akumar@suse.de |
---|---|
State | Accepted |
Headers | show |
Series | [1/5] dup01.c: use TST_EXP_FD macro and add inode check | expand |
Hi Avinesh, > --- > testcases/kernel/syscalls/dup/dup01.c | 25 +++++++++++++++---------- ... > static void verify_dup(void) > { > + TST_EXP_FD(dup(fd), "dup(%d)", fd); IMHO only this is enough: TST_EXP_FD(dup(fd)); Kind regards, Petr > + > + SAFE_FSTAT(TST_RET, &buf2); > + TST_EXP_EQ_LU(buf1.st_ino, buf2.st_ino); > + > + SAFE_CLOSE(TST_RET); > }
Hi Petr, > > + TST_EXP_FD(dup(fd), "dup(%d)", fd); > > IMHO only this is enough: > TST_EXP_FD(dup(fd)); > okay, please update when you merge, if everything else is fine. Thank you, Avinesh
Hi Avinesh, merged this one. Thanks! Kind regards, Petr
diff --git a/testcases/kernel/syscalls/dup/dup01.c b/testcases/kernel/syscalls/dup/dup01.c index 74e24cc02..ce6f39ed3 100644 --- a/testcases/kernel/syscalls/dup/dup01.c +++ b/testcases/kernel/syscalls/dup/dup01.c @@ -7,27 +7,32 @@ * */ +/*\ + * [Description] + * + * Verify that dup(2) syscall executes successfully and allocates + * a new file descriptor which refers to the same open file as oldfd. + */ + #include "tst_test.h" static int fd; +static struct stat buf1, buf2; static void verify_dup(void) { - TEST(dup(fd)); - - if (TST_RET < -1) { - tst_res(TFAIL, "Invalid dup() return value %ld", TST_RET); - } else if (TST_RET == -1) { - tst_res(TFAIL | TTERRNO, "dup(%d) Failed", fd); - } else { - tst_res(TPASS, "dup(%d) returned %ld", fd, TST_RET); - SAFE_CLOSE(TST_RET); - } + TST_EXP_FD(dup(fd), "dup(%d)", fd); + + SAFE_FSTAT(TST_RET, &buf2); + TST_EXP_EQ_LU(buf1.st_ino, buf2.st_ino); + + SAFE_CLOSE(TST_RET); } static void setup(void) { fd = SAFE_OPEN("dupfile", O_RDWR | O_CREAT, 0700); + SAFE_FSTAT(fd, &buf1); } static void cleanup(void)
- simplify using TST_EXP_FD() macro - add inode comparison check for the newly allocated file descriptor - add test description Signed-off-by: Avinesh Kumar <akumar@suse.de> --- testcases/kernel/syscalls/dup/dup01.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)