src/tests: clean up duplicate code

This commit is contained in:
John Hood
2016-02-24 00:43:56 -05:00
parent ed92637f25
commit 49a4106ae4
17 changed files with 88 additions and 458 deletions
+1
View File
@@ -1,6 +1,7 @@
EXTRA_DIST = \ EXTRA_DIST = \
hold-stdin print-exitstatus \ hold-stdin print-exitstatus \
e2e-test e2e-test-server \ e2e-test e2e-test-server \
e2e-test-subrs \
mosh-client mosh-server \ mosh-client mosh-server \
$(displaytests) \ $(displaytests) \
emulation-attributes.test emulation-attributes.test
+1 -8
View File
@@ -1,13 +1,6 @@
#!/bin/sh #!/bin/sh
fail() . $(dirname $0)/e2e-test-subrs
{
printf "$@" 2>&1
exit 99
}
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
+1 -8
View File
@@ -1,13 +1,6 @@
#!/bin/sh #!/bin/sh
fail() . $(dirname $0)/e2e-test-subrs
{
printf "$@" 2>&1
exit 99
}
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
+71
View File
@@ -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
}
+1 -41
View File
@@ -8,14 +8,7 @@
# line). # line).
# #
fail() . $(dirname $0)/e2e-test-subrs
{
printf "$@" 2>&1
exit 99
}
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -28,39 +21,6 @@ if [ $# -ne 1 ]; then
fail "bad arguments %s\n" "$@" fail "bad arguments %s\n" "$@"
fi 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() baseline()
{ {
# We need to control CR and LF individually for this test. # We need to control CR and LF individually for this test.
+1 -66
View File
@@ -3,14 +3,8 @@
# #
# This validates display of ASCII and ISO-8859-1 characters. # This validates display of ASCII and ISO-8859-1 characters.
# #
fail()
{
printf "$@" 2>&1
exit 99
}
. $(dirname $0)/e2e-test-subrs
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -23,65 +17,6 @@ if [ $# -ne 1 ]; then
fail "bad arguments %s\n" "$@" fail "bad arguments %s\n" "$@"
fi 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() baseline()
{ {
printf '\033[H\033[J' printf '\033[H\033[J'
+1 -41
View File
@@ -10,14 +10,7 @@
# compares on these values fail though they are visually identical. # compares on these values fail though they are visually identical.
# #
fail() . $(dirname $0)/e2e-test-subrs
{
printf "$@" 2>&1
exit 99
}
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -30,39 +23,6 @@ if [ $# -ne 1 ]; then
fail "bad arguments %s\n" "$@" fail "bad arguments %s\n" "$@"
fi 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() baseline()
{ {
# Strip our name to the last dash-separated word before the .test suffix. # Strip our name to the last dash-separated word before the .test suffix.
+1 -8
View File
@@ -4,14 +4,7 @@
# This test is for issue 539 on github. # This test is for issue 539 on github.
# #
fail() . $(dirname $0)/e2e-test-subrs
{
printf "$@" 2>&1
exit 99
}
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
+1 -40
View File
@@ -4,14 +4,8 @@
# This test exercises a particular optimization involving small cursor # This test exercises a particular optimization involving small cursor
# motions in Mosh. # motions in Mosh.
# #
fail()
{
printf "$@" 2>&1
exit 99
}
. $(dirname $0)/e2e-test-subrs
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -24,39 +18,6 @@ if [ $# -ne 1 ]; then
fail "bad arguments %s\n" "$@" fail "bad arguments %s\n" "$@"
fi 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() baseline()
{ {
printf '\033[H\033[J' printf '\033[H\033[J'
+2 -40
View File
@@ -5,14 +5,9 @@
# of performance code for Mosh, involving insert/delete line. # of performance code for Mosh, involving insert/delete line.
# It does insert/delete line from 0 to 2 more than the window height # It does insert/delete line from 0 to 2 more than the window height
# 24 in this test environment). # 24 in this test environment).
fail() #
{
printf "$@" 2>&1
exit 99
}
. $(dirname $0)/e2e-test-subrs
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -25,39 +20,6 @@ if [ $# -ne 1 ]; then
fail "bad arguments %s\n" "$@" fail "bad arguments %s\n" "$@"
fi 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() baseline()
{ {
printf '\033[H\033[J' printf '\033[H\033[J'
+1 -66
View File
@@ -8,14 +8,8 @@
# between cells. It got moved to the Rows class where it makes more # between cells. It got moved to the Rows class where it makes more
# sense. # sense.
# #
fail()
{
printf "$@" 2>&1
exit 99
}
. $(dirname $0)/e2e-test-subrs
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -28,65 +22,6 @@ if [ $# -ne 1 ]; then
fail "bad arguments %s\n" "$@" fail "bad arguments %s\n" "$@"
fi 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() baseline()
{ {
printf '\033[H\033[J' printf '\033[H\033[J'
+1 -66
View File
@@ -24,14 +24,8 @@
# would be predicted as ")" before being replaced by the # would be predicted as ")" before being replaced by the
# correct character. # correct character.
# #
fail()
{
printf "$@" 2>&1
exit 99
}
. $(dirname $0)/e2e-test-subrs
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -39,65 +33,6 @@ if [ $# -eq 0 ]; then
exit exit
fi 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() tmux_commands()
{ {
for x in $(seq 1 5); do for x in $(seq 1 5); do
+1 -9
View File
@@ -11,15 +11,7 @@
# cleanup with kill -9. # cleanup with kill -9.
# #
. $(dirname $0)/e2e-test-subrs
fail()
{
printf "$@" 2>&1
exit 99
}
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
+1 -8
View File
@@ -14,14 +14,7 @@
TIMEOUT=10 TIMEOUT=10
fail() . $(dirname $0)/e2e-test-subrs
{
printf "$@" 2>&1
exit 99
}
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -8,14 +8,7 @@
# #
# It just sends the offending output to mosh and expects it to not die. # It just sends the offending output to mosh and expects it to not die.
fail() . $(dirname $0)/e2e-test-subrs
{
printf "$@" 2>&1
exit 99
}
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
+1 -8
View File
@@ -10,14 +10,7 @@
# that are visually identical. The variant test is not run or validated. # that are visually identical. The variant test is not run or validated.
# #
fail() . $(dirname $0)/e2e-test-subrs
{
printf "$@" 2>&1
exit 99
}
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
+1 -41
View File
@@ -6,14 +6,7 @@
# resize them. But it works! # resize them. But it works!
# #
fail() . $(dirname $0)/e2e-test-subrs
{
printf "$@" 2>&1
exit 99
}
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -21,39 +14,6 @@ if [ $# -eq 0 ]; then
exit exit
fi 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() tmux_resize_commands()
{ {
hv=$1 hv=$1