Skip to contentSkip to conversation

mail: fix the bug of mail01

PATCH In review liubo 2 participants 2 messages Nov 16, 2009

lore
Share & tools
lore

liubo

author
#0 lore raw

PATCH 1/1 mail: fix the bug of mail01

In the testcase "mail01",

when mail is send to nosuchuser@domain
and mail is send to user@nosuchdomain,
mail program may return either "Returnedmail:"
or "UndeliveredMailReturned", regardless of
the existence of /etc/redhat-release.

So, we did a bit of changes to recognize both of
returned values.

This patch fixes the problem.

---
 testcases/commands/mail/mail_tests.sh |   65 ++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 34 deletions(-)
testcases/commands/mail/mail_tests.sh +31 -34
index 45bac93..024120f 100755
@@ -172,28 +172,27 @@ else
     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)
-    RC2=$(awk '/^>N/ {print match($9 $10 $11, "Maildeliveryfailed:")}' \
-        $LTPTMP/tst_mail.res)
-#####
-# Some mailers (e.g., Red Hat's sendmail) print different messages 
-#####
-if [ -f /etc/redhat-release ] 
-then 
-  [ -z "$RC2" -o "X$RC2" = "X0" ] && \
+##################################################################
+# In this testcase, mail will get "Returnedmail:", while mailx will
+# get "UndeliveredMailReturned:".
+# Either of mail and mailx may be linked to another.
+# For example,
+# /bin/mail -> /bin/mailx
+# or
+# /bin/mailx -> /bin/mail
+##################################################################
      RC2=$(awk '/^>N/ {print match($9 $10, "Returnedmail:")}' \
              $LTPTMP/tst_mail.res)
-else 
-  [ -z "$RC2" -o "X$RC2" = "X0" ] && \
-     RC2=$(awk '/^>N/ {print match($9 $10 $11, "UndeliveredMailReturned")}' \
+     RC3=$(awk '/^>N/ {print match($9 $10, "UndeliveredMail")}' \
              $LTPTMP/tst_mail.res)
 fi 
-    if [ -z "$RC1" -a -z "$RC2" ]
+    if [ -z "$RC1" -a -z "$RC2" -a -z "$RC3" ]
     then
         $LTPBIN/tst_res TFAIL $LTPTMP/tst_mail.res \
         "Test #2: No new mail for root. Reason:"
         TFAILCNT=$(( $TFAILCNT+1 ))
     else
-        if [ $RC1 -ne 0 -a $RC2 -ne 0 ]
+        if [ $RC1 -ne 0 -a $RC2 -ne 0 ] || [ $RC1 -ne 0 -a $RC3 -ne 0 ]
         then
             $LTPBIN/tst_resm TPASS \
                 "Test #2: Mailer-Deamon reported delivery failure"
@@ -203,7 +202,6 @@ fi
             TFAILCNT=$(( $TFAILCNT+1 ))
         fi
     fi
-fi
 else
     $LTPBIN/tst_resm TCONF "mail command not installed"
 fi    
@@ -242,29 +240,28 @@ else
     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)
-    RC2=$(awk '/^>N/ {print match($9 $10 $11, "Maildeliveryfailed:")}' \
-        $LTPTMP/tst_mail.res)
-#####
-# Some mailers (e.g., Red Hat's sendmail) print different messages 
-#####
-if [ -f /etc/redhat-release ] 
-then 
-   [ -z "$RC2" -o "X$RC2" = "X0" ] && \
-      RC2=$(awk '/^>N/ {print match($9 $10, "Returnedmail:")}' \
-              $LTPTMP/tst_mail.res)
-else 
-    [ -z "$RC2" -o "X$RC2" = "X0" ] && \
-        RC2=$(awk '/^>N/ {print match($9 $10 $11, "UndeliveredMailReturned")}' \
-                $LTPTMP/tst_mail.res)
-fi 
-    if [ -z "$RC1" -a -z "$RC2" ]
+##################################################################
+# In this testcase, mail will get "Returnedmail:", while mailx will
+# get "UndeliveredMailReturned:".
+# Either of mail and mailx may be linked to another.
+# For example,
+# /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)
+fi
+    if [ -z "$RC1" -a -z "$RC2" -a -z "$RC3" ]
     then
         $LTPBIN/tst_res TFAIL $LTPTMP/tst_mail.res \
-        "Test #3: No new mail for root. Reason:"
+        "Test #2: No new mail for root. Reason:"
         TFAILCNT=$(( $TFAILCNT+1 ))
     else
-        if [ $RC1 -ne 0 -a $RC2 -ne 0 ]
-        then
+        if [ $RC1 -ne 0 -a $RC2 -ne 0 ] || [ $RC1 -ne 0 -a $RC3 -ne 0 ]
+	then
             $LTPBIN/tst_resm TPASS \
                 "Test #3: Mailer-Deamon reported delivery failure"
         else
@@ -273,7 +270,7 @@ fi
             TFAILCNT=$(( $TFAILCNT+1 ))
         fi
     fi
-fi
+
 else
     $LTPBIN/tst_resm TCONF "mail command not installed"
 fi
Signature · 14 lines
1.6.2.2




