#!/bin/sh
# $Id: t-smar-2.sh,v 1.17 2006/10/05 01:32:28 ca Exp $
# Copyright (c) 2003-2005 Sendmail, Inc. and its suppliers.
# All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
# ------------------------------------------------------------
# Description:
# Script to test MX/A expansion for RFC2821 addresses.
# Uses smar, t-smar-2, startsmar.sh, DNS
# Note: this program relies on the meta1.org DNS server.
# ------------------------------------------------------------
#
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=smar-0.out
IP=smar-0.ip
OK=smar-0.ok
TPRG=./t-smar-1
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 ${SOCK} ${PIDS}
# start SMAR
${SHELL} ${SD}/startsmar.sh || exit 1
rm -f ${OUT} ${IP} ${OK}
TEST=1
# ----------------------------------------
# check output somehow...
${VALGRIND} ${TPRG} -M -VVVV '<a@double1.meta1.org>' > ${OUT} 2>&1
grep '^IP' ${OUT} > ${IP}
cat > ${OK} <<EOF
IP[0]=63.195.85.27 [3fc3551b]
EOF
if diff ${OK} ${IP}
then
:
else
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed."
fi
# 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 5
# start SMAR
rm -f ${SOCK} ${PIDS}
# start SMAR
${SHELL} ${SD}/startsmar.sh || exit 1
rm -f ${OUT} ${IP} ${OK}
TEST=2
# ----------------------------------------
# check output somehow...
${VALGRIND} ${TPRG} -M -VVVV '<a@double2.meta1.org>' > ${OUT} 2>&1
grep '^IP' ${OUT} > ${IP}
cat > ${OK} <<EOF
IP[0]=63.195.85.27 [3fc3551b]
EOF
if diff ${OK} ${IP}
then
:
else
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed."
fi
TEST=3
# ----------------------------------------
# check output somehow...
${VALGRIND} ${TPRG} -M -VVVV '<a@meta1-1-50.meta1.org>' > ${OUT} 2>&1
grep '^IP' ${OUT} > ${IP}
cat > ${OK} <<EOF
IP[0]=10.1.50.10 [a01320a]
IP[1]=10.1.50.11 [a01320b]
IP[2]=10.1.50.20 [a013214]
IP[3]=10.1.50.12 [a01320c]
IP[4]=10.1.50.21 [a013215]
EOF
if diff ${OK} ${IP} >/dev/null
then
:
else
# first two entries are random order, try again
cat > ${OK} <<EOF
IP[0]=10.1.50.11 [a01320b]
IP[1]=10.1.50.10 [a01320a]
IP[2]=10.1.50.20 [a013214]
IP[3]=10.1.50.12 [a01320c]
IP[4]=10.1.50.21 [a013215]
EOF
if diff ${OK} ${IP}
then
:
else
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed."
fi
fi
# rm -f ${OUT} ${IP} ${OK}
# 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
exit ${ERRS}
syntax highlighted by Code2HTML, v. 0.9.1