diff options
author | Stefan Eßer <se@FreeBSD.org> | 2021-09-22 15:00:08 +0200 |
---|---|---|
committer | Stefan Eßer <se@FreeBSD.org> | 2021-09-22 15:00:08 +0200 |
commit | a48c3021c4c4cffc537122ac14d2c340ae75ad62 (patch) | |
tree | 1d9f566f87b3aa431888415d03ad4c47de64cda2 | |
parent | b3a11ac3dba190dce355620935ef45260d6e721e (diff) | |
download | pexpect-a48c3021c4c4cffc537122ac14d2c340ae75ad62.tar.gz |
Do not send more characters than can be buffered by cat
The cat command on FreeBSD blocks if the default input buffer fills
and not output can be sent. The test used to generate more than 10 KB
of data before accepting the output generated by the cat program,
causing cat to block (stop reading input) until the output buffer has
been drained.
There is no reason to send long lines in this test, therefore it is
easily possible to perform the tests with lines that do not cause more
than 4 KB (the default input buffer size on FreeBSD) to be sent before
output from the cat program is checked.
In order to not depend on such buffer sizes pexpect needs to check for
output from the spawned command and buffer it, before it gets to
execute the expect() function. Apparently this is not happening and
thus the system dependent buffer size limit makes this test fail if
its capacity is exceeded.
-rwxr-xr-x | tests/test_expect.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/test_expect.py b/tests/test_expect.py index 243bc34..c9087f4 100755 --- a/tests/test_expect.py +++ b/tests/test_expect.py @@ -456,7 +456,7 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase): child = pexpect.spawn('cat', echo=False) child.sendline('BEGIN') for i in range(100): - child.sendline('foo' * 100) + child.sendline('foo' * 10) e = child.expect([b'xyzzy', pexpect.TIMEOUT], searchwindowsize=10, timeout=0.001) self.assertEqual(e, 1) @@ -473,7 +473,7 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase): child = pexpect.spawn('cat', echo=False) child.sendline('BEGIN') for i in range(100): - child.sendline('foo' * 100) + child.sendline('foo' * 10) e = child.expect([b'xyzzy', pexpect.TIMEOUT], searchwindowsize=10, timeout=0.5) self.assertEqual(e, 1) |