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 <<EOF
Date: Sun, 18 Dec 2005 00:52:39 +0100
From: foo@example.edu
@MD5SUM@ $* | @MD5FMT@ | cut -d ' ' -f 1
}
+#### Use built-in $((...)) in test suite if shell supports it.
+#### Borrowed from configure's as_fn_arith. The result is placed
+#### in global arith_val.
+#### Detected at run-time instead of by configure to allow testing
+#### with different shells.
+if (eval "test \$(( 1 + 1 )) = 2" 2>/dev/null); then
+ eval 'arith_eval () { arith_val=$(( $* )); }'
+else
+ arith_eval () { arith_val=`expr "$@" || test $? -eq 1`; }
+fi
+
test_skip ()
{
WHY="$1"
require_prog ()
{
- if [ -z "$(findprog $1)" ]; then
+ if [ -z `findprog $1` ]; then
test_skip "missing $1"
fi
}
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
}
#### 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
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
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
# 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}"
"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}
setup_test
-user="`id -un`"
+user=`id -un`
host=`${MH_OBJ_DIR}/test/getfqdn`
run_test "${MH_LIB_DIR}/ap -format %(mymbox{text}) ${user}" \
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"
fcc1="+nosuchmailbox"
fcc2="+nosuchmailbox2"
-digestdate=$(date "+%A, %e %b %Y")
+digestdate=`date "+%A, %e %b %Y"`
cat > "$expected" <<EOF
From: ${from}
i=1
while [ "$i" -le 6 ]
do
- filename=$(mhpath +inbox $i)
+ filename=`mhpath +inbox $i`
cat $filename >> "$expected"
cat >> "$expected" <<EOF
------------------------------
EOF
- i=$(expr $i + 1)
+ i=`expr $i + 1`
done
cat >> "$expected" <<EOF
i=7
while [ "$i" -le 8 ]
do
- filename=$(mhpath +inbox $i)
+ filename=`mhpath +inbox $i`
cat $filename >> "$expected"
cat >> "$expected" <<EOF
------------------------------
EOF
- i=$(expr $i + 1)
+ i=`expr $i + 1`
done
cat >> "$expected" <<EOF
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
# 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" | cut -d ' ' -f 1`
+HDRSZ=`wc -c "$HDR" | cut -d ' ' -f 1`
# makembox_A mboxname sz
# Assemble a mailbox into file mboxname, with two messages, such
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"
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"
# 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
11+ 03/01 Mr Nobody Who is on first?<<Abbott: Every dollar of it. And why not, the man's entitled to it. Cos"
-check "$(mhpath +inbox 11)" "${MH_TEST_DIR}/test.mbox.2" "keep first"
+check `mhpath +inbox 11` "${MH_TEST_DIR}/test.mbox.2" "keep first"
rm -f "${MH_TEST_DIR}/test.mbox" "${MH_TEST_DIR}/test.mbox.2"
run_test "scan -width 120 +inbox 11" \
check $expected $actual
# Write message with a text/plain subpart.
-msgfile=$(mhpath new)
+msgfile=`mhpath new`
cat > $msgfile <<EOF
To: recipient@example.com
From: sender@example.com
-version
-help
EOF
-# The exit status is 1 with -help, so invert it to prevent
-# triggering immediate exit due to set -e.
-! mhparam -help >$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
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
-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
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 <<EOF
Content-Transfer-Encoding: binary
To: bar@example.edu
actual=$MH_TEST_DIR/$$.actual
# Write message with bogus quoted-printable data.
-msgfile=$(mhpath new)
-msgnum=$(basename $msgfile)
+msgfile=`mhpath new`
+msgnum=`basename $msgfile`
cat > $msgfile <<EOF
From: foo@example.edu
To: bar@example.edu
actual=$MH_TEST_DIR/$$.actual
# Write message with a text/plain subpart.
-msgfile=$(mhpath new)
-msgnum=$(basename $msgfile)
+msgfile=`mhpath new`
+msgnum=`basename $msgfile`
cat > $msgfile <<EOF
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="NextPart_001"
check $expected 6.txt
# Write message with a text/plain subpart.
-msgfile=$(mhpath new)
+msgfile=`mhpath new`
cat > $msgfile <<EOF
To: recipient@example.com
From: sender@example.com
check $expected 11.2.txt
# check reassembly of message/partial messages (RFC 1521, 7.3.2)
-msgfile=$(mhpath new)
+msgfile=`mhpath new`
cat > $msgfile <<EOF
To: recipient@example.com
From: sender@example.com
This is part one of three.
EOF
-msgfile=$(mhpath new)
+msgfile=`mhpath new`
cat > $msgfile <<EOF
To: recipient@example.com
From: sender@example.com
This is part two of three.
EOF
-msgfile=$(mhpath new)
+msgfile=`mhpath new`
cat > $msgfile <<EOF
To: recipient@example.com
From: sender@example.com
check $expected $actual
# Invert exit status so execution doesn't terminate due to -e.
-! pick -after '29 Sep 2008 00:00:00' >$actual 2>/dev/null
+set +e
+pick -after '29 Sep 2008 00:00:00' >$actual 2>/dev/null
+set -e
cat >$expected <<EOF
0
EOF
10
EOF
check $expected $actual
-# Invert exit status so execution doesn't terminate due to -e.
-! pick -before '28 Sep 2006 00:00:00' last:3 >$actual 2>/dev/null
+set +e
+pick -before '28 Sep 2006 00:00:00' last:3 >$actual 2>/dev/null
+set -e
cat >$expected <<EOF
0
EOF
check $expected $actual
# Test -datefield.
-# Invert exit status so execution doesn't terminate due to -e.
-! pick -datefield date -after '29 Sep 2008 00:00:00' >$actual 2>/dev/null
+set +e
+pick -datefield date -after '29 Sep 2008 00:00:00' >$actual 2>/dev/null
+set -e
cat >$expected <<EOF
0
EOF
This is a fcc test
EOF
-msgname=$(mhpath +inbox 11)
+msgname=`mhpath +inbox 11`
sed -i.bak -e 's/^Date:.*/Date:/' "${msgname}"
other has 7 messages (1-13).
TOTAL = 12 messages in 2 folders.'
-if ! test -f $MH_TEST_DIR/Mail/inbox/,2; then
+if test -f $MH_TEST_DIR/Mail/inbox/,2; then
+ :
+else
echo "$0: refile -nounlink failed" 1>&2
failed=`expr ${failed:-0} + 1`
fi
#
set +e
-whatnowtest="$(echo cd | TERM=dumb whatnow -prompt '')"
+whatnowtest=`echo cd | TERM=dumb whatnow -prompt ''`
set -e
case "${whatnowtest}" in
detach $testname_quoted
alist
EOF
- break;;
+ ;;
"") cat > "$expected" <<EOF
$testname
EOF
- break;;
+ ;;
*) echo "Unknown response to whatnow readline test"
echo "Response is: ${whatnowtest}"
exit 1
- break;;
+ ;;
esac
# whatnow's exit status is always 1 so that is not a failure
#
set +e
-whatnowtest="$(echo cd | TERM=dumb whatnow -prompt '')"
+whatnowtest=`echo cd | TERM=dumb whatnow -prompt ''`
set -e
case "${whatnowtest}" in
pwd
$SPDIR
EOF
- break;;
+ ;;
"") cat > "$expected" <<EOF
$SPDIR
EOF
- break;;
+ ;;
*) echo "Unknown response to whatnow readline test"
echo "Response is: ${whatnowtest}"
exit 1
- break;;
+ ;;
esac
cat > $expectederr <<EOF
#
set +e
-whatnowtest="$(echo cd | TERM=dumb whatnow -prompt '')"
+whatnowtest=`echo cd | TERM=dumb whatnow -prompt ''`
set -e
case "${whatnowtest}" in
boz
ls
EOF
- break;;
+ ;;
"") cat > "$expected" <<EOF
baz
boz
EOF
- break;;
+ ;;
*) echo "Unknown response to whatnow readline test"
echo "Response is: ${whatnowtest}"
exit 1
- break;;
+ ;;
esac
cat > $expectederr <<EOF