X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=test%2Finc%2Ftest-eom-align;h=5acdc0eb0897302136934fe4b9e3f7480733ddb6;hb=a6f717992d5588898c37711aa1895dbb11016e1c;hp=276d70c7208f2a16b2cd1afb72f2d08921a1b202;hpb=c65573459d4b3de74e78ff2f0e3c248d84d3b8fe;p=mmh diff --git a/test/inc/test-eom-align b/test/inc/test-eom-align index 276d70c..5acdc0e 100755 --- a/test/inc/test-eom-align +++ b/test/inc/test-eom-align @@ -4,33 +4,41 @@ set -e -. ${MH_TEST_COMMON} +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname "$0"`/../.. + MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" setup_test -THISDIR="${srcdir}/test/inc" +THISDIR="$srcdir/test/inc" -if [ ! -z "$VALGRIND_ME" ]; then +if [ -z "$VALGRIND_ME" ]; then + VALGRIND= +else require_prog valgrind # Lack of quotes here is important VALGRIND="valgrind --quiet --error-exitcode=1" echo "Running tests under valgrind: takes ages!" -else - VALGRIND= fi # First check that all our various pieces of text are # intact. (Since we're dealing in exact byte alignment # minor corruptions such as line ending changes could # render the tests useless.) -(cd "$THISDIR" && output_md5 *.txt > "$MH_TEST_DIR/inctest.md5sums") -diff -u "$THISDIR/md5sums" "$MH_TEST_DIR/inctest.md5sums" +(cd "$THISDIR" && \ + for i in *.txt; do + echo `output_md5 $i`' '"$i" >> "$MH_TEST_DIR/inctest.md5sums" + done) +check "$THISDIR/md5sums" "$MH_TEST_DIR/inctest.md5sums" 'keep first' FILLER="$THISDIR/filler.txt" FROMLINE="$THISDIR/fromline.txt" HDR="$THISDIR/msgheader.txt" -if grep -q From "$FILLER"; then +if grep From "$FILLER" >/dev/null; then echo "Somebody's messed with $FILLER -- it must not contain" echo "anything that might look like a message delimiter!" exit 1 @@ -43,8 +51,8 @@ fi # bigger as well. STDIO_BUFSZ=16384 -FROMLINESZ="$(wc -c "$FROMLINE" | cut -d ' ' -f 1)" -HDRSZ="$(wc -c "$HDR" | cut -d ' ' -f 1)" +FROMLINESZ=`wc -c < "$FROMLINE"` +HDRSZ=`wc -c < "$HDR"` # makembox_A mboxname sz # Assemble a mailbox into file mboxname, with two messages, such @@ -57,7 +65,7 @@ makembox_A () { MBOX="$1" SZ=$2 - WANTSZ="$(($SZ - $HDRSZ - $FROMLINESZ - 1))" + arith_eval $SZ - $HDRSZ - $FROMLINESZ - 1; WANTSZ=$arith_val dd if="$FILLER" of="$MBOX.body" bs="$WANTSZ" count=1 2>/dev/null echo >> "$MBOX.body" cat "$FROMLINE" "$HDR" "$MBOX.body" > "$MBOX" @@ -76,7 +84,7 @@ makembox_B () { MBOX="$1" SZ=$2 - WANTSZ="$(($SZ - $HDRSZ - $FROMLINESZ - 1))" + arith_eval $SZ - $HDRSZ - $FROMLINESZ - 1; WANTSZ=$arith_val dd if="$FILLER" of="$MBOX.body" bs="$WANTSZ" count=1 2>/dev/null echo >> "$MBOX.body" cat "$FROMLINE" "$HDR" "$MBOX.body" > "$MBOX" @@ -91,10 +99,12 @@ do_one_test_A () { $VALGRIND inc -silent -file "$MH_TEST_DIR/eom-align.mbox" # We know the messages should be 11 and 12 in inbox # Now get the bodies back out. - sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/11" > "$MH_TEST_DIR/eom-align.inbox.body1" - sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/12" > "$MH_TEST_DIR/eom-align.inbox.body2" - diff -u "$MH_TEST_DIR/eom-align.mbox.body" "$MH_TEST_DIR/eom-align.inbox.body1" - diff -u "$FILLER" "$MH_TEST_DIR/eom-align.inbox.body2" + body1="$MH_TEST_DIR/eom-align.inbox.body1" + body2="$MH_TEST_DIR/eom-align.inbox.body2" + sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/11" > "$body1" + sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/12" > "$body2" + check "$MH_TEST_DIR/eom-align.mbox.body" "$body1" 'keep first' + check "$FILLER" "$body2" 'keep first' rmm 11 12 } @@ -105,23 +115,29 @@ do_one_test_B () { makembox_B "$MH_TEST_DIR/eom-align.mbox" $STDIO_BUFSZ $VALGRIND inc -silent -file "$MH_TEST_DIR/eom-align.mbox" # We know the message should be 11 in the inbox - sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/11" > "$MH_TEST_DIR/eom-align.inbox.body1" - diff -u "$MH_TEST_DIR/eom-align.mbox.body" "$MH_TEST_DIR/eom-align.inbox.body1" + body1="$MH_TEST_DIR/eom-align.inbox.body1" + sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/11" > "$body1" + check "$MH_TEST_DIR/eom-align.mbox.body" "$body1" 'keep first' rmm 11 } - # Cover a decent range around the stdio buffer size to make sure we catch # any corner cases whether they relate to total message size equal to # buffer size or to body size equal to buffer size. -START=$(($STDIO_BUFSZ - 16)) -FINISH=$(($STDIO_BUFSZ + $HDRSZ + $FROMLINESZ + 32)) -echo "Testing inc of files with various alignments of eom marker with buffer size..." +arith_eval $STDIO_BUFSZ - 16; START=$arith_val +arith_eval $STDIO_BUFSZ + $HDRSZ + $FROMLINESZ + 32; FINISH=$arith_val +echo \ +"Testing inc of files with various alignments of eom marker with buffer size..." i="$START" while test $i -le $FINISH; do progress_update $i $START $FINISH do_one_test_A $i do_one_test_B $i - i=$(expr $i + 1) + i=`expr $i + 1` done progress_done + +test ${failed:-0} -eq 0 && \ +rm "$MH_TEST_DIR/eom-align.mbox" "$MH_TEST_DIR/eom-align.mbox.body" + +exit $failed