public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Avinesh Kumar <akumar@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] (no subject)
Date: Tue, 14 Jan 2025 16:37:04 +0100	[thread overview]
Message-ID: <20250114153715.5993-1-akumar@suse.de> (raw)

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 <akumar@suse.de>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/syscalls/flock/flock02.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/flock/flock02.c b/testcases/kernel/syscalls/flock/flock02.c
index b8c7eee68..e2fe73a64 100644
--- a/testcases/kernel/syscalls/flock/flock02.c
+++ b/testcases/kernel/syscalls/flock/flock02.c
@@ -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)
-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2025-01-14 15:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14 15:37 Avinesh Kumar [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-08-14  6:38 [LTP] (no subject) Indumathi Raju
2024-08-26 11:50 ` Cyril Hrubis
     [not found] <tencent_048887541FB562D43FE2D104@qq.com>
2024-04-28  7:16 ` =?gb18030?B?wrfssw==?=
2024-04-19  7:07 [LTP] [PATCH v2] Add case about arch_prctl syscall lufei
2024-04-21  7:15 ` [LTP] (no subject) lufei
2024-04-26  8:36   ` Cyril Hrubis
2024-04-26  9:42     ` 路斐
2024-04-26 10:28       ` Cyril Hrubis
2024-04-26 12:27         ` 路斐
2024-04-26 12:47           ` Jan Stancek
2024-04-28  7:44 ` lufei
2021-11-15  8:15 Joerg Vehlow
2019-10-07  6:45 Joerg Vehlow
2019-10-07  6:53 ` Joerg Vehlow
2019-08-21  2:25 Jim Woo
2019-08-22 12:45 ` Cyril Hrubis
2014-03-07 11:39 [LTP] [PATCH 1/2] add tst_get_unused_port() Jan Stancek
2014-03-10 14:22 ` [LTP] (no subject) Jan Stancek
2013-08-05 14:44 Stanislav Kholmanskikh
2009-07-01 20:08 Henry Yei
2009-06-24 22:58 Henry Yei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250114153715.5993-1-akumar@suse.de \
    --to=akumar@suse.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox