+
+
+#### Replace generated Content-ID headers with static value
+replace_contentid()
+{
+ sed "/^Content-ID/s/:.*/: <TESTID>/" "$@"
+}
+
+
+#### Filter that squeezes blank lines, partially emulating GNU cat -s,
+#### but sufficient for our purpose.
+#### From http://www-rohan.sdsu.edu/doc/sed.html, compiled by Eric Pement.
+squeeze_lines()
+{
+ sed '/^$/N;/\n$/D'
+}
+
+#### Filter that converts non-breakable space U+00A0 to an ASCII space.
+prepare_space()
+{
+ sed 's/'"`printf '\\302\\240'`"'/ /g'
+}
+
+
+# first argument: command line to run
+# second argument: "normspace" to normalize the whitespace
+# stdin: expected output
+runandcheck()
+{
+ if [ "$2" = "normspace" ]; then
+ eval "$1" 2>&1 | prepare_space >"$tmpfile"
+ diff="`prepare_space | diff -ub - "$tmpfile" || :`"
+ else
+ eval "$1" >"$tmpfile" 2>&1
+ diff="`diff -u - "$tmpfile"`"
+ fi
+
+ if [ "$diff" ]; then
+ echo "$0: $1 failed"
+ echo "$diff"
+ failed=`expr "${failed:-0}" + 1`
+ fi
+}