public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/locks/
Date: Tue, 17 May 2011 20:56:51 +0000 (UTC)	[thread overview]
Message-ID: <0ea4406a64f8af1143e1a819b61f95e8b1777f99.zmedico@gentoo> (raw)

commit:     0ea4406a64f8af1143e1a819b61f95e8b1777f99
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue May 17 20:56:15 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue May 17 20:56:15 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0ea4406a

test_asynchronous_lock: test waiting

---
 pym/portage/tests/locks/test_asynchronous_lock.py |   25 +++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py
index 7e9fdfe..e72adf6 100644
--- a/pym/portage/tests/locks/test_asynchronous_lock.py
+++ b/pym/portage/tests/locks/test_asynchronous_lock.py
@@ -37,3 +37,28 @@ class AsynchronousLockTestCase(TestCase):
 
 		finally:
 			shutil.rmtree(tempdir)
+
+	def testAsynchronousLockWait(self):
+		scheduler = PollScheduler().sched_iface
+		tempdir = tempfile.mkdtemp()
+		try:
+			path = os.path.join(tempdir, 'lock_me')
+			lock1 = AsynchronousLock(path=path, scheduler=scheduler)
+			lock1.start()
+			self.assertEqual(lock1.wait(), os.EX_OK)
+
+			# lock2 requires _force_async=True since the portage.locks
+			# module is not designed to work as intended here if the
+			# same process tries to lock the same file more than
+			# one time concurrently.
+			lock2 = AsynchronousLock(path=path, scheduler=scheduler,
+				_force_async=True, _force_process=True)
+			lock2.start()
+			# lock2 should we waiting for lock1 to release
+			self.assertEqual(lock2.returncode, None)
+
+			lock1.unlock()
+			self.assertEqual(lock2.wait(), os.EX_OK)
+			lock2.unlock()
+		finally:
+			shutil.rmtree(tempdir)



             reply	other threads:[~2011-05-17 20:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17 20:56 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-05-17 21:03 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/locks/ Zac Medico
2011-05-17 21:14 Zac Medico
2011-05-18 19:46 Arfrever Frehtes Taifersar Arahesis
2011-06-09  0:33 Zac Medico
2011-12-14  9:18 Zac Medico
2012-03-28  0:26 Zac Medico

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=0ea4406a64f8af1143e1a819b61f95e8b1777f99.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /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