src/tests: clean up duplicate code
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
EXTRA_DIST = \
|
||||
hold-stdin print-exitstatus \
|
||||
e2e-test e2e-test-server \
|
||||
e2e-test-subrs \
|
||||
mosh-client mosh-server \
|
||||
$(displaytests) \
|
||||
emulation-attributes.test
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# This is a library of subroutines mostly intended for test scripts.
|
||||
#
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
chr()
|
||||
{
|
||||
printf "\\$(printf %03o $1)"
|
||||
}
|
||||
|
||||
utf8cp()
|
||||
{
|
||||
if [ $1 -gt $((0x10ffff)) ]; then
|
||||
fail "illegal Unicode code point %x\n" $1
|
||||
elif [ $1 -lt $((0x80)) ]; then
|
||||
chr $1
|
||||
elif [ $1 -lt $((0x800)) ]; then
|
||||
chr $(( (($1 >> 6) & 0x1f) | 0xc0 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
elif [ $1 -lt $((0x10000)) ]; then
|
||||
chr $(( (($1 >> 12) & 0x0f) | 0xe0 ))
|
||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
elif [ $1 -lt $((0x200000)) ]; then
|
||||
chr $(( (($1 >> 18) & 0x03) | 0xf0 ))
|
||||
chr $(( (($1 >> 12) & 0x3f) | 0x80 ))
|
||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -8,14 +8,7 @@
|
||||
# line).
|
||||
#
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -28,39 +21,6 @@ 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.
|
||||
|
||||
@@ -3,14 +3,8 @@
|
||||
#
|
||||
# This validates display of ASCII and ISO-8859-1 characters.
|
||||
#
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -23,65 +17,6 @@ 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
|
||||
}
|
||||
|
||||
chr()
|
||||
{
|
||||
printf "\\$(printf %03o $1)"
|
||||
}
|
||||
|
||||
utf8cp()
|
||||
{
|
||||
if [ $1 -gt $((0x10ffff)) ]; then
|
||||
fail "illegal Unicode code point %x\n" $1
|
||||
elif [ $1 -lt $((0x80)) ]; then
|
||||
chr $1
|
||||
elif [ $1 -lt $((0x800)) ]; then
|
||||
chr $(( (($1 >> 6) & 0x1f) | 0xc0 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
elif [ $1 -lt $((0x10000)) ]; then
|
||||
chr $(( (($1 >> 12) & 0x0f) | 0xe0 ))
|
||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
elif [ $1 -lt $((0x200000)) ]; then
|
||||
chr $(( (($1 >> 18) & 0x03) | 0xf0 ))
|
||||
chr $(( (($1 >> 12) & 0x3f) | 0x80 ))
|
||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
fi
|
||||
}
|
||||
|
||||
baseline()
|
||||
{
|
||||
printf '\033[H\033[J'
|
||||
|
||||
@@ -10,14 +10,7 @@
|
||||
# compares on these values fail though they are visually identical.
|
||||
#
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -30,39 +23,6 @@ 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()
|
||||
{
|
||||
# Strip our name to the last dash-separated word before the .test suffix.
|
||||
|
||||
@@ -4,14 +4,7 @@
|
||||
# This test is for issue 539 on github.
|
||||
#
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
|
||||
@@ -4,14 +4,8 @@
|
||||
# This test exercises a particular optimization involving small cursor
|
||||
# motions in Mosh.
|
||||
#
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -24,39 +18,6 @@ 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'
|
||||
|
||||
@@ -5,14 +5,9 @@
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -25,39 +20,6 @@ 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'
|
||||
|
||||
@@ -8,14 +8,8 @@
|
||||
# between cells. It got moved to the Rows class where it makes more
|
||||
# sense.
|
||||
#
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -28,65 +22,6 @@ 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
|
||||
}
|
||||
|
||||
chr()
|
||||
{
|
||||
printf "\\$(printf %03o $1)"
|
||||
}
|
||||
|
||||
utf8cp()
|
||||
{
|
||||
if [ $1 -gt $((0x10ffff)) ]; then
|
||||
fail "illegal Unicode code point %x\n" $1
|
||||
elif [ $1 -lt $((0x80)) ]; then
|
||||
chr $1
|
||||
elif [ $1 -lt $((0x800)) ]; then
|
||||
chr $(( (($1 >> 6) & 0x1f) | 0xc0 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
elif [ $1 -lt $((0x10000)) ]; then
|
||||
chr $(( (($1 >> 12) & 0x0f) | 0xe0 ))
|
||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
elif [ $1 -lt $((0x200000)) ]; then
|
||||
chr $(( (($1 >> 18) & 0x03) | 0xf0 ))
|
||||
chr $(( (($1 >> 12) & 0x3f) | 0x80 ))
|
||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
fi
|
||||
}
|
||||
|
||||
baseline()
|
||||
{
|
||||
printf '\033[H\033[J'
|
||||
|
||||
@@ -24,14 +24,8 @@
|
||||
# would be predicted as ")" before being replaced by the
|
||||
# correct character.
|
||||
#
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -39,65 +33,6 @@ if [ $# -eq 0 ]; then
|
||||
exit
|
||||
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
|
||||
}
|
||||
|
||||
chr()
|
||||
{
|
||||
printf "\\$(printf %03o $1)"
|
||||
}
|
||||
|
||||
utf8cp()
|
||||
{
|
||||
if [ $1 -gt $((0x10ffff)) ]; then
|
||||
fail "illegal Unicode code point %x\n" $1
|
||||
elif [ $1 -lt $((0x80)) ]; then
|
||||
chr $1
|
||||
elif [ $1 -lt $((0x800)) ]; then
|
||||
chr $(( (($1 >> 6) & 0x1f) | 0xc0 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
elif [ $1 -lt $((0x10000)) ]; then
|
||||
chr $(( (($1 >> 12) & 0x0f) | 0xe0 ))
|
||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
elif [ $1 -lt $((0x200000)) ]; then
|
||||
chr $(( (($1 >> 18) & 0x03) | 0xf0 ))
|
||||
chr $(( (($1 >> 12) & 0x3f) | 0x80 ))
|
||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
fi
|
||||
}
|
||||
|
||||
tmux_commands()
|
||||
{
|
||||
for x in $(seq 1 5); do
|
||||
|
||||
@@ -11,15 +11,7 @@
|
||||
# cleanup with kill -9.
|
||||
#
|
||||
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
|
||||
@@ -14,14 +14,7 @@
|
||||
|
||||
TIMEOUT=10
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
|
||||
@@ -8,14 +8,7 @@
|
||||
#
|
||||
# It just sends the offending output to mosh and expects it to not die.
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
|
||||
@@ -10,14 +10,7 @@
|
||||
# that are visually identical. The variant test is not run or validated.
|
||||
#
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
# resize them. But it works!
|
||||
#
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -21,39 +14,6 @@ if [ $# -eq 0 ]; then
|
||||
exit
|
||||
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
|
||||
}
|
||||
|
||||
tmux_resize_commands()
|
||||
{
|
||||
hv=$1
|
||||
|
||||
Reference in New Issue
Block a user