]> 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 1caf0399711fcd6b49b376094dec6eaa427ed8f3..c396957883f0892ca73dd7e91ad9a7fb2a611715 100755 (executable)
@@ -14,6 +14,21 @@ fi
 
 . "${srcdir}/test/post/test-post-common.sh"
 
+# Find MIME type string, using configured procs if available.
+MIMETYPEPROC=`mhparam mimetypeproc`
+MIMEENCODINGPROC=`mhparam mimeencodingproc`
+content_type_string() {
+  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
+    #### 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
+}
+
 # Customize test_post () for use with mhmail.
 # $1 is expected output file, provided by caller
 # $2 is mhmail switches, except for -body
@@ -53,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]
@@ -73,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\ --*) ;;
@@ -86,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"
@@ -101,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.
@@ -113,11 +133,8 @@ esac
 
 
 # check -nosend
+start_test "-nosend"
 # Not supported by compiled mhmail.
-#### TEMPORARY hack to diagnose failure on Solaris.
-echo before
-sh -x mhmail -nosend recipient@example.com -from sender1@localhost -body '' 2>&1
-echo after
 mhmail -nosend recipient@example.com -from sender1@localhost \
   -server 127.0.0.1 -port $localport -body '' >"$actual" 2>"$actual_err"
 
@@ -137,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
@@ -157,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
@@ -177,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
@@ -197,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
@@ -220,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
@@ -247,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
@@ -268,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.
@@ -281,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:
 
@@ -294,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
@@ -315,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
@@ -335,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
@@ -359,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
@@ -385,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
@@ -412,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
@@ -431,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
@@ -452,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
@@ -477,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
@@ -497,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
@@ -522,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
@@ -542,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
@@ -564,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
@@ -591,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
@@ -611,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
@@ -636,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
@@ -664,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
@@ -694,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
@@ -724,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
@@ -748,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
@@ -758,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
@@ -769,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
@@ -795,7 +842,7 @@ Content-Type: text/plain; charset="us-ascii"
 See how easy it is to add an attachment!
 
 ------- =_aaaaaaaaaa0
-Content-Type: text/plain; name="attachment.txt"; charset="us-ascii"
+Content-Type: `content_type_string ${srcdir}/test/mhmail/attachment.txt`
 Content-Description: attachment.txt
 Content-Disposition: attachment; filename="attachment.txt"
 
@@ -815,4 +862,5 @@ test_mhmail "$expected" \
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
+finish_test
 exit ${failed:-0}