From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/process/, pym/_emerge/
Date: Thu, 15 Dec 2011 23:55:51 +0000 (UTC) [thread overview]
Message-ID: <915348ce34fc499ac295b8f0ffee9f0829803542.zmedico@gentoo> (raw)
commit: 915348ce34fc499ac295b8f0ffee9f0829803542
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 15 23:55:42 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Dec 15 23:55:42 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=915348ce
test_poll: test different sizes, and pty too
---
pym/_emerge/PipeReader.py | 4 +++-
pym/portage/tests/process/test_poll.py | 23 +++++++++++++++++------
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py
index af8cfdd..78acb72 100644
--- a/pym/_emerge/PipeReader.py
+++ b/pym/_emerge/PipeReader.py
@@ -64,7 +64,9 @@ class PipeReader(AbstractPollTask):
try:
data = os.read(fd, self._bufsize)
except OSError as e:
- if e.errno not in (errno.EAGAIN,):
+ # EIO happens with pty on Linux after the
+ # slave end of the pty has been closed.
+ if e.errno not in (errno.EAGAIN, errno.EIO):
raise
break
else:
diff --git a/pym/portage/tests/process/test_poll.py b/pym/portage/tests/process/test_poll.py
index c3b50d4..e7a4702 100644
--- a/pym/portage/tests/process/test_poll.py
+++ b/pym/portage/tests/process/test_poll.py
@@ -3,25 +3,28 @@
from portage import os
from portage.tests import TestCase
+from portage.util._pty import _create_pty_or_pipe
from _emerge.PollScheduler import PollScheduler
from _emerge.PipeReader import PipeReader
from _emerge.SpawnProcess import SpawnProcess
class PipeReaderTestCase(TestCase):
- def testPipeReader(self):
+ def _testPipeReader(self, test_string, use_pty):
"""
Use a poll loop to read data from a pipe and assert that
the data written to the pipe is identical to the data
read from the pipe.
"""
- test_string = 2 * "blah blah blah\n"
-
scheduler = PollScheduler().sched_iface
- master_fd, slave_fd = os.pipe()
+ if use_pty:
+ got_pty, master_fd, slave_fd = _create_pty_or_pipe()
+ else:
+ got_pty = False
+ master_fd, slave_fd = os.pipe()
master_file = os.fdopen(master_fd, 'rb', 0)
- slave_file = os.fdopen(slave_fd, 'wb')
+ slave_file = os.fdopen(slave_fd, 'wb', 0)
producer = SpawnProcess(
args=["bash", "-c", "echo -n '%s'" % test_string],
env=os.environ, fd_pipes={1:slave_fd},
@@ -44,4 +47,12 @@ class PipeReaderTestCase(TestCase):
self.assertEqual(consumer.returncode, os.EX_OK)
output = consumer.getvalue().decode('ascii', 'replace')
- self.assertEqual(test_string, output)
+ return (output, got_pty)
+
+ def testPipeReader(self):
+ for use_pty in (False, True):
+ for x in (1, 2, 5, 6, 7, 8, 2**5, 2**10, 2**12, 2**13, 2**14):
+ test_string = x * "a"
+ output, got_pty = self._testPipeReader(test_string, use_pty)
+ self.assertEqual(test_string, output,
+ "x = %s, use_pty = %s, got_pty = %s" % (x, use_pty, got_pty))
next reply other threads:[~2011-12-15 23:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-15 23:55 Zac Medico [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-12-16 2:03 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/process/, pym/_emerge/ Zac Medico
2011-12-16 21:56 Zac Medico
2012-02-08 21:04 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=915348ce34fc499ac295b8f0ffee9f0829803542.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