Skip to contentSkip to conversation

mail_tests.sh: fix a version problem of Heirloom Mail

PATCH New Shi Weihua 1 participant 1 message Jan 25, 2010

lore
Share & tools
lore

Shi Weihua

author
#0 lore raw

PATCH 1/1 mail_tests.sh: fix a version problem of Heirloom Mail

In the previous mailx version, the command "echo "d" | mail -u root" will output like the following.
-----------------------------
Mail version 8.1 6/6/93. Type ? for help.
"/var/mail/root": 1 message 1 new

Quoted 1 line

N 1 MAILER-DAEMON@localh Mon Jan 25 09:11 63/2367 "Returned mail: see tr"

-----------------------------

Buy in Heirloom Mail, the command will output.
-----------------------------
Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/mail/root": 1 message 1 new

Quoted 1 line

N 1 Mail Delivery Subsys Mon Jan 25 14:16 67/2195 "Returned mail: see tr"

-----------------------------

"MAILER-DAEMON@localh" is been changed to "Mail Delivery Subsys". We should make mail_tests.sh to supporting Heirloom Mail.

---

testcases/commands/mail/mail_tests.sh +58 -13
@@ -55,6 +55,25 @@ else
     LTPBIN=$LTPROOT/testcases/bin
 fi
 
+isHeirloomMail=0
+checkHeirloomMail()
+{
+    isHeirloomMail=0
+
+    if [ $# -ne 1 ]; then
+        return
+    fi
+
+    if [ ! -f $1 ]; then
+	return
+    fi
+
+    cat $1 | grep "Heirloom"
+    if [ $? -eq 0 ]; then
+	isHeirloomMail=1
+    fi
+}
+
 RC=0
 export TCID=SETUP
 export TST_COUNT=1
@@ -170,8 +189,14 @@ else
     # but wait for the mail to arrive first, sleep 5s.
     sleep 5s
     echo "d" | mail -u root > $LTPTMP/tst_mail.res 2>&1
-    RC1=$(awk '/^>N/ {IGNORECASE=1; print match($3, "Mailer-Daemon")}' \
-	$LTPTMP/tst_mail.res)
+    checkHeirloomMail $LTPTMP/tst_mail.res
+    if [ $isHeirloomMail -eq 0 ]; then
+	RC1=$(awk '/^>N/ {IGNORECASE=1; print match($3, "Mailer-Daemon")}' \
+		$LTPTMP/tst_mail.res)
+    else
+	RC1=$(awk '/^>N/ {IGNORECASE=1; print match($3 $4 $5, "MailDeliverySubsys")}' \
+		$LTPTMP/tst_mail.res)
+    fi
 ##################################################################
 # In this testcase, mail will get "Returnedmail:", while mailx will
 # get "UndeliveredMailReturned:".
@@ -181,10 +206,17 @@ else
 # or
 # /bin/mailx -> /bin/mail
 ##################################################################
-     RC2=$(awk '/^>N/ {print match($9 $10, "Returnedmail:")}' \
-             $LTPTMP/tst_mail.res)
-     RC3=$(awk '/^>N/ {print match($9 $10, "UndeliveredMail")}' \
-             $LTPTMP/tst_mail.res)
+     if [ $isHeirloomMail -eq 0 ]; then
+	RC2=$(awk '/^>N/ {print match($9 $10, "Returnedmail:")}' \
+		$LTPTMP/tst_mail.res)
+	RC3=$(awk '/^>N/ {print match($9 $10, "UndeliveredMail")}' \
+		$LTPTMP/tst_mail.res)
+     else
+	RC2=$(awk '/^>N/ {print match($11 $12, "Returnedmail:")}' \
+		$LTPTMP/tst_mail.res)
+	RC3=$(awk '/^>N/ {print match($11 $12, "UndeliveredMail")}' \
+		$LTPTMP/tst_mail.res)
+     fi
 fi 
     if [ -z "$RC1" -a -z "$RC2" -a -z "$RC3" ]
     then
@@ -238,8 +270,14 @@ else
     # but wait for the mail to arrive first, sleep 5s.
     sleep 5s
     echo "d" | mail -u root > $LTPTMP/tst_mail.res 2>&1
-    RC1=$(awk '/^>N/ {IGNORECASE=1; print match($3, "Mailer-Daemon")}' \
-	$LTPTMP/tst_mail.res)
+    checkHeirloomMail $LTPTMP/tst_mail.res
+    if [ $isHeirloomMail -eq 0 ]; then
+	RC1=$(awk '/^>N/ {IGNORECASE=1; print match($3, "Mailer-Daemon")}' \
+		$LTPTMP/tst_mail.res)
+    else
+	RC1=$(awk '/^>N/ {IGNORECASE=1; print match($3 $4 $5, "MailDeliverySubsys")}' \
+		$LTPTMP/tst_mail.res)
+    fi
 ##################################################################
 # In this testcase, mail will get "Returnedmail:", while mailx will
 # get "UndeliveredMailReturned:".
@@ -248,11 +286,18 @@ else
 # /bin/mail -> /bin/mailx
 # or
 # /bin/mailx -> /bin/mail
-##################################################################
-     RC2=$(awk '/^>N/ {print match($9 $10, "Returnedmail:")}' \
-             $LTPTMP/tst_mail.res)
-     RC3=$(awk '/^>N/ {print match($9 $10, "UndeliveredMail")}' \
-             $LTPTMP/tst_mail.res)
+#################################################################
+     if [ $isHeirloomMail -eq 0 ]; then
+	RC2=$(awk '/^>N/ {print match($9 $10, "Returnedmail:")}' \
+		$LTPTMP/tst_mail.res)
+	RC3=$(awk '/^>N/ {print match($9 $10, "UndeliveredMail")}' \
+		$LTPTMP/tst_mail.res)
+     else
+	RC2=$(awk '/^>N/ {print match($11 $12, "Returnedmail:")}' \
+		$LTPTMP/tst_mail.res)
+	RC3=$(awk '/^>N/ {print match($11 $12, "UndeliveredMail")}' \
+		$LTPTMP/tst_mail.res)
+     fi
 fi
     if [ -z "$RC1" -a -z "$RC2" -a -z "$RC3" ]
     then

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list