#!/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