X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/40cbba6fa1e5926cebd5e2a26b92a8f0b647474e..d6f99160c913cb04406f9a71eb059018e17f477b:/test/bad-input/test-header diff --git a/test/bad-input/test-header b/test/bad-input/test-header index 0e210dba..eeacc831 100755 --- a/test/bad-input/test-header +++ b/test/bad-input/test-header @@ -5,6 +5,8 @@ # ###################################################### +set -e + if test -z "${MH_OBJ_DIR}"; then srcdir=`dirname "$0"`/../.. MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR @@ -33,10 +35,10 @@ EOF # check scan cat >"$expected" < "$actual" 2>&1 -check "$expected" "$actual" +run_prog scan -width 80 last > "$actual" 2>&1 +check "$expected" "$actual" : scan with bogus header field # check show (mhl) cat >"$expected" < "$actual" 2>&1 -check "$expected" "$actual" +run_prog show last > "$actual" 2>&1 +check "$expected" "$actual" : "show (mhl) with bogus header field" # check mhshow cat >"$expected" < "$actual" 2>&1 -check "$expected" "$actual" +run_prog mhshow last > "$actual" 2>&1 +check "$expected" "$actual" : mhshow with bogus header field # check m_getfld() handling of empty header field msgfile="$MH_TEST_DIR/Mail/inbox/12" printf 'Date: Sat, 12 Jan 2013 09:07:01 -0600\nReceived:' >"$msgfile" cat >"$expected" <"$expected_err" <"$actual" 2>"$actual_err" -check "$expected" "$actual" -check "$expected_err" "$actual_err" +run_prog scan -width 13 last >"$actual" 2>"$actual_err" +check "$expected" "$actual" : m_getfld, empty header output +check "$expected_err" "$actual_err" : m_getfld, empty header error # check m_getfld() handling of excessively long header field name msgfile="$MH_TEST_DIR/Mail/inbox/13" @@ -94,16 +97,25 @@ Date: Tue, 15 Jan 2013 21:13:12 -0600 ThisHeaderFieldNameIsWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaayTooLong: OK EOF cat >"$expected" <"$expected_err" <"$actual" 2>"$actual_err" -check "$expected" "$actual" -check "$expected_err" "$actual_err" +run_prog scan -width 13 last >"$actual" 2>"$actual_err" +check "$expected" "$actual" : m_getfld with excessively long header field name +# Cygwin has a BUFSIZ of 1024 so the error message gets truncated. +# Deal with that by grepping to verify that scan showed the proper error. +verify_string_in_file() { + if grep "$1" "$2" >/dev/null; then + : + else + echo "$0: did not receive expected error message \"$1\"" + failed=`expr ${failed:-0} + 1` + fi +} +verify_string_in_file 'scan: field name "ThisHeaderFieldNameIsWa' "$actual_err" +verify_string_in_file 'exceeds 997' "$actual_err" +verify_string_in_file '??Format error (message 13) in component 2' "$actual_err" +rm -f "$actual_err" # check m_getfld() handling of long header field name without a colon msgfile="$MH_TEST_DIR/Mail/inbox/14" @@ -116,16 +128,16 @@ Test EOF cat >"$expected" <"$expected_err" <"$actual" 2>"$actual_err" -check "$expected" "$actual" -check "$expected_err" "$actual_err" +run_prog scan -width 13 last >"$actual" 2>"$actual_err" +check "$expected" "$actual" : m_getfld with long header, no colon output +check "$expected_err" "$actual_err" : m_getfld with long header, no colon error exit $failed