subrata_modak | c864960 | 2008-08-27 11:29:55 +0000 | [diff] [blame] | 1 | #!/bin/sh |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 2 | ################################################################################ |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 3 | ## ## |
| 4 | ## Copyright (c) International Business Machines Corp., 2001 ## |
| 5 | ## ## |
| 6 | ## This program is free software; you can redistribute it and#or modify ## |
| 7 | ## it under the terms of the GNU General Public License as published by ## |
| 8 | ## the Free Software Foundation; either version 2 of the License, or ## |
| 9 | ## (at your option) any later version. ## |
| 10 | ## ## |
| 11 | ## This program is distributed in the hope that it will be useful, but ## |
| 12 | ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## |
| 13 | ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## |
| 14 | ## for more details. ## |
| 15 | ## ## |
| 16 | ## You should have received a copy of the GNU General Public License ## |
| 17 | ## along with this program; if not, write to the Free Software ## |
| 18 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## |
| 19 | ## ## |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 20 | ################################################################################ |
| 21 | # |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 22 | # File : mail_tests.sh |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 23 | # |
iyermanoj | 5b00680 | 2003-01-10 17:17:31 +0000 | [diff] [blame] | 24 | # Description: Tests basic functions of mail system. The aim of the test is to |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 25 | # make sure that certain basic functionality of mail is expected |
| 26 | # to work as per man page. There are 4 - 5 operations that are |
| 27 | # done on a regular basis wrt mail. ie. |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 28 | # |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 29 | # mail sent to an user@domain - received by that user@domain |
| 30 | # mail is sent to nosuchuser@domain - mail delivery failure |
| 31 | # mail is sent to user@nosuchdomain - mail delivery failure |
| 32 | # mail to user1@domain and cc user2@domain - mail rec by both |
| 33 | # mail to user1@domain and bcc user2@domain - mail rec by both |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 34 | # |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 35 | # Author: Manoj Iyer, manjo@mail.utexas.edu |
| 36 | # |
| 37 | # History: Jan 07 2003 - Created - Manoj Iyer. |
| 38 | # Jan 09 2003 - Added Test #2 #3 #4 and #5. |
| 39 | # Jan 10 2002 - Fixed various bugs I had introduced in the test. |
| 40 | # - Added SETUP and CLEANUP sections |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 41 | # |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 42 | |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 43 | export TST_TOTAL=5 |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 44 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 45 | LTPTMP=${TMPBASE:-/tmp} |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 46 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 47 | if [ -z "$LTPBIN" -a -z "$LTPROOT" ]; then |
| 48 | LTPBIN=./ |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 49 | else |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 50 | LTPBIN=$LTPROOT/testcases/bin |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 51 | fi |
| 52 | |
Rishikesh K Rajak | 77312d8 | 2010-02-17 18:45:56 +0530 | [diff] [blame] | 53 | isHeirloomMail=0 |
| 54 | checkHeirloomMail() |
| 55 | { |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 56 | if [ $# -eq 1 -a -f $1 ] && grep "Heirloom" $1; then |
| 57 | isHeirloomMail=1 |
| 58 | fi |
Rishikesh K Rajak | 77312d8 | 2010-02-17 18:45:56 +0530 | [diff] [blame] | 59 | } |
| 60 | |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 61 | RC=0 |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 62 | export TCID=mail_tests::setup |
iyermanoj | 5b00680 | 2003-01-10 17:17:31 +0000 | [diff] [blame] | 63 | export TST_COUNT=1 |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 64 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 65 | if ! type mail > /dev/null 2>&1; then |
| 66 | tst_resm TCONF "mail isn't installed" |
| 67 | exit 0 |
| 68 | fi |
| 69 | |
| 70 | cat > $LTPTMP/tst_mail.in <<EOF |
| 71 | This is a test email. |
| 72 | EOF |
| 73 | |
| 74 | if [ $? -ne 0 ] ; then |
| 75 | tst_resm TBROK "couldn't create a temporary message" |
subrata_modak | e764b28 | 2009-08-23 06:03:44 +0000 | [diff] [blame] | 76 | fi |
| 77 | |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 78 | # check if the user mail_test exists on this system. |
| 79 | # if not add that user mail_test, will removed before exiting test. |
Rishikesh K Rajak | 2a276cf | 2010-04-15 12:06:23 +0530 | [diff] [blame^] | 80 | id -u mail_test >/dev/null 2>&1 |
| 81 | if [ $? -ne 0 ] ; then |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 82 | tst_resm TINFO "INIT: Adding temporary user mail_test" |
| 83 | useradd -m -s /sbin/nologin mail_test > $LTPTMP/tst_mail.out 2>&1 |
| 84 | if [ $? -ne 0 ]; then |
| 85 | tst_brk TBROK $LTPTMP/tst_mail.out NULL \ |
| 86 | "Test INIT: Failed adding user mail_test. Reason:" |
| 87 | exit 1 |
| 88 | fi |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 89 | fi |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 90 | |
| 91 | trap |
| 92 | |
| 93 | tst_resm TINFO "INIT: Removing all mails for mail_test and root" |
subrata_modak | 39552a0 | 2008-10-21 06:54:15 +0000 | [diff] [blame] | 94 | echo "d*" | mail -u mail_test > /dev/null 2>&1 |
| 95 | echo "d*" | mail -u root > /dev/null 2>&1 |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 96 | |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 97 | # Set return code RC variable to 0, it will be set with a non-zero return code |
| 98 | # in case of error. Set TFAILCNT to 0, increment if there occures a failure. |
| 99 | |
| 100 | TFAILCNT=0 |
| 101 | RC=0 |
| 102 | RC1=0 |
| 103 | RC2=0 |
| 104 | |
| 105 | # Test #1 |
| 106 | # Test that mail user@domain will send a mail to that user at that domain. |
| 107 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 108 | export TCID=mail_tests::mail01 |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 109 | export TST_COUNT=1 |
| 110 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 111 | tst_resm TINFO "Test #1: mail root@localhost will send mail to root" |
| 112 | tst_resm TINFO "Test #1: user on local machine." |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 113 | |
| 114 | mail -s "Test" root@localhost < $LTPTMP/tst_mail.in \ |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 115 | > $LTPTMP/tst_mail.out 2>&1 |
| 116 | if [ $? -ne 0 ]; then |
| 117 | tst_res TFAIL $LTPTMP/tst_mail.out \ |
| 118 | "Test #1: mail command failed. Reason: " |
| 119 | : $(( TFAILCNT += 1 )) |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 120 | else |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 121 | # check if root received a new email with Test as subject |
| 122 | # but wait for the mail to arrive. |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 123 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 124 | sleep 10 |
| 125 | echo "d" | mail -u root > $LTPTMP/tst_mail.res 2>&1 |
| 126 | mailsub=$(awk '/^>N/ {print match($9, "Test")}' $LTPTMP/tst_mail.res) |
| 127 | if [ "x$mailsub" != x0 ]; then |
| 128 | tst_resm TPASS \ |
| 129 | "Test #1: Mail was sent to root & was received" |
| 130 | else |
| 131 | tst_res TFAIL $LTPTMP/tst_mail.res \ |
| 132 | "Test #1: Mail sent to root, but was not received" |
| 133 | : $(( TFAILCNT += 1 )) |
| 134 | fi |
| 135 | |
| 136 | fi |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 137 | |
| 138 | # Test #2 |
| 139 | # Test that mail user@bad-domain will result in a warning from the mailer |
robbiew | 7829e1e | 2004-03-23 16:11:21 +0000 | [diff] [blame] | 140 | # daemon that the domain does not exist. |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 141 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 142 | export TCID=mail_tests::mail02 |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 143 | export TST_COUNT=2 |
| 144 | RC=0 |
| 145 | RC1=0 |
| 146 | RC2=0 |
| 147 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 148 | tst_resm TINFO "Test #2: mail user@bad-domain will result in failure" |
| 149 | tst_resm TINFO "Test #2: to deliver the mail. Mailer daemon should" |
| 150 | tst_resm TINFO "Test #2: report this failure." |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 151 | |
robbiew | 9f219da | 2003-12-09 17:58:03 +0000 | [diff] [blame] | 152 | # Don't use underscores in domain names (they're illegal)... |
| 153 | mail -s "Test" root@thisdomaindoesnotexist < $LTPTMP/tst_mail.in \ |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 154 | > $LTPTMP/tst_mail.out 2>&1 |
| 155 | if [ $? -ne 0 ]; then |
| 156 | tst_res TFAIL $LTPTMP/tst_mail.out \ |
| 157 | "Test #2: mail command failed. Reason:" |
| 158 | : $(( TFAILCNT += 1 )) |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 159 | else |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 160 | # check if Mailer-Deamon reported any delivery failure. |
| 161 | # but wait for the mail to arrive first, sleep 5. |
| 162 | sleep 5 |
| 163 | echo "d" | mail -u root > $LTPTMP/tst_mail.res 2>&1 |
| 164 | checkHeirloomMail $LTPTMP/tst_mail.res |
| 165 | if [ $isHeirloomMail -eq 0 ]; then |
| 166 | RC1=$(awk '/^>N/ {IGNORECASE=1; print match($3, "Mailer-Daemon")}' \ |
| 167 | $LTPTMP/tst_mail.res) |
| 168 | else |
| 169 | RC1=$(awk '/^>N/ {IGNORECASE=1; print match($3 $4 $5, "MailDeliverySubsys")}' \ |
| 170 | $LTPTMP/tst_mail.res) |
| 171 | fi |
| 172 | |
| 173 | ################################################################## |
| 174 | # In this testcase, mail will get "Returnedmail:", while mailx will |
| 175 | # get "UndeliveredMailReturned:". |
| 176 | # Either of mail and mailx may be linked to another. |
| 177 | # For example, |
| 178 | # /bin/mail -> /bin/mailx |
| 179 | # or |
| 180 | # /bin/mailx -> /bin/mail |
| 181 | ################################################################## |
| 182 | if [ $isHeirloomMail -eq 0 ]; then |
| 183 | RC2=$(awk '/^>N/ {print match($9 $10, "Returnedmail:")}' \ |
| 184 | $LTPTMP/tst_mail.res) |
| 185 | RC3=$(awk '/^>N/ {print match($9 $10, "UndeliveredMail")}' \ |
| 186 | $LTPTMP/tst_mail.res) |
| 187 | else |
| 188 | RC2=$(awk '/^>N/ {print match($11 $12, "Returnedmail:")}' \ |
| 189 | $LTPTMP/tst_mail.res) |
| 190 | RC3=$(awk '/^>N/ {print match($11 $12, "UndeliveredMail")}' \ |
| 191 | $LTPTMP/tst_mail.res) |
| 192 | fi |
| 193 | if [ -z "$RC1" -a -z "$RC2" -a -z "$RC3" ]; then |
| 194 | tst_res TFAIL $LTPTMP/tst_mail.res \ |
| 195 | "Test #2: No new mail for root. Reason:" |
| 196 | : $(( TFAILCNT += 1 )) |
| 197 | else |
| 198 | |
| 199 | if [ $RC1 -ne 0 -a $RC2 -ne 0 ] || [ $RC1 -ne 0 -a $RC3 -ne 0 ]; then |
| 200 | tst_resm TPASS \ |
| 201 | "Test #2: Mailer-Deamon reported delivery failure" |
| 202 | else |
| 203 | tst_res TFAIL $LTPTMP/tst_mail.res \ |
| 204 | "Test #2: Mailer-Deamon failed to report delivery failure. Reason:" |
| 205 | : $(( TFAILCNT += 1 )) |
| 206 | fi |
| 207 | |
| 208 | fi |
| 209 | |
| 210 | |
| 211 | fi |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 212 | |
| 213 | # Test #3 |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 214 | # Test that mail non_existent_user@localhost will result in delivery failure. |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 215 | # Mailer-Deamon will report this failure. |
| 216 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 217 | export TCID=mail_tests::mail03 |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 218 | export TST_COUNT=3 |
| 219 | RC=0 |
| 220 | RC1=0 |
| 221 | RC2=0 |
| 222 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 223 | tst_resm TINFO "Test #3: mail non_existent_user@localhost will fail" |
| 224 | tst_resm TINFO "Test #3: to deliver the mail. Mailer daemon should" |
| 225 | tst_resm TINFO "Test #3: report this failure." |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 226 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 227 | mail -s "Test" non_existent_user@localhost < $LTPTMP/tst_mail.in > \ |
| 228 | $LTPTMP/tst_mail.out 2>&1 |
| 229 | if [ $? -ne 0 ]; then |
| 230 | tst_res TFAIL $LTPTMP/tst_mail.out \ |
| 231 | "Test #3: mail command failed. Reason: " |
| 232 | : $(( TFAILCNT += 1 )) |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 233 | else |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 234 | # check if Mailer-Deamon reported any delivery failure. |
| 235 | # but wait for the mail to arrive first, sleep 5. |
| 236 | sleep 5 |
| 237 | echo "d" | mail -u root > $LTPTMP/tst_mail.res 2>&1 |
| 238 | checkHeirloomMail $LTPTMP/tst_mail.res |
| 239 | if [ $isHeirloomMail -eq 0 ]; then |
| 240 | RC1=$(awk '/^>N/ {IGNORECASE=1; print match($3, "Mailer-Daemon")}' \ |
| 241 | $LTPTMP/tst_mail.res) |
| 242 | else |
| 243 | RC1=$(awk '/^>N/ {IGNORECASE=1; print match($3 $4 $5, "MailDeliverySubsys")}' \ |
| 244 | $LTPTMP/tst_mail.res) |
| 245 | fi |
| 246 | ################################################################## |
| 247 | # In this testcase, mail will get "Returnedmail:", while mailx will |
| 248 | # get "UndeliveredMailReturned:". |
| 249 | # Either of mail and mailx may be linked to another. |
| 250 | # For example, |
| 251 | # /bin/mail -> /bin/mailx |
| 252 | # or |
| 253 | # /bin/mailx -> /bin/mail |
| 254 | ################################################################# |
| 255 | if [ $isHeirloomMail -eq 0 ]; then |
| 256 | RC2=$(awk '/^>N/ {print match($9 $10, "Returnedmail:")}' \ |
| 257 | $LTPTMP/tst_mail.res) |
| 258 | RC3=$(awk '/^>N/ {print match($9 $10, "UndeliveredMail")}' \ |
| 259 | $LTPTMP/tst_mail.res) |
| 260 | else |
| 261 | RC2=$(awk '/^>N/ {print match($11 $12, "Returnedmail:")}' \ |
| 262 | $LTPTMP/tst_mail.res) |
| 263 | RC3=$(awk '/^>N/ {print match($11 $12, "UndeliveredMail")}' \ |
| 264 | $LTPTMP/tst_mail.res) |
| 265 | fi |
subrata_modak | 8eb5a85 | 2009-11-16 13:25:48 +0000 | [diff] [blame] | 266 | fi |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 267 | if [ -z "$RC1" -a -z "$RC2" -a -z "$RC3" ]; then |
| 268 | |
| 269 | tst_res TFAIL $LTPTMP/tst_mail.res \ |
| 270 | "Test #3: No new mail for root. Reason:" |
| 271 | : $(( TFAILCNT += 1 )) |
subrata_modak | 8eb5a85 | 2009-11-16 13:25:48 +0000 | [diff] [blame] | 272 | |
subrata_modak | e764b28 | 2009-08-23 06:03:44 +0000 | [diff] [blame] | 273 | else |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 274 | if [ $RC1 -ne 0 -a $RC2 -ne 0 ] || [ $RC1 -ne 0 -a $RC3 -ne 0 ]; then |
| 275 | tst_resm TPASS \ |
| 276 | "Test #3: Mailer-Daemon reported delivery failure" |
| 277 | else |
| 278 | tst_res TFAIL $LTPTMP/tst_mail.res \ |
| 279 | "Test #3: Mailer-Daemon failed to report delivery failure. Reason:" |
| 280 | : $(( TFAILCNT += 1 )) |
| 281 | fi |
subrata_modak | e764b28 | 2009-08-23 06:03:44 +0000 | [diff] [blame] | 282 | fi |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 283 | |
| 284 | # Test #4 |
| 285 | # Test that mail -c user@domain option will carbon copy that user. |
| 286 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 287 | export TCID=mail_tests::mail04 |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 288 | export TST_COUNT=4 |
| 289 | RC=0 |
| 290 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 291 | tst_resm TINFO "Test #4: Test that mail -c user@domain will" |
| 292 | tst_resm TINFO "Test #4: carbon copy user@domain" |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 293 | # send mail to root and carbon copy mail_test |
| 294 | mail -s "Test" root@localhost -c mail_test@localhost < \ |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 295 | $LTPTMP/tst_mail.in > $LTPTMP/tst_mail.out 2>&1 |
| 296 | if [ $? -ne 0 ]; then |
| 297 | tst_res TFAIL $LTPTMP/tst_mail.out \ |
| 298 | "Test #4: mail command failed. Reason:" |
| 299 | : $(( TFAILCNT += 1 )) |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 300 | else |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 301 | # Check if mail_test received the mail and |
| 302 | # also if root received the main copy of the email. |
| 303 | sleep 5 |
| 304 | echo "d" | mail -u root > $LTPTMP/tst_mail.res 2>&1 |
| 305 | RC1=$(awk '/^>N/ {print match($9, "Test")}' $LTPTMP/tst_mail.res) |
| 306 | echo "d" | mail -u mail_test > $LTPTMP/tst_mail.res 2>&1 |
| 307 | RC2=$(awk '/^>N/ {print match($9, "Test")}' $LTPTMP/tst_mail.res) |
| 308 | |
| 309 | if [ "x$RC1" != x0 -a "x$RC2" != x0 ]; then |
| 310 | tst_resm TPASS \ |
| 311 | "Test #4: Mail was carbon copied to user mail_test" |
| 312 | else |
| 313 | tst_res TFAIL $LTPTMP/tst_mail.res \ |
| 314 | "Test #4: mail failed to carbon copy user mail_test. Reason:" |
| 315 | : $(( TFAILCNT += 1 )) |
| 316 | fi |
| 317 | |
subrata_modak | e764b28 | 2009-08-23 06:03:44 +0000 | [diff] [blame] | 318 | fi |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 319 | |
| 320 | # Test #5 |
| 321 | # Test that mail -b user@domain option will blind carbon copy that user. |
| 322 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 323 | export TCID=mail_tests::mail05 |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 324 | export TST_COUNT=5 |
| 325 | RC=0 |
| 326 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 327 | tst_resm TINFO "Test #5: Test that mail -b user@domain will" |
| 328 | tst_resm TINFO "Test #5: blind carbon copy user@domain" |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 329 | |
| 330 | # send mail to root and carbon copy mail_test |
Rishikesh K Rajak | 2a276cf | 2010-04-15 12:06:23 +0530 | [diff] [blame^] | 331 | mail -s "Test" root@localhost -b mail_test@localhost < \ |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 332 | $LTPTMP/tst_mail.in > $LTPTMP/tst_mail.out 2>&1 |
| 333 | if [ $? -ne 0 ]; then |
| 334 | tst_res TFAIL $LTPTMP/tst_mail.out \ |
| 335 | "Test #5: mail command failed. Reason:" |
| 336 | : $(( TFAILCNT += 1 )) |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 337 | else |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 338 | # Check if mail_test received the mail and |
| 339 | # also if root received the main copy of the email. |
| 340 | sleep 5 |
| 341 | echo "d" | mail -u root > $LTPTMP/tst_mail.res 2>&1 |
| 342 | RC1=$(awk '/^>N/ {print match($9, "Test")}' $LTPTMP/tst_mail.res) |
| 343 | echo "d" | mail -u mail_test > $LTPTMP/tst_mail.res 2>&1 |
| 344 | RC2=$(awk '/^>N/ {print match($9, "Test")}' $LTPTMP/tst_mail.res) |
| 345 | |
| 346 | if [ "x$RC1" != x0 -a "x$RC2" != x0 ]; then |
| 347 | tst_resm TPASS \ |
Rishikesh K Rajak | 2a276cf | 2010-04-15 12:06:23 +0530 | [diff] [blame^] | 348 | "Test #5: Mail was blind carbon copied to user mail_test" |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 349 | else |
| 350 | tst_res TFAIL $LTPTMP/tst_mail.res \ |
Rishikesh K Rajak | 2a276cf | 2010-04-15 12:06:23 +0530 | [diff] [blame^] | 351 | "Test #5: mail failed to blind carbon copy user mail_test. Reason:" |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 352 | : $(( TFAILCNT += 1 )) |
| 353 | fi |
| 354 | |
subrata_modak | e764b28 | 2009-08-23 06:03:44 +0000 | [diff] [blame] | 355 | fi |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 356 | |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 357 | #CLEANUP & EXIT |
| 358 | # remove all the temporary files created by this test. |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 359 | export TCID=mail_tests::cleanup |
iyermanoj | 5b00680 | 2003-01-10 17:17:31 +0000 | [diff] [blame] | 360 | export TST_COUNT=1 |
| 361 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 362 | tst_resm TINFO "Test CLEAN: Removing temporary files from $LTPTMP" |
iyermanoj | d91b924 | 2003-01-09 23:08:26 +0000 | [diff] [blame] | 363 | rm -fr $LTPTMP/tst_mail* |
| 364 | |
Garrett Cooper | be744da | 2010-02-24 20:15:46 -0800 | [diff] [blame] | 365 | tst_resm TINFO "Test CLEAN: Removing temporary user mail_test" |
subrata_modak | 39552a0 | 2008-10-21 06:54:15 +0000 | [diff] [blame] | 366 | userdel -r mail_test > /dev/null 2>&1 |
iyermanoj | fccc143 | 2003-01-07 23:13:33 +0000 | [diff] [blame] | 367 | |
| 368 | exit $TFAILCNT |