From a556f418842dfe03ea305962f0a37abd6d340348 Mon Sep 17 00:00:00 2001 From: David Levine Date: Tue, 6 Mar 2012 21:57:16 -0600 Subject: [PATCH] Added test-mhparam and test-mhstore. --- Makefile.am | 6 +- test/mhparam/test-mhparam | 101 +++++++++++++++++++ test/mhstore/test-mhstore | 243 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 348 insertions(+), 2 deletions(-) create mode 100755 test/mhparam/test-mhparam create mode 100755 test/mhstore/test-mhstore diff --git a/Makefile.am b/Makefile.am index 7d8568f..bf7151e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,9 +51,11 @@ TESTS = test/bad-input/test-header \ test/forw/test-forw-format \ test/inc/test-deb359167 test/inc/test-eom-align \ test/manpages/test-manpages test/mhbuild/test-forw \ - test/mhlist/test-mhlist test/mhpath/test-mhpath \ + test/mhlist/test-mhlist test/mhparam/test-mhparam \ + test/mhpath/test-mhpath \ test/mhshow/test-cte-binary test/mhshow/test-qp \ - test/mhshow/test-subpart test/new/test-basic \ + test/mhshow/test-subpart test/mhstore/test-mhstore \ + test/new/test-basic \ test/pick/test-pick test/pick/test-stderr \ test/repl/test-if-str test/scan/test-scan \ test/sequences/test-flist test/sequences/test-mark \ diff --git a/test/mhparam/test-mhparam b/test/mhparam/test-mhparam new file mode 100755 index 0000000..6615748 --- /dev/null +++ b/test/mhparam/test-mhparam @@ -0,0 +1,101 @@ +#!/bin/sh +###################################################### +# +# Test mhparam +# +###################################################### + +set -e + +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 + +expected=$MH_TEST_DIR/$$.expected +expected_err=$MH_TEST_DIR/$$.expected_err +actual=$MH_TEST_DIR/$$.actual +actual_err=$MH_TEST_DIR/$$.actual_err + + +# check -help +cat >$expected <$actual 2>&1 +check $expected $actual + +# check -version +if ! mhparam -v | grep '^mhparam --' >/dev/null; then + echo "$0: mhparam -v generated unexpected output" 1>&2 + failed=`expr ${failed:-0} + 1` +fi + +# check unknown option +run_test 'mhparam -nonexistent' 'mhparam: -nonexistent unknown' + +# check -all +cp $MH_TEST_DIR/Mail/.mh_profile $expected +# -all adds current folder +echo 'Current-Folder: '`folder -f` >>$expected +mhparam -all >$actual +check $expected $actual 'keep first' + +# check -all with a component +echo 'mhparam: profile-components ignored with -all' >$expected_err +mhparam -all path >$actual 2>$actual_err +check $expected $actual 'keep first' +check $expected_err $actual_err + +# check -all with -components +echo 'mhparam: -components ignored with -all' >$expected_err +mhparam -all -components >$actual 2>$actual_err +check $expected $actual +check $expected_err $actual_err + +# check one component +run_test 'mhparam path' "$MH_TEST_DIR/Mail" + +# check more than one component, which enables -component +echo 'AliasFile: aliases' >>"$MH_TEST_DIR/Mail/.mh_profile" +run_test 'mhparam path AliasFile' "path: $MH_TEST_DIR/Mail +AliasFile: aliases" + +# check -component +run_test 'mhparam -component Path' "Path: $MH_TEST_DIR/Mail" + +# check -component, note that component name of argument is echoed exactly +run_test 'mhparam -component path' "path: $MH_TEST_DIR/Mail" +run_test 'mhparam -component PATH' "PATH: $MH_TEST_DIR/Mail" + +# check -nocomponent +run_test 'mhparam -component -nocomponent path' "$MH_TEST_DIR/Mail" +run_test 'mhparam -nocomponent path AliasFile' "$MH_TEST_DIR/Mail +aliases" + +# check nonexistent component +run_test 'mhparam nonexistent' '' + +# check that return status counts nonexistent components +set +e +mhparam path context nonexistent1 nonexistent2 nonexistent3 >/dev/null +run_test "echo $?" 3 +set -e + +# mhparam -debug (undocumented) +# Some of its output depends on configure options, so don't bother to +# check for correctness here. +mhparam -debug >/dev/null + +exit $failed diff --git a/test/mhstore/test-mhstore b/test/mhstore/test-mhstore new file mode 100755 index 0000000..52b92f7 --- /dev/null +++ b/test/mhstore/test-mhstore @@ -0,0 +1,243 @@ +#!/bin/sh +###################################################### +# +# Test mhstore +# +###################################################### + +set -e + +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 + +expected=$MH_TEST_DIR/$$.expected +actual=$MH_TEST_DIR/$$.actual + +cd $MH_TEST_DIR + +# check with no options and no current message +run_test 'mhstore' 'mhstore: no cur message' + +# check with no options and current message +folder +inbox 5 > /dev/null +cat > $expected <&1 | \ + sed 's/.*as file //'` +check $expected $stored_contents + +# check message number greater than highest +run_test 'mhstore 11' "mhstore: message 11 doesn't exist" + +# check multiple messages +run_test 'mhstore 4 6' 'storing message 4 as file 4.txt +storing message 6 as file 6.txt' +cat > $expected < $expected < $msgfile < $expected < $expected < $expected < $expected < $expected < $expected < $expected < $MH_TEST_DIR/$$.tmp +mv -f $MH_TEST_DIR/$$.tmp $msgfile +run_test 'mhstore last -part 2 -check' \ +'storing message 11 part 2 as file 11.2.txt +mhstore: content integrity suspect (digest mismatch) -- continuing + (content text/plain in message 11, part 2)' +check $expected 11.2.txt 'keep first' + +# check -nocheck, the default +run_test 'mhstore last -part 2 -check -nocheck' \ + 'storing message 11 part 2 as file 11.2.txt' +check $expected 11.2.txt + +# check reassembly of message/partial messages (RFC 1521, 7.3.2) +msgfile=$(mhpath new) +cat > $msgfile < $msgfile < $msgfile < $expected <