summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Quast <jquast@io.com>2015-02-22 12:27:40 -0800
committerJeff Quast <jquast@io.com>2015-02-22 12:28:05 -0800
commitabe0df1c5285a9cddf528db74a432f14b0954dae (patch)
treedc9c3f241691b316ed652c75d7039d3843b6715b
parent9f1bd0193a38fe4e0d4d6a4f481c02ac28fee094 (diff)
downloadpexpect-git-abe0df1c5285a9cddf528db74a432f14b0954dae.tar.gz
FreeBSD: Document magic max canon value of 1920
-rw-r--r--pexpect/pty_spawn.py2
-rw-r--r--tests/test_maxcanon.py12
-rwxr-xr-xtools/teamcity-runtests.sh3
3 files changed, 13 insertions, 4 deletions
diff --git a/pexpect/pty_spawn.py b/pexpect/pty_spawn.py
index 0663926..0ba1e0c 100644
--- a/pexpect/pty_spawn.py
+++ b/pexpect/pty_spawn.py
@@ -475,7 +475,7 @@ class spawn(SpawnBase):
On Linux systems, this is 4096 (defined by N_TTY_BUF_SIZE). All
other systems honor the POSIX.1 definition PC_MAX_CANON -- 1024
- on OSX, 256 on OpenSolaris, 255 on FreeBSD.
+ on OSX, 256 on OpenSolaris, and 1920 on FreeBSD.
This value may be discovered using fpathconf(3)::
diff --git a/tests/test_maxcanon.py b/tests/test_maxcanon.py
index bbd08f3..95f9025 100644
--- a/tests/test_maxcanon.py
+++ b/tests/test_maxcanon.py
@@ -12,7 +12,8 @@ class TestCaseCanon(PexpectTestCase.PexpectTestCase):
Test expected Canonical mode behavior (limited input line length).
All systems use the value of MAX_CANON which can be found using
- fpathconf(3) value PC_MAX_CANON -- with the exception of Linux.
+ fpathconf(3) value PC_MAX_CANON -- with the exception of Linux
+ and FreeBSD.
Linux, though defining a value of 255, actually honors the value
of 4096 from linux kernel include file tty.h definition
@@ -22,6 +23,10 @@ class TestCaseCanon(PexpectTestCase.PexpectTestCase):
implement this bit, and acts as if it is always set." Although these
tests ensure it is enabled, this is a non-op for Linux.
+ FreeBSD supports neither, and instead uses a fraction (1/5) of the tty
+ speed which is always 9600. Therefor, the maximum limited input line
+ length is 9600 / 5 = 1920.
+
These tests only ensure the correctness of the behavior described by
the sendline() docstring. pexpect is not particularly involved in
these scenarios, though if we wish to expose some kind of interface
@@ -43,6 +48,9 @@ class TestCaseCanon(PexpectTestCase.PexpectTestCase):
# SunOS allows PC_MAX_CANON + 1; see
# https://bitbucket.org/illumos/illumos-gate/src/d07a59219ab7fd2a7f39eb47c46cf083c88e932f/usr/src/uts/common/io/ldterm.c?at=default#cl-1888
self.max_input = os.fpathconf(0, 'PC_MAX_CANON') + 1
+ elif sys.platform.lower().startswith('freebsd'):
+ # http://lists.freebsd.org/pipermail/freebsd-stable/2009-October/052318.html
+ self.max_input = 9600 / 5
else:
# All others (probably) limit exactly at PC_MAX_CANON
self.max_input = os.fpathconf(0, 'PC_MAX_CANON')
@@ -90,7 +98,7 @@ class TestCaseCanon(PexpectTestCase.PexpectTestCase):
send_bytes = self.max_input
# exercise,
- child.sendline('_' * send_bytes)
+ child.send('_' * send_bytes)
child.expect_exact('\a')
# exercise, we must now backspace to send CR.
diff --git a/tools/teamcity-runtests.sh b/tools/teamcity-runtests.sh
index b74f179..aa14582 100755
--- a/tools/teamcity-runtests.sh
+++ b/tools/teamcity-runtests.sh
@@ -14,6 +14,7 @@ export PYTHONIOENCODING=UTF8
export LANG=en_US.UTF-8
pyversion=$1
+shift
here=$(cd `dirname $0`; pwd)
osrel=$(uname -s)
venv=teamcity-pexpect
@@ -44,7 +45,7 @@ py.test \
--junit-xml=results.${osrel}.py${pyversion}.xml \
--verbose \
--verbose \
- || ret=$?
+ "$@" || ret=$?
if [ $ret -ne 0 ]; then
# we always exit 0, preferring instead the jUnit XML