X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/6106441685a38400d9aa94ccb7218218102f941c..a616a7953d87c3c51afcc8e693c48c37ec000edf:/test/bad-input/test-header diff --git a/test/bad-input/test-header b/test/bad-input/test-header index 35d680a6..0e210dba 100755 --- a/test/bad-input/test-header +++ b/test/bad-input/test-header @@ -1,34 +1,27 @@ #!/bin/sh ###################################################### # -# Test bogus headers (no blank line before body). +# Test bogus headers (no blank line before body, etc.) # ###################################################### -if [ -z "${MH_TEST_COMMON}" ]; then - echo "MH_TEST_COMMON not set; try running via 'make check'" +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname "$0"`/../.. + MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR fi -. ${MH_TEST_COMMON} +. "$MH_OBJ_DIR/test/common.sh" setup_test -# TODO: Move to a common file tests can source; need more framework... -failed=0 -check() { - diff -u $expected $actual - if [ $? -ne 0 ]; then - failed=$((failed + 1)) - fi -} - -expected=$MH_TEST_DIR/$$.expected -actual=$MH_TEST_DIR/$$.actual +expected="$MH_TEST_DIR/$$.expected" +expected_err="$MH_TEST_DIR/$$.expected_err" +actual="$MH_TEST_DIR/$$.actual" +actual_err="$MH_TEST_DIR/$$.actual_err" # Write message with bogus header field (missing blank line, really). -msgfile=$(mhpath new) -msgnum=$(basename $msgfile) -cat > $msgfile <"$msgfile" < $expected <"$expected" < $actual 2>&1 -check +scan -width 80 last > "$actual" 2>&1 +check "$expected" "$actual" # check show (mhl) -cat > $expected <"$expected" < $actual 2>&1 -check +show last > "$actual" 2>&1 +check "$expected" "$actual" # check mhshow -cat > $expected <"$expected" < $actual 2>&1 -check +mhshow -nopause last > "$actual" 2>&1 +check "$expected" "$actual" + +# 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" + +# check m_getfld() handling of excessively long header field name +msgfile="$MH_TEST_DIR/Mail/inbox/13" +cat >"$msgfile" <"$expected" <"$expected_err" <"$actual" 2>"$actual_err" +check "$expected" "$actual" +check "$expected_err" "$actual_err" + +# check m_getfld() handling of long header field name without a colon +msgfile="$MH_TEST_DIR/Mail/inbox/14" +cat >"$msgfile" <"$expected" <"$expected_err" <"$actual" 2>"$actual_err" +check "$expected" "$actual" +check "$expected_err" "$actual_err" + exit $failed