From: David Levine Date: Wed, 25 Apr 2012 02:04:54 +0000 (-0500) Subject: Fixed test suite to work with Solaris Bourne shell: X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=8f75811e49388577186fc634e931edc1834b59c9;p=mmh Fixed test suite to work with Solaris Bourne shell: 1) Removed ! (negation) of statuses. 2) Removed initializations from export statements. 3) Replaced $() with ``. 4) Replaced $(()) (and expr) with new function arith_eval (). (cherry picked from commit a6af3b6300e02ade9f223f8d91667f590d191dc9) --- diff --git a/test/bad-input/test-header b/test/bad-input/test-header index b45a576..af7e784 100755 --- a/test/bad-input/test-header +++ b/test/bad-input/test-header @@ -18,8 +18,8 @@ expected=$MH_TEST_DIR/$$.expected actual=$MH_TEST_DIR/$$.actual # Write message with bogus header field (missing blank line, really). -msgfile=$(mhpath new) -msgnum=$(basename $msgfile) +msgfile=`mhpath new` +msgnum=`basename $msgfile` cat > $msgfile </dev/null); then + eval 'arith_eval () { arith_val=$(( $* )); }' +else + arith_eval () { arith_val=`expr "$@" || test $? -eq 1`; } +fi + test_skip () { WHY="$1" @@ -57,7 +68,7 @@ findprog() require_prog () { - if [ -z "$(findprog $1)" ]; then + if [ -z `findprog $1` ]; then test_skip "missing $1" fi } @@ -68,10 +79,10 @@ progress_update () THIS="$1" FIRST="$2" LAST="$3" - RANGE="$(($LAST - $FIRST))" - PROG="$(($THIS - $FIRST))" + arith_eval $LAST - $FIRST; RANGE=$arith_val + arith_eval $THIS - $FIRST; PROG=$arith_val # this automatically rounds to nearest integer - PERC="$(((100 * $PROG) / $RANGE))" + arith_eval 100 \* $PROG / $RANGE; PERC=$arith_val # note \r so next update will overwrite printf "%3d%%\r" $PERC } @@ -104,8 +115,9 @@ check() { #### an error message is printed and global variable "failed" is incremented; #### if there is an optional third argument, it is used in the error message. run_test() { - #### Invert exit status to prevent triggering immediate exit due to set -e. - ! actual_output="`$1 2>&1`" + set +e + actual_output=`$1 2>&1` + set -e if test x"$actual_output" != x"$2"; then echo "$0: ${3:-\"$1\"} expected:" 1>&2 echo " '$2'" 1>&2 @@ -117,15 +129,18 @@ run_test() { setup_test () { - export MH=${MH_TEST_DIR}/Mail/.mh_profile - export MHMTSCONF=${MH_INST_DIR}${sysconfdir}/mts.conf - export PATH=${MH_INST_DIR}${bindir}:${PATH} - export MH_LIB_DIR=${MH_INST_DIR}${auxexecdir} + MH=${MH_TEST_DIR}/Mail/.mh_profile + MHMTSCONF=${MH_INST_DIR}${sysconfdir}/mts.conf + PATH=${MH_INST_DIR}${bindir}:${PATH} + MH_LIB_DIR=${MH_INST_DIR}${auxexecdir} + export MH MHMTSCONF MH_LIB_DIR # # Only install once # - if [ ! -d ${MH_INST_DIR}${bindir} ]; then + if [ -d ${MH_INST_DIR}${bindir} ]; then + : + else (cd ${MH_OBJ_DIR} && make DESTDIR=${MH_INST_DIR} install) || exit 1 fi diff --git a/test/folder/test-create b/test/folder/test-create index 1af751e..59e7c3f 100755 --- a/test/folder/test-create +++ b/test/folder/test-create @@ -15,7 +15,9 @@ fi setup_test folder -create +testfolder > /dev/null -if [ ! -d "$MH_TEST_DIR/Mail/testfolder" ]; then +if [ -d "$MH_TEST_DIR/Mail/testfolder" ]; then + : +else exit 1 fi diff --git a/test/format/test-localmbox b/test/format/test-localmbox index 36f9392..d3c43ef 100755 --- a/test/format/test-localmbox +++ b/test/format/test-localmbox @@ -19,7 +19,7 @@ echo "Local-Mailbox: ${testname}" >> ${MH} # We can use "ap" to get the output of format commands -testoutput=$(${MH_LIB_DIR}/ap -format "%(localmbox)" ignore) +testoutput=`${MH_LIB_DIR}/ap -format "%(localmbox)" ignore` if [ x"${testname}" != x"${testoutput}" ]; then echo "Expected ${testname}, got ${testoutput}" diff --git a/test/format/test-myhost b/test/format/test-myhost index 635f35f..375f8ac 100755 --- a/test/format/test-myhost +++ b/test/format/test-myhost @@ -18,7 +18,7 @@ run_test "${MH_LIB_DIR}/ap -format %(myhost) ignore" "$host" \ "local hostname test" cp ${MHMTSCONF} ${MH_TEST_DIR}/Mail/mts.conf || exit 1 -export MHMTSCONF="${MH_TEST_DIR}/Mail/mts.conf" +MHMTSCONF="${MH_TEST_DIR}/Mail/mts.conf" echo "localname: some.random.name" >> ${MHMTSCONF} diff --git a/test/format/test-mymbox b/test/format/test-mymbox index c154a8b..ba0f706 100755 --- a/test/format/test-mymbox +++ b/test/format/test-mymbox @@ -13,7 +13,7 @@ fi setup_test -user="`id -un`" +user=`id -un` host=`${MH_OBJ_DIR}/test/getfqdn` run_test "${MH_LIB_DIR}/ap -format %(mymbox{text}) ${user}" \ diff --git a/test/format/test-myname b/test/format/test-myname index 15ca852..dda0f37 100755 --- a/test/format/test-myname +++ b/test/format/test-myname @@ -26,7 +26,8 @@ echo "Signature: Some Random Name 1" >> ${MH} run_test "${MH_LIB_DIR}/ap -format %(myname) ignore" \ "Some Random Name 1" "MH Profile Signature test" -export SIGNATURE="Some Random Name 2" +SIGNATURE="Some Random Name 2" +export SIGNATURE run_test "${MH_LIB_DIR}/ap -format %(myname) ignore" \ "${SIGNATURE}" "SIGNATURE Environment test" diff --git a/test/forw/test-forw-digest b/test/forw/test-forw-digest index 7106fe8..ff39ddd 100755 --- a/test/forw/test-forw-digest +++ b/test/forw/test-forw-digest @@ -24,7 +24,7 @@ cc4="CC User Four " fcc1="+nosuchmailbox" fcc2="+nosuchmailbox2" -digestdate=$(date "+%A, %e %b %Y") +digestdate=`date "+%A, %e %b %Y"` cat > "$expected" <> "$expected" cat >> "$expected" <> "$expected" <> "$expected" cat >> "$expected" <> "$expected" </dev/null echo >> "$MBOX.body" cat "$FROMLINE" "$HDR" "$MBOX.body" > "$MBOX" @@ -84,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" @@ -124,15 +124,16 @@ do_one_test_B () { # 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 diff --git a/test/inc/test-inc-scanout b/test/inc/test-inc-scanout index 419147c..b66965a 100755 --- a/test/inc/test-inc-scanout +++ b/test/inc/test-inc-scanout @@ -189,7 +189,7 @@ run_test "inc -file ${MH_TEST_DIR}/test.mbox -width 120 -truncate" \ 11+ 03/01 Mr Nobody Who is on first?< $actual 2>&1 check $expected $actual # Write message with a text/plain subpart. -msgfile=$(mhpath new) +msgfile=`mhpath new` cat > $msgfile <$actual 2>&1 +# The exit status is 1 with -help, so temporarily disable -e. +set +e +mhparam -help >$actual 2>&1 +set -e check $expected $actual # check -version -if ! mhparam -v | grep '^mhparam --' >/dev/null; then +if mhparam -v | grep '^mhparam --' >/dev/null; then + : +else echo "$0: mhparam -v generated unexpected output" 1>&2 failed=`expr ${failed:-0} + 1` fi @@ -133,8 +136,10 @@ check $expected $actual run_test 'mhparam faceproc formatproc rmmproc' '' #### test sbackup separately because it's only passed as a -D compile option -if ! mhparam sbackup | grep -F ', +if mhparam sbackup | grep -F ', #' >/dev/null; then + : +else echo mhparam sbackup failed failed=`expr ${failed:-0} + 1` fi diff --git a/test/mhpath/test-mhpath b/test/mhpath/test-mhpath index 71ee9ea..54a1a12 100755 --- a/test/mhpath/test-mhpath +++ b/test/mhpath/test-mhpath @@ -27,13 +27,16 @@ Usage: mhpath [+folder] [msgs] [switches] -version -help EOF -# The exit status is 1 with -help, so invert it to prevent -# triggering immediate exit due to set -e. -! mhpath -help > $actual 2>&1 +# The exit status is 1 with -help, so temporarily disable -e. +set +e +mhpath -help > $actual 2>&1 +set -e check $expected $actual # check -version -if ! mhpath -v | grep '^mhpath --' > /dev/null; then +if mhpath -v | grep '^mhpath --' > /dev/null; then + : +else echo "$0: mhpath -v generated unexpected output" 1>&2 failed=`expr ${failed:-0} + 1` fi diff --git a/test/mhshow/test-cte-binary b/test/mhshow/test-cte-binary index b53f1e0..8f582b0 100755 --- a/test/mhshow/test-cte-binary +++ b/test/mhshow/test-cte-binary @@ -17,8 +17,8 @@ expected=$MH_TEST_DIR/$$.expected actual=$MH_TEST_DIR/$$.actual # Write message with Content-Transfer-Encoding: binary text. -msgfile=$(mhpath new) -msgnum=$(basename $msgfile) +msgfile=`mhpath new` +msgnum=`basename $msgfile` cat > $msgfile < $msgfile < $msgfile < $msgfile < $msgfile < $msgfile < $msgfile <$actual 2>/dev/null +set +e +pick -after '29 Sep 2008 00:00:00' >$actual 2>/dev/null +set -e cat >$expected <$expected <$actual 2>/dev/null +set +e +pick -before '28 Sep 2006 00:00:00' last:3 >$actual 2>/dev/null +set -e cat >$expected <$actual 2>/dev/null +set +e +pick -datefield date -after '29 Sep 2008 00:00:00' >$actual 2>/dev/null +set -e cat >$expected <&2 failed=`expr ${failed:-0} + 1` fi diff --git a/test/whatnow/test-attach-detach b/test/whatnow/test-attach-detach index fe5785c..7d538a2 100755 --- a/test/whatnow/test-attach-detach +++ b/test/whatnow/test-attach-detach @@ -38,7 +38,7 @@ touch $expected $expectederr $actual $actualerr # set +e -whatnowtest="$(echo cd | TERM=dumb whatnow -prompt '')" +whatnowtest=`echo cd | TERM=dumb whatnow -prompt ''` set -e case "${whatnowtest}" in @@ -49,15 +49,15 @@ $testname detach $testname_quoted alist EOF - break;; + ;; "") cat > "$expected" < "$expected" < $expectederr < "$expected" < $expectederr <