------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw
Quoted 8 lines · liubo

In the testcase "mail01",

when mail is send to nosuchuser@domain and mail is send to user@nosuchdomain, mail program may return either "Returnedmail:" or "UndeliveredMailReturned", regardless of the existence of /etc/redhat-release.

Quoted 6 lines

So, we did a bit of changes to recognize both of returned values.

This patch fixes the problem.

Thanks. Done.

Regards--
Subrata

Quoted 106 lines
---
 testcases/commands/mail/mail_tests.sh |   65 ++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 34 deletions(-)
testcases/commands/mail/mail_tests.sh +30 -33
index 45bac93..024120f 100755
@@ -172,28 +172,27 @@ else
     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)
-    RC2=$(awk '/^>N/ {print match($9 $10 $11, "Maildeliveryfailed:")}' \
-        $LTPTMP/tst_mail.res)
-#####
-# Some mailers (e.g., Red Hat's sendmail) print different messages 
-#####
-if [ -f /etc/redhat-release ] 
-then 
-  [ -z "$RC2" -o "X$RC2" = "X0" ] && \
+##################################################################
+# In this testcase, mail will get "Returnedmail:", while mailx will
+# get "UndeliveredMailReturned:".
+# Either of mail and mailx may be linked to another.
+# For example,
+# /bin/mail -> /bin/mailx
+# or
+# /bin/mailx -> /bin/mail
+##################################################################
      RC2=$(awk '/^>N/ {print match($9 $10, "Returnedmail:")}' \
              $LTPTMP/tst_mail.res)
-else 
-  [ -z "$RC2" -o "X$RC2" = "X0" ] && \
-     RC2=$(awk '/^>N/ {print match($9 $10 $11, "UndeliveredMailReturned")}' \
+     RC3=$(awk '/^>N/ {print match($9 $10, "UndeliveredMail")}' \
              $LTPTMP/tst_mail.res)
 fi 
-    if [ -z "$RC1" -a -z "$RC2" ]
+    if [ -z "$RC1" -a -z "$RC2" -a -z "$RC3" ]
     then
         $LTPBIN/tst_res TFAIL $LTPTMP/tst_mail.res \
         "Test #2: No new mail for root. Reason:"
         TFAILCNT=$(( $TFAILCNT+1 ))
     else
-        if [ $RC1 -ne 0 -a $RC2 -ne 0 ]
+        if [ $RC1 -ne 0 -a $RC2 -ne 0 ] || [ $RC1 -ne 0 -a $RC3 -ne 0 ]
         then
             $LTPBIN/tst_resm TPASS \
                 "Test #2: Mailer-Deamon reported delivery failure"
@@ -203,7 +202,6 @@ fi
             TFAILCNT=$(( $TFAILCNT+1 ))
         fi
     fi
-fi
 else
     $LTPBIN/tst_resm TCONF "mail command not installed"
 fi    
@@ -242,29 +240,28 @@ else
     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)
-    RC2=$(awk '/^>N/ {print match($9 $10 $11, "Maildeliveryfailed:")}' \
-        $LTPTMP/tst_mail.res)
-#####
-# Some mailers (e.g., Red Hat's sendmail) print different messages 
-#####
-if [ -f /etc/redhat-release ] 
-then 
-   [ -z "$RC2" -o "X$RC2" = "X0" ] && \
-      RC2=$(awk '/^>N/ {print match($9 $10, "Returnedmail:")}' \
-              $LTPTMP/tst_mail.res)
-else 
-    [ -z "$RC2" -o "X$RC2" = "X0" ] && \
-        RC2=$(awk '/^>N/ {print match($9 $10 $11, "UndeliveredMailReturned")}' \
-                $LTPTMP/tst_mail.res)
-fi 
-    if [ -z "$RC1" -a -z "$RC2" ]
+##################################################################
+# In this testcase, mail will get "Returnedmail:", while mailx will
+# get "UndeliveredMailReturned:".
+# Either of mail and mailx may be linked to another.
+# For example,
+# /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)
+fi
+    if [ -z "$RC1" -a -z "$RC2" -a -z "$RC3" ]
     then
         $LTPBIN/tst_res TFAIL $LTPTMP/tst_mail.res \
-        "Test #3: No new mail for root. Reason:"
+        "Test #2: No new mail for root. Reason:"
         TFAILCNT=$(( $TFAILCNT+1 ))
     else
-        if [ $RC1 -ne 0 -a $RC2 -ne 0 ]
-        then
+        if [ $RC1 -ne 0 -a $RC2 -ne 0 ] || [ $RC1 -ne 0 -a $RC3 -ne 0 ]
+	then
             $LTPBIN/tst_resm TPASS \
                 "Test #3: Mailer-Deamon reported delivery failure"
         else

testcases/commands/mail/mail_tests.sh fi · line 276

Quoted 8 lines
testcases/commands/mail/mail_tests.sh +1 -1
@@ -273,7 +270,7 @@ fi
             TFAILCNT=$(( $TFAILCNT+1 ))
         fi
     fi
-fi
+
 else
     $LTPBIN/tst_resm TCONF "mail command not installed"
 fi

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list