#!/bin/sh
# $Id: t-mxcheck-0.sh,v 1.3 2006/12/28 05:16:44 ca Exp $
#
# ------------------------------------------------------------
# Description:
# Script to test MX lookups of RFC2821 addresses
# Uses smar, t-access-0, access map, t-mm, startsmar.sh
# ------------------------------------------------------------
# Note: smar and t-access-0 are running asynchronous, hence
# there must be no expected order in the output file.
#
# don't run if stop is "set".
test -s stop && exit 1
#
if test X"${MTA_NO_DNS_TEST}" != "X"
then
echo "SKIPPED: $0"
exit 0
fi
SD=`dirname $0`
if test "${SD}" = "."
then
SD=../smar
fi
. ${SD}/common.sh
OUT=mxcheck-0.out
IP=mxcheck-0.ip
OK=mxcheck-0.ok
TPRG=./t-access-0
VERBOSE=false
if test X"`uname`" != "XOSF1"
then
while getopts s:V FLAG
do
case "${FLAG}" in
s) SKIP="${SKIP} ${OPTARG}";;
V) VERBOSE=true;;
esac
done
shift `expr ${OPTIND} - 1`
fi
rm -f ${ACCMAP} ${SOCK} ${PIDS}
# create access map for tests
${VALGRIND} ${MM} -t' ' -F ${ACCMAP} <<EOF
mxbadip:127.0.0.1 error:550 5.7.0 127.0.0.1 not allowed
EOF
killit()
{
if test -s ${PIDS}
then
# stop SMAR
for i in `cat ${PIDS}`
do
kill ${i}
done
fi
# thanks kids for not following the POSIX standard...
if test X"`uname`" = "XLinux"
then
killall smar
fi
exit 1
}
trap killit 2
# start SMAR
${SHELL} ${SD}/startsmar.sh || exit 1
rm -f ${OUT} ${IP} ${OK}
# run tests ----------------
TEST=1
# ----------------------------------------
${VALGRIND} ${TPRG} -M '<t1@meta1null.meta1.org>' > ${OUT} 2>&1
grep '^react=' ${OUT} > ${IP}
cat > ${OK} <<EOF
react=statt, ret=0, statt='551 5.1.8 Invalid MX entry
EOF
if diff ${OK} ${IP}
then
:
else
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed."
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
fi
TEST=2
# ----------------------------------------
${VALGRIND} ${TPRG} -M '<t2@meta1nullbutA.meta1.org>' > ${OUT} 2>&1
grep '^react=' ${OUT} > ${IP}
cat > ${OK} <<EOF
react=statt, ret=0, statt='551 5.1.8 Invalid MX entry
EOF
if diff ${OK} ${IP}
then
:
else
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed."
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
fi
TEST=3
# ----------------------------------------
${VALGRIND} ${TPRG} -M '<t3@meta1nullMX1.meta1.org>' > ${OUT} 2>&1
grep '^react=' ${OUT} > ${IP}
cat > ${OK} <<EOF
react=statt, ret=0, statt='551 5.1.8 Invalid MX entry
EOF
if diff ${OK} ${IP}
then
:
else
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed."
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
fi
# end tests ----------------
# stop SMAR
for i in `cat ${PIDS}`
do
kill ${i}
done
# ----------------
# thanks kids for not following the POSIX standard...
if test X"`uname`" = "XLinux"
then
killall smar
fi
sleep 3
exit ${ERRS}
syntax highlighted by Code2HTML, v. 0.9.1