#!/bin/sh
# $Id: t-msgmod-3.sh,v 1.3 2006/10/05 04:27:40 ca Exp $
# Copyright (c) 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.
#
# ----------------------------------------
# test message body modifications: inserting headers
# uses t-msgmod-0
# ----------------------------------------
#
test -s stop && exit 1
#
GREP=grep
ERR=false
ERRS=0
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
TPRG=./t-msgmod-0
IN=msg-3.in
OK=msg-3.ok
OUT=msg-3.out
cat > ${IN} <<EOF
From: a
To: b
Subject: first subject line
continued subject
last subject line
body
.
EOF
# ----------------------------------------
# test: insert header
TEST=1
if echo " ${SKIP} X" | ${GREP} -v " ${TEST} " > /dev/null
then
ERR=false
cat > ${OK} <<EOF
Insert: header0
From: a
To: b
Subject: first subject line
continued subject
last subject line
body
.
EOF
for i in 1 2 3 4 5 6 7 8 9 10 16 32 128 256
do
${TPRG} -b ${i} -i '0=Insert: header0' < ${IN} > ${OUT}
if diff ${OK} ${OUT}
then
:
else
echo "$0: test ${TEST} failed for i=${i}"
ERR=true
break
fi
done
if ${ERR}
then
echo "$0: test ${TEST} failed"
ERRS=`expr ${ERRS} + 1 `
test X"${MTA_STOPONERROR}" != X && exit 1
fi
else
${VERBOSE} && echo "$0: test ${TEST} SKIPPED"
fi
# ----------------------------------------
# test: insert header
TEST=2
if echo " ${SKIP} X" | ${GREP} -v " ${TEST} " > /dev/null
then
ERR=false
cat > ${OK} <<EOF
From: a
Insert: header1
To: b
Subject: first subject line
continued subject
last subject line
body
.
EOF
for i in 1 2 3 4 5 6 7 8 9 10 16 32 128 256
do
${TPRG} -b ${i} -i '1=Insert: header1' < ${IN} > ${OUT}
if diff ${OK} ${OUT}
then
:
else
echo "$0: test ${TEST} failed for i=${i}"
ERR=true
break
fi
done
if ${ERR}
then
echo "$0: test ${TEST} failed"
ERRS=`expr ${ERRS} + 1 `
test X"${MTA_STOPONERROR}" != X && exit 1
fi
else
${VERBOSE} && echo "$0: test ${TEST} SKIPPED"
fi
# ----------------------------------------
# test: insert header
TEST=3
if echo " ${SKIP} X" | ${GREP} -v " ${TEST} " > /dev/null
then
ERR=false
cat > ${OK} <<EOF
From: a
To: b
Subject: first subject line
continued subject
last subject line
body
.
EOF
for i in 1 2 3 4 5 6 7 8 9 10 16 32 128 256
do
${TPRG} -b ${i} -i '4=Insert: header4' < ${IN} > ${OUT}
if diff ${OK} ${OUT}
then
:
else
echo "$0: test ${TEST} failed for i=${i}"
ERR=true
break
fi
done
if ${ERR}
then
echo "$0: test ${TEST} failed"
ERRS=`expr ${ERRS} + 1 `
test X"${MTA_STOPONERROR}" != X && exit 1
fi
else
${VERBOSE} && echo "$0: test ${TEST} SKIPPED"
fi
# ----------------------------------------
# test: prepend, insert, and append headers
TEST=4
if echo " ${SKIP} X" | ${GREP} -v " ${TEST} " > /dev/null
then
ERR=false
cat > ${OK} <<EOF
Prepend: headerP
Prepend2: headerP2
From: a
HeaderIns1: insert1
To: b
HeaderIns2: insert2
Subject: first subject line
continued subject
last subject line
Append: headerA
Append2: headerA2
body
.
EOF
for i in 1 2 3 4 5 6 7 8 9 10 16 32 128 256
do
${TPRG} -b ${i} -M 'p=Prepend: headerP' -M 'a=Append: headerA' -M 'p=Prepend2: headerP2' -M 'a=Append2: headerA2' -i '1=HeaderIns1: insert1' -i '2=HeaderIns2: insert2' < ${IN} > ${OUT}
if diff ${OK} ${OUT}
then
:
else
echo "$0: test ${TEST} failed for i=${i}"
ERR=true
break
fi
done
if ${ERR}
then
echo "$0: test ${TEST} failed"
ERRS=`expr ${ERRS} + 1 `
test X"${MTA_STOPONERROR}" != X && exit 1
fi
else
${VERBOSE} && echo "$0: test ${TEST} SKIPPED"
fi
# ----------------------------------------
# end
if test "${ERRS}" = "0"
then
rm -f ${IN} ${OK} ${OUT}
exit 0
else
echo "${ERRS} error(s)"
exit 1
fi
syntax highlighted by Code2HTML, v. 0.9.1