From 1ffdb3667e18b50e52bbd5c2fa64f5e13a892eb5 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 17 May 2011 14:02:12 -0700 Subject: test_asynchronous_lock: test wait and cancel --- pym/portage/tests/locks/test_asynchronous_lock.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'pym') diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py index e72adf684..dc4619dfd 100644 --- a/pym/portage/tests/locks/test_asynchronous_lock.py +++ b/pym/portage/tests/locks/test_asynchronous_lock.py @@ -62,3 +62,25 @@ class AsynchronousLockTestCase(TestCase): lock2.unlock() finally: shutil.rmtree(tempdir) + + def testAsynchronousLockWaitCancel(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 = 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) + + # Cancel lock2 and then check wait() and returncode results. + lock2.cancel() + self.assertEqual(lock2.wait() == os.EX_OK, False) + self.assertEqual(lock2.returncode == os.EX_OK, False) + lock1.unlock() + finally: + shutil.rmtree(tempdir) -- cgit v1.2.3-1-g7c22