1 # Common helper routines for test shell scripts
2 # -- intended to be sourced by them
11 #fake sleeps 60 secounds and then reads all input
30 # portable implementation of 'which' utility
41 if [ -f "$D/$PROG" ] && [ -x "$D/$PROG" ]; then
42 printf '%s\n' "$D/$PROG"
51 if [ -z "$(findprog $1)" ]; then
52 test_skip "missing $1"
58 for locale in "$@"; do
59 if locale -a | grep -i "$locale" >/dev/null; then
63 test_skip "no suitable locale available"
66 # Do a best guess at FQDN
69 hostname -f 2>/dev/null || uname -n
72 # Some stuff for doing silly progress indicators
75 test -t 1 || return 0 # suppress progress meter if non-interactive
79 range="$(expr $last - $first ||:)"
80 prog="$(expr $this - $first ||:)"
81 # this automatically rounds to nearest integer
82 perc="$(expr 100 \* $prog / $range ||:)"
83 # note \r so next update will overwrite
84 printf "%3d%%\r" $perc
89 test -t 1 || return 0 # suppress progress meter if non-interactive
94 #### Replace generated Content-ID headers with static value
97 sed "/^Content-ID/s/:.*/: <TESTID>/" "$@"
101 #### Filter that squeezes blank lines, partially emulating GNU cat -s,
102 #### but sufficient for our purpose.
103 #### From http://www-rohan.sdsu.edu/doc/sed.html, compiled by Eric Pement.
109 #### Filter that converts non-breakable space U+00A0 to an ASCII space.
112 sed 's/'"`printf '\\302\\240'`"'/ /g'
116 # first argument: command line to run
117 # second argument: "normspace" to normalize the whitespace
118 # stdin: expected output
121 if [ "$2" = "normspace" ]; then
122 eval "$1" 2>&1 | prepare_space >"$tmpfile"
123 diff="`prepare_space | diff -ub - "$tmpfile" || :`"
125 eval "$1" >"$tmpfile" 2>&1
126 diff="`diff -u - "$tmpfile"`"
132 failed=`expr "${failed:-0}" + 1`