--- /dev/null
+#!/bin/bash
+# $Id$
+
+######################################################################
+#
+# Compare the file $1/output with files in $1/cmp
+#
+# Upon success, store the name of the successful file in $1/cmp
+# in the file $1/OK
+#
+######################################################################
+
+# Process command line arguments.
+# $1 is the name of the test.
+#
+# options may be
+# -v for verbose output of diff
+
+diffout="/dev/null"
+diffopt=""
+
+for arg in $* ; do
+ if test "x$arg" = "x-v" ; then
+ diffout="/dev/stdout" ;
+ fi
+done
+
+# First, we check if $1/OK exists. If so, it hopefully contains the
+# name of the successful comparison file in $1/cmp
+
+if test -r $1/OK; then
+ okname=`cat $1/OK`
+ if test "x$okname" != "x" ; then
+ echo -n " $1/cmp/$okname"
+ if diff $diffopt $1/output $1/cmp/$okname > $diffout ; then
+ exit 0 ;
+ fi
+ fi
+fi
+
+# If this round failed, check all files in this directory
+# If successful, write the name into $1/OK
+
+for file in `cd $1/cmp ; ls` ; do
+ echo -n " $1/cmp/$file"
+ if diff $diffopt $1/output $1/cmp/$file > $diffout ; then
+ echo $file > $1/OK
+ exit 0 ;
+ fi
+done
+
+# All files failed
+exit 1
+