diff options
author | John Hood <cgull@glup.org> | 2015-10-05 02:18:17 -0400 |
---|---|---|
committer | John Hood <cgull@glup.org> | 2015-10-14 23:28:21 -0400 |
commit | 01749be64221299240388717623d576794aa0bca (patch) | |
tree | e2399661c50535d07909774ba61715036d0aeb6c | |
parent | fb76563d3335767f394fca29f960817e518c8cb2 (diff) |
Add test for behavior at column 80.
-rw-r--r-- | src/tests/Makefile.am | 1 | ||||
-rwxr-xr-x | src/tests/emulation-80th-column.test | 94 |
2 files changed, 95 insertions, 0 deletions
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index 9f72f10..57ff0ac 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -9,6 +9,7 @@ AM_LDFLAGS = $(HARDEN_LDFLAGS) displaytests = \ e2e-success.test \ e2e-failure.test \ + emulation-80th-column.test \ emulation-back-tab.test \ emulation-multiline-scroll.test \ unicode-combine-fallback-assert.test \ diff --git a/src/tests/emulation-80th-column.test b/src/tests/emulation-80th-column.test new file mode 100755 index 0000000..39ab1f9 --- /dev/null +++ b/src/tests/emulation-80th-column.test @@ -0,0 +1,94 @@ +#!/bin/sh + +# +# This test validates the ancient VT100 behavior of positioning the +# cursor at column 80 (and not wrapping) after 80 characters are +# output, and behaving accordingly with subsequent cursor motion +# commands (CR+LF in this state should not result in an extra blank +# line). +# + +fail() +{ + printf "$@" 2>&1 + exit 99 +} + + + +PATH=$PATH:.:$srcdir +# Top-level wrapper. +if [ $# -eq 0 ]; then + e2e-test $0 baseline post + exit +fi + +# OK, we have arguments, we're one of the test hooks. +if [ $# -ne 1 ]; then + fail "bad arguments %s\n" "$@" +fi + +sleepf() +{ + (sleep .1 || sleep 1) > /dev/null 2>&1 +} + +seq() +{ + if [ $# -lt 1 -o $# -gt 3 ]; then + echo "bad args" >&2 + fi + first=$1 + incr=1 + last=0 + case $# in + 3) + incr=$2 + last=$3 + ;; + 2) + last=$2 + ;; + 1) + ;; + esac + while :; do + printf '%d\n' $first + first=$(expr $first + $incr) + if [ $first -gt $last ]; then + break + fi + done +} + +baseline() +{ + # We need to control CR and LF individually for this test. + stty raw + printf '\033[H\033[J' + for lines in $(seq 1 25); do + for tencols in $(seq 1 8); do + printf "EEEEEEEEEE" + done + printf "\r\n" + done +} + +post() +{ + # If hidden 80th column is working properly, then the lines + # will have no blank lines in between and we should see 23 + # of them. + if [ $(grep -c "EEEEEEEEEE" $(basename $0).d/baseline.capture) -ne 23 ]; then + exit 1 + fi +} + +case $1 in + baseline) + baseline;; + post) + post;; + *) + fail "unknown test argument %s\n" $1;; +esac |