From fb76563d3335767f394fca29f960817e518c8cb2 Mon Sep 17 00:00:00 2001 From: John Hood Date: Sat, 3 Oct 2015 23:59:15 -0400 Subject: [PATCH] Add multiline-scroll regression test --- src/tests/Makefile.am | 1 + src/tests/emulation-multiline-scroll.test | 83 +++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100755 src/tests/emulation-multiline-scroll.test diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index df126f0..9f72f10 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -10,6 +10,7 @@ displaytests = \ e2e-success.test \ e2e-failure.test \ emulation-back-tab.test \ + emulation-multiline-scroll.test \ unicode-combine-fallback-assert.test \ unicode-later-combining.test diff --git a/src/tests/emulation-multiline-scroll.test b/src/tests/emulation-multiline-scroll.test new file mode 100755 index 0000000..a490ab3 --- /dev/null +++ b/src/tests/emulation-multiline-scroll.test @@ -0,0 +1,83 @@ +#!/bin/sh + +# +# This is a regression test for a crash seen in my development +# of performance code for Mosh, involving insert/delete line. +# It does insert/delete line from 0 to 2 more than the window height +# 24 in this test environment). +fail() +{ + printf "$@" 2>&1 + exit 99 +} + + + +PATH=$PATH:.:$srcdir +# Top-level wrapper. +if [ $# -eq 0 ]; then + e2e-test $0 baseline + 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() +{ + printf '\033[H\033[J' + for dir in L M; do + for i in $(seq 0 2) $(seq 22 26); do + printf '%d\r' $i + printf '\033[%d%s' $i $dir + # On the one hand, we'd like to test that this works + # properly on both client and server, which requires + # delays so that each iteration percolates to the client + # by itself. On the other hand, that makes the test take + # a long time. Compromise on .1 second. + (sleep .1 || sleep 1) > /dev/null 2>&1 + done + done +} + +case $1 in + baseline) + baseline;; + *) + fail "unknown test argument %s\n" $1;; +esac