All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Fasheh <mfasheh@suse.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] ocfs2-test: fix flock_unit_test for fcntl locks
Date: Wed, 13 Aug 2008 21:06:12 -0700	[thread overview]
Message-ID: <20080814040612.GH21187@wotan.suse.de> (raw)

We were expecting a failure for the same-node same-fd trylock tests when in
fcntl mode, but fcntl locks will actually succeed for this, while flock
locks won't. The solution is to check which locking mode we're using and
adjust our expected return accordingly.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>

Index: ocfs2-test/programs/flock_tests/flock_unit_test.c
===================================================================
--- ocfs2-test/programs/flock_tests/flock_unit_test.c	(revision 183)
+++ ocfs2-test/programs/flock_tests/flock_unit_test.c	(working copy)
@@ -329,7 +329,19 @@
 static void test_1node_1file(char *fname)
 {
 	int fd1, fd2;
+	int trylock_return = 0;
 
+	/*
+	 * flock allows one lock per fd, so a trylock on the 2nd file
+	 * descriptor will return EWOULDBLOCK.
+	 *
+	 * fcntl on the other hand, only allows one lock per process,
+	 * regardless of the number of fds used. So our trylocks here
+	 * should succeed as it'll be considered an EX->EX convert.
+	 */
+	if (use_flock)
+		trylock_return = EWOULDBLOCK;
+
 	fd1 = get_fd(fname);
 	fd2 = get_fd(fname);
 
@@ -344,13 +356,13 @@
 
 	info("Two exclusive trylocks\n");
 	lock_abort(fname, fd1, 0, 1, 1);
-	lock_abort(fname, fd2, EWOULDBLOCK, 1, 1);
+	lock_abort(fname, fd2, trylock_return, 1, 1);
 	unlock_abort(fname, fd1, 0);
 
 
 	info("One exclusive, one shared trylock\n");
 	lock_abort(fname, fd1, 0, 1, 0);
-	lock_abort(fname, fd2, EWOULDBLOCK, 0, 1);
+	lock_abort(fname, fd2, trylock_return, 0, 1);
 	unlock_abort(fname, fd1, 0);
 
 

             reply	other threads:[~2008-08-14  4:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-14  4:06 Mark Fasheh [this message]
2008-08-14 18:51 ` [Ocfs2-devel] [Ocfs2-tools-devel] ocfs2-test: fix flock_unit_test for fcntl locks Joel Becker
2008-08-20 16:26 ` [Ocfs2-devel] " Sunil Mushran
2008-08-21 19:33   ` Mark Fasheh

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=20080814040612.GH21187@wotan.suse.de \
    --to=mfasheh@suse.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.