(no subject)
Following up on https://lore.kernel.org/ltp/1934768.7Z3S40VBb9@localhost/
Subject: [PATCH] flock02: Add test for EWOULDBLOCK errno
Also fix a make check warning.
Signed-off-by Avinesh Kumar <[email protected]>
Signed-off-by Yang Xu <[email protected]>
--- testcases/kernel/syscalls/flock/flock02.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/flock/flock02.c +9 -1
@@ -13,6 +13,7 @@* - EBADF if the file descriptor is invalid * - EINVAL if the argument operation does not include LOCK_SH,LOCK_EX,LOCK_UN * - EINVAL if an invalid combination of locking modes is used i.e LOCK_SH with LOCK_EX +* - EWOULDBLOCK if the file is locked and the LOCK_NB flag was selected */ #include <errno.h>
@@ -31,13 +32,19 @@ static struct tcase { {&badfd, LOCK_SH, EBADF}, {&fd, LOCK_NB, EINVAL}, {&fd, LOCK_SH | LOCK_EX, EINVAL}, + {&fd, LOCK_NB | LOCK_EX, EWOULDBLOCK} }; -static void verify_flock (unsigned n) +static void verify_flock (unsigned int n) {struct tcase *tc = &tcases[n]; fd =SAFE_OPEN ("testfile" ,O_RDWR ); +int fd2 =SAFE_OPEN ("testfile" ,O_RDWR ); + +if (tc->exp_err ==EWOULDBLOCK ) +flock (fd2,LOCK_EX ); +TEST (flock (*tc->fd, tc->operation));if (TST_RET ==0 ) {tst_res (TFAIL |TTERRNO ,"flock() succeeded unexpectedly" );
@@ -53,6 +60,7 @@ static void verify_flock(unsigned n) }SAFE_CLOSE (fd); +SAFE_CLOSE (fd2); }static void setup (void )
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp