# Common helper routines for test shell scripts -- intended to be sourced by them # @configure_input@ output_md5() { @MD5SUM@ $* | @MD5FMT@ } test_skip () { WHY="$1" echo "$Test $0 SKIP ($WHY)" exit 77 } # portable implementation of 'which' utility findprog() { FOUND= PROG="$1" IFS_SAVE="$IFS" IFS=: for D in $PATH; do if [ -z "$D" ]; then D=. fi if [ -f "$D/$PROG" ] && [ -x "$D/$PROG" ]; then printf '%s\n' "$D/$PROG" break fi done IFS="$IFS_SAVE" } require_prog () { if [ -z "$(findprog $1)" ]; then test_skip "missing $1" fi } # Some stuff for doing silly progress indicators progress_update () { THIS="$1" FIRST="$2" LAST="$3" RANGE="$(($LAST - $FIRST))" PROG="$(($THIS - $FIRST))" # this automatically rounds to nearest integer PERC="$(((100 * $PROG) / $RANGE))" # note \r so next update will overwrite printf "%3d%%\r" $PERC } progress_done () { printf "100%%\n" } setup_test () { export MH=${MH_TEST_DIR}/Mail/.mh_profile export MH_INST_DIR=${MH_TEST_DIR}/inst export MHMTSCONF=${MH_INST_DIR}${sysconfdir}/mts.conf export PATH=${MH_INST_DIR}${bindir}:${PATH} if [ -z "${srcdir}" ]; then echo "srcdir not set; aborting" exit 1 fi # # Only do this once # if [ ! -d ${MH_INST_DIR}${bindir} ]; then (cd ${MH_OBJ_DIR} && make DESTDIR=${MH_INST_DIR} install) || exit 1 fi # clean old test data trap "rm -rf $MH_TEST_DIR/Mail; exit \$status" 0 # setup test data mkdir $MH_TEST_DIR/Mail || exit 1 cat > $MH < /dev/null # create 10 basic messages for i in 1 2 3 4 5 6 7 8 9 10; do cat > $MH_TEST_DIR/Mail/inbox/$i < To: Some User Date: Fri, 29 Sep 2006 00:00:00 Subject: Testing message $i This is message number $i EOF done }