# $Id$

do_cksum() {
    while read CRC SIZE NAME; do
	CRC2=0; SIZE2=0; NAME2=""
	if cksum "$NAME" | (
		read CRC2 SIZE2 NAME2

		if [ "$CRC" != "$CRC2" ] ; then
		    if [ 'quiet' != "$1"  ] ; then
			echo "$0: CRC didn't match for $NAME ($CRC != $CRC2)"
		    fi
		    return 0;
		fi

		if [ "$SIZE" != "$SIZE2" ]; then
		    echo "$0: SIZE didn't match for $NAME ($SIZE != $SIZE2)"
		    return 0;
		fi

		return 1
	    );
	    then
	    return 1; 
	fi
    done

    return 0;
}

have_cksum() {
    if cksum /dev/null > /dev/null 2>&1; then
	:
    else
	return 1;
    fi

    return 0;
}

# Echo result
check_result() {
  RC=$1
  shift
  msg=$*
  if test $RC -ne 0 ; then 
    if test $RC -ne 77 ; then
      echo "$0: $msg failed."
      exit $RC
    else 
      echo "$0: $msg skipped."
    fi
  else 
    echo "$0: $msg ok."
  fi
}

# Do a file compare of $1 with $2 for program $3
cmp_files() {
  outfile=$1
  rightfile=$2
  prog=$3
  if test "/usr/bin/diff" != no ; then
    if /usr/bin/diff  -w --unified ${outfile} ${rightfile} ; then
      rm -f $outfile
      return 0
    else
      return 3
    fi
  else
    echo "$0: No diff(1) or cmp(1) found - cannot test $prog"
    rm -f $outfile
    return 77
  fi
}

#;;; Local Variables: ***
#;;; mode:shell-script ***
#;;; eval: (sh-set-shell "bash") ***
#;;; End: ***
