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 -66
View File
@@ -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'