From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QUTBp-0005Uf-1d for garchives@archives.gentoo.org; Thu, 09 Jun 2011 00:33:37 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7889D1C004; Thu, 9 Jun 2011 00:33:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 48F9A1C004 for ; Thu, 9 Jun 2011 00:33:29 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B31061B4019 for ; Thu, 9 Jun 2011 00:33:28 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id F13AB8003C for ; Thu, 9 Jun 2011 00:33:27 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/locks/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/tests/locks/test_lock_nonblock.py X-VCS-Directories: pym/portage/tests/locks/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: c249745ca37f996ef7de51d1be2997e6734d649b Date: Thu, 9 Jun 2011 00:33:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: f62ad177e791d979e34648a1bb042088 commit: c249745ca37f996ef7de51d1be2997e6734d649b Author: Zac Medico gentoo org> AuthorDate: Thu Jun 9 00:32:56 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Thu Jun 9 00:32:56 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Dc249745c Test noblocking locks. --- pym/portage/tests/locks/test_lock_nonblock.py | 46 +++++++++++++++++++= ++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/pym/portage/tests/locks/test_lock_nonblock.py b/pym/portage/= tests/locks/test_lock_nonblock.py new file mode 100644 index 0000000..d5748ad --- /dev/null +++ b/pym/portage/tests/locks/test_lock_nonblock.py @@ -0,0 +1,46 @@ +# Copyright 2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +import shutil +import tempfile +import traceback + +import portage +from portage import os +from portage.tests import TestCase + +class LockNonblockTestCase(TestCase): + + def testLockNonblock(self): + tempdir =3D tempfile.mkdtemp() + try: + path =3D os.path.join(tempdir, 'lock_me') + lock1 =3D portage.locks.lockfile(path) + pid =3D os.fork() + if pid =3D=3D 0: + portage.process._setup_pipes({0:0, 1:1, 2:2}) + rval =3D 2 + try: + try: + lock2 =3D portage.locks.lockfile(path, flags=3Dos.O_NONBLOCK) + except portage.exception.TryAgain: + rval =3D os.EX_OK + else: + rval =3D 1 + portage.locks.unlockfile(lock2) + except SystemExit: + raise + except: + traceback.print_exc() + finally: + os._exit(rval) + + self.assertEqual(pid > 0, True) + pid, status =3D os.waitpid(pid, 0) + self.assertEqual(os.WIFEXITED(status), True) + self.assertEqual(os.WEXITSTATUS(status), os.EX_OK) + + portage.locks.unlockfile(lock1) + finally: + shutil.rmtree(tempdir) +