]> diplodocus.org Git - nmh/blobdiff - test/mhmail/test-mhmail
Tell make that uip/mhical.c depends on sbr/icalparse.h
[nmh] / test / mhmail / test-mhmail
index a6a3917633577fbf8cff0bd96a333a56016a9743..c396957883f0892ca73dd7e91ad9a7fb2a611715 100755 (executable)
@@ -14,20 +14,18 @@ fi
 
 . "${srcdir}/test/post/test-post-common.sh"
 
-# Find MIME type string, using mimetypeproc if configured with it.
+# Find MIME type string, using configured procs if available.
 MIMETYPEPROC=`mhparam mimetypeproc`
-file -i * # temporary, for debugging on OpenBSD
+MIMEENCODINGPROC=`mhparam mimeencodingproc`
 content_type_string() {
-echo $1
-echo $MIMETYPEPROC; $MIMETYPEPROC $1 # temporary, for debugging on OpenBSD
-  if test -z "$MIMETYPEPROC"; then
+  if test -z "$MIMETYPEPROC"  -o  -z "$MIMEENCODINGPROC"; then
+    #### This should be the order of name and charset.
     echo "text/plain; name=\"`basename $1`\"; charset=\"us-ascii\""
   else
-    # 1) Excise leading filename followed by : and any whitespace.
-    # 2) Wrap charset value in double quotes.  Assume that it isn't already.
-    printf "%s %s%s" \
-      `$MIMETYPEPROC $1 | sed -e 's/.*: *//' -e 's/\(charset=\)\(.*\)/\1"\2"/'`\
-      "; name=\"`basename $1`\""
+    #### Excise any leading filename followed by : and whitespace.
+    printf '%s; charset="%s"; name="%s"' \
+      `$MIMETYPEPROC $1 | sed -e 's/.*: *//'` \
+      `$MIMEENCODINGPROC $1 | sed -e 's/.*: *//'` `basename $1`
   fi
 }
 
@@ -70,6 +68,7 @@ actual_err=$MH_TEST_DIR/test-mhmail$$.actual_err
 
 
 # check -help
+start_test "-help"
 # Verified behavior consistent with compiled sendmail.
 cat >$expected <<EOF
 Usage: mhmail [-t(o)] addrs ... [switches]
@@ -90,11 +89,13 @@ Usage: mhmail [-t(o)] addrs ... [switches]
   mhmail with no arguments is equivalent to inc
 EOF
 
-mhmail -help >$actual 2>&1
-check $expected $actual
+#### Skip nmh intro text.
+mhmail -help 2>&1 | sed '/^$/,$d' >"$actual"
+check "$expected" "$actual"
 
 
 # check -version
+start_test "-version"
 # Verified same behavior as compiled mhmail.
 case `mhmail -v` in
   mhmail\ --*) ;;
@@ -103,6 +104,7 @@ case `mhmail -v` in
 esac
 
 # check for missing argument to switches that require them
+start_test "for missing argument to switches that require them"
 for switch in attach body cc from headerfield subject to; do
   run_test "mhmail recipient -$switch" \
            "mhmail: missing argument to -$switch"
@@ -118,6 +120,7 @@ done
 
 
 # check with no switches
+start_test "with no switches"
 # That will just run inc, which we don't want to do anything,
 # so tell inc to just display its version.
 # Verified same behavior as compiled mhmail.
@@ -130,6 +133,7 @@ esac
 
 
 # check -nosend
+start_test "-nosend"
 # Not supported by compiled mhmail.
 mhmail -nosend recipient@example.com -from sender1@localhost \
   -server 127.0.0.1 -port $localport -body '' >"$actual" 2>"$actual_err"
@@ -150,6 +154,7 @@ check "$expected_err" "$actual_err"
 
 
 # check -send
+start_test "-send"
 # Not supported by compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -170,6 +175,7 @@ test_mhmail "$expected" "-from sender2@localhost -nosend -send" '|' message
 
 
 # check -from
+start_test "-from"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -190,6 +196,7 @@ test_mhmail "$expected" "-from sender3@localhost" '|' message
 
 
 # check -from and -body
+start_test "-from and -body"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -210,6 +217,7 @@ test_mhmail "$expected" "-from sender4@localhost" -b body
 
 
 # check -from and -cc
+start_test "-from and -cc"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -233,6 +241,7 @@ test_mhmail "$expected" \
 
 
 # check -from and multiple -cc addresses
+start_test "-from and multiple -cc addresses"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -260,6 +269,7 @@ test_mhmail "$expected" \
 
 
 # check -from and -subject
+start_test "-from and -subject"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -281,6 +291,7 @@ test_mhmail "$expected" '-from sender7@localhost -subject Test' '|' message
 
 
 # check -from and -profile
+start_test "-from and -profile"
 # Show that -profile causes mhmail to 1) read the profile and
 # 2) use send(1) by added a send switch to the profile and
 # verifying that it gets used.
@@ -294,6 +305,8 @@ RCPT TO:<recipient@example.com>
 DATA
 To: recipient@example.com
 From: sender8@localhost
