Add a test for spinning on no-change screen updates

This commit is contained in:
John Hood
2016-10-28 02:01:14 -04:00
parent dc292dcdaa
commit 52d10cf211
3 changed files with 68 additions and 0 deletions
+1
View File
@@ -22,6 +22,7 @@ displaytests = \
emulation-cursor-motion.test \
emulation-multiline-scroll.test \
emulation-wrap-across-frames.test \
network-no-diff.test \
prediction-unicode.test \
pty-deadlock.test \
repeat.test \
+7
View File
@@ -29,6 +29,11 @@ fi
# run harnessed command
eval "$@"
testret=$?
# Capture mosh-server runtime if possible.
runtime=$(ps -o time= $PPID 2>/dev/null)
if [ $? -ne 0 ]; then # Cygwin...
runtime=-
fi
# Wait for tmux client screen to become up to date.
sleep 1
printf "@@@ server complete @@@" >&2
@@ -53,6 +58,8 @@ if ! tmux save-buffer "$testname.capture"; then
printf "tmux save-buffer failed, erroring test\n" >&2
exit 99
fi
# Dump runtime into tmux log.
printf "@@@ runtime %s @@@\n" "$runtime"
# return useful exitstatus from harnessed command
if [ $testret -ne 0 ]; then
exit 1
+60
View File
@@ -0,0 +1,60 @@
#!/bin/sh
#
# This is a regression test to ensure that Mosh does not spin
# on updates that do not actually change the framebuffer.
#
# shellcheck source=e2e-test-subrs
. "$(dirname "$0")/e2e-test-subrs"
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
baseline()
{
# Generate updates that don't change the screen
i=0
while [ $i -lt 10 ]; do
printf 'x\b'
i=$((i + 1))
sleep 1
done
}
post()
{
# Extract server run time.
runtime=$(sed -E -n 's/.*@@@ runtime: (.*) @@@.*/\1/p' "$(basename "$0").d/baseline.tmux.log")
# If this system can't actually report runtime, bail.
if [ -z "$runtime" ] || [ "$runtime" -eq "-" ]; then
exit 0
fi
# If we ran for more than one second, fail.
seconds=${runtime##*:}
bigger=${runtime%:*}
onesec=$(echo "$seconds >= 1" | bc)
if [ "$onesec" -eq 1 ] || [ "$bigger" -ne 0 ]; then
exit 1
fi
exit 0
}
case $1 in
baseline)
baseline;;
post)
post;;
*)
fail "unknown test argument %s\n" "$1";;
esac