diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-12-13 20:24:35 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-12-13 20:24:35 -0800 |
commit | 89bcc67e2930a841e1120492634ebc20530bc1d7 (patch) | |
tree | 72354b816b5117a8b522f5bf338f728c0606cf2d /pym/portage/tests/locks | |
parent | 9fa915eef028c96b8cde3876fb8bb299c03f9a62 (diff) | |
download | portage-89bcc67e2930a841e1120492634ebc20530bc1d7.tar.gz portage-89bcc67e2930a841e1120492634ebc20530bc1d7.tar.bz2 portage-89bcc67e2930a841e1120492634ebc20530bc1d7.zip |
locks.py: fix hardlink locks for bug #394195
This updates the hardlink locking code to support the non-blocking,
lockfile(wantnewlockfile=False), and lockfile(file_object) behaviors
which are used by portage code.
Diffstat (limited to 'pym/portage/tests/locks')
-rw-r--r-- | pym/portage/tests/locks/test_asynchronous_lock.py | 48 | ||||
-rw-r--r-- | pym/portage/tests/locks/test_lock_nonblock.py | 12 |
2 files changed, 55 insertions, 5 deletions
diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py index 0d6f11656..c896cb45c 100644 --- a/pym/portage/tests/locks/test_asynchronous_lock.py +++ b/pym/portage/tests/locks/test_asynchronous_lock.py @@ -12,7 +12,7 @@ from _emerge.PollScheduler import PollScheduler class AsynchronousLockTestCase(TestCase): - def testAsynchronousLock(self): + def _testAsynchronousLock(self): scheduler = PollScheduler().sched_iface tempdir = tempfile.mkdtemp() try: @@ -39,7 +39,17 @@ class AsynchronousLockTestCase(TestCase): finally: shutil.rmtree(tempdir) - def testAsynchronousLockWait(self): + def testAsynchronousLock(self): + self._testAsynchronousLock() + + def testAsynchronousLockHardlink(self): + os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1" + try: + self._testAsynchronousLock() + finally: + os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None) + + def _testAsynchronousLockWait(self): scheduler = PollScheduler().sched_iface tempdir = tempfile.mkdtemp() try: @@ -67,7 +77,17 @@ class AsynchronousLockTestCase(TestCase): finally: shutil.rmtree(tempdir) - def testAsynchronousLockWaitCancel(self): + def testAsynchronousLockWait(self): + self._testAsynchronousLockWait() + + def testAsynchronousLockWaitHardlink(self): + os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1" + try: + self._testAsynchronousLockWait() + finally: + os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None) + + def _testAsynchronousLockWaitCancel(self): scheduler = PollScheduler().sched_iface tempdir = tempfile.mkdtemp() try: @@ -92,7 +112,17 @@ class AsynchronousLockTestCase(TestCase): finally: shutil.rmtree(tempdir) - def testAsynchronousLockWaitKill(self): + def testAsynchronousLockWaitCancel(self): + self._testAsynchronousLockWaitCancel() + + def testAsynchronousLockWaitCancelHardlink(self): + os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1" + try: + self._testAsynchronousLockWaitCancel() + finally: + os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None) + + def _testAsynchronousLockWaitKill(self): scheduler = PollScheduler().sched_iface tempdir = tempfile.mkdtemp() try: @@ -122,3 +152,13 @@ class AsynchronousLockTestCase(TestCase): lock1.unlock() finally: shutil.rmtree(tempdir) + + def testAsynchronousLockWaitKill(self): + self._testAsynchronousLockWaitKill() + + def testAsynchronousLockWaitKillHardlink(self): + os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1" + try: + self._testAsynchronousLockWaitKill() + finally: + os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None) diff --git a/pym/portage/tests/locks/test_lock_nonblock.py b/pym/portage/tests/locks/test_lock_nonblock.py index cc1b28e82..914084ca7 100644 --- a/pym/portage/tests/locks/test_lock_nonblock.py +++ b/pym/portage/tests/locks/test_lock_nonblock.py @@ -11,7 +11,7 @@ from portage.tests import TestCase class LockNonblockTestCase(TestCase): - def testLockNonblock(self): + def _testLockNonblock(self): tempdir = tempfile.mkdtemp() try: path = os.path.join(tempdir, 'lock_me') @@ -44,3 +44,13 @@ class LockNonblockTestCase(TestCase): finally: shutil.rmtree(tempdir) + def testLockNonblock(self): + self._testLockNonblock() + + def testLockNonblockHardlink(self): + os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1" + try: + self._testLockNonblock() + finally: + os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None) + |