+MIME-Version: 1.0
+Content-Type: text/plain; charset="us-ascii"
 Date:
 Message-ID:
 
@@ -307,6 +320,7 @@ test_mhmail "$expected" '-from sender8@localhost -profile' '|' message
 
 
 # check repeated -from and -subject switches
+start_test "repeated -from and -subject switches"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -328,6 +342,7 @@ test_mhmail "$expected" '-from sender9@localhost -from sender9@localhost '\
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 # check repeated -body switches
+start_test "repeated -body switches"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -348,6 +363,7 @@ test_mhmail "$expected" "-from sender10@localhost -body body1" -b body2
 
 
 # check multiple -cc switches
+start_test "multiple -cc switches"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -372,6 +388,7 @@ test_mhmail "$expected" \
 
 
 # check separated -cc arguments
+start_test "separated -cc arguments"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -398,6 +415,7 @@ test_mhmail "$expected" \
 
 
 # check -cc switch followed by -to switch
+start_test "-cc switch followed by -to switch"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -425,6 +443,7 @@ test_mhmail "$expected" \
 
 
 # check with no newline on stdin
+start_test "with no newline on stdin"
 # Shows different behavior than compiled mhmail, which was silent in this case.
 cat > "$expected" <<EOF
 EOF
@@ -444,6 +463,7 @@ check "$expected_err" "$actual_err"
 
 
 # check with one newline on stdin
+start_test "with one newline on stdin"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -465,6 +485,7 @@ test_mhmail "$expected" '-from sender14@localhost' '|' '
 
 
 # check with multiple newlines on stdin
+start_test "with multiple newlines on stdin"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -490,6 +511,7 @@ test_mhmail "$expected" '-from sender15@localhost' '|' '
 
 
 # check with text and no trailing newline on stdin
+start_test "with text and no trailing newline on stdin"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -510,6 +532,7 @@ test_mhmail "$expected" '-from sender16@localhost' '|' 'no newline in input'
 
 
 # check with text and multiple trailing blank lines on stdin
+start_test "with text and multiple trailing blank lines on stdin"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -535,6 +558,7 @@ test_mhmail "$expected" '-from sender17@localhost' '|' "here's some text
 
 
 # check with no newline to -body
+start_test "with no newline to -body"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -555,6 +579,7 @@ test_mhmail "$expected" '-from sender18@localhost' -b ''
 
 
 # check with one newline to -body
+start_test "with one newline to -body"
 # Shows different behavior than compiled mhmail, which suppressed the newline.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -577,6 +602,7 @@ test_mhmail "$expected" '-from sender19@localhost' -b '
 
 
 # check with multiple newlines to -body
+start_test "with multiple newlines to -body"
 # Shows different behavior than compiled mhmail, which suppressed one
 #   of the newlines.
 cat > "$expected" <<EOF
@@ -604,6 +630,7 @@ test_mhmail "$expected" '-from sender20@localhost' -b '
 
 
 # check with text and no trailing newline to -body
+start_test "with text and no trailing newline to -body"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -624,6 +651,7 @@ test_mhmail "$expected" '-from sender21@localhost' -b 'no newline in input'
 
 
 # check with text and multiple trailing blank lines to -body
+start_test "with text and multiple trailing blank lines to -body"
 # Shows different behavior than compiled mhmail, which suppressed one
 #   of the newlines.
 cat > "$expected" <<EOF
@@ -649,6 +677,7 @@ test_mhmail "$expected" '-from sender22@localhost' -b "here's some text
 
 
 # check -resent
+start_test "-resent"
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -677,6 +706,7 @@ please resend this message, 1'
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 # check -resent -profile, using stdin
+start_test "-resent -profile, using stdin"
 # Not supported by compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -707,6 +737,7 @@ please resend this message, 2'
 
 
 # check -resent -profile, using -b
+start_test "-resent -profile, using -b"
 # Not supported by compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -737,6 +768,7 @@ please resend this message, 3'
 
 
 # check -headerfield.
+start_test "-headerfield."
 # Not supported by compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -761,6 +793,7 @@ test_mhmail "$expected" \
 
 
 # check multiple -headerfields.
+start_test "multiple -headerfields."
 # Not supported by compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -771,7 +804,7 @@ To: recipient@example.com
 From: sender27@example.com
 MIME-Version: 1.0
 Content-Type: text/plain;charset=utf-8
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
 Date:
 
 with added header fields
@@ -782,13 +815,14 @@ EOF
 test_mhmail "$expected" \
   "-from sender27@example.com -headerfield MIME-Version:1.0 \
 -headerfield Content-Type:text/plain;charset=utf-8 \
--headerfield Content-Transfer-Encoding:8bit" \
+-headerfield Content-Transfer-Encoding:7bit" \
   -b 'with added header fields'
 
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
 # check -attach
+start_test "-attach"
 # Not supported by compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -828,4 +862,5 @@ test_mhmail "$expected" \
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
+finish_test
 exit ${failed:-0}