[comp.mail.sendmail] Is there a test suite for sendmail?

marc@apollo.COM (Marc Gibian) (04/08/89)

Does anyone out there know of a test suite for sendmail?

Thanks,
-- 
Internet: marc@apollo.COM            UUCP: {decvax,mit-erl,yale}!apollo!marc
NETel:    Apollo: 508-256-6600 x2077
(Copyright 1988 by author. All rights reserved.  Free redistribution allowed.)

barnett@crdgw1.crd.ge.com (Bruce Barnett) (04/11/89)

In article <427eb5e9.feda@apollo.COM>, marc@apollo (Marc Gibian) writes:
>Does anyone out there know of a test suite for sendmail?

I have included a simple script in the Beta release of Ease 2.1.
The input is in the form

	0 user@some.do.main
	0 a!b@c.com
	etc.
and the output is in TBL form:

0	user@some.do.main	tcp	some.do.main	user<@some.do.main>
0	a!b@d.com	tcp	d.com	a!b


Yell if you want it.

--
Bruce G. Barnett	<barnett@crdgw1.ge.com>  a.k.a. <barnett@[192.35.44.4]>
			uunet!steinmetz!barnett, <barnett@steinmetz.ge.com>

barnett@crdgw1.crd.ge.com (Bruce G. Barnett) (04/14/89)

>Does anyone out there know of a test suite for sendmail?

	This is how I test my sendmail files.

	This document is a portion of the Ease 2.1 package
	(currently in Beta test).

I use the following mechanism to maintain a sendmail file

	0. If you don't have Ease 2.1, go to step 5.
	1. Convert the *.cf file into ease.
	2. Convert the ease file to cf.  Look at the errors.

	   Most of these errors can be eliminated by using the right
	   flags on cfc. Make sure that you specify all of the
	   classes (using the -C flag ) that you need, which generate
	   the matching field definitions for any_in_? fields.

	   The remaining errors are either warnings or mistakes
	   in the translation. If you can't get cfc/ease to accept
	   the new syntax, use the asm("    ") construct to work around
	   it and report the bugs.

	3. At this point, your ease output should be close to the original
	   input. Use the program cfdiff to check this. Cfdiff, and cfstrip,
	   are two shell scripts I wrote for comparing two *.cf files.

	   You will see some differences in lines that have been split into
	   two lines, and the Ob option is converted into the more
	   verbose Obackground option.

	  If your diff program has the -w option, you can ignore spaces in the
	  cf files. Occasionally ease inserts some extra spaces. Or the
	  original sendmail file has extra spaces. (e.g. SunOS).
	  See the script cfdiff.

	4. Once you have the ease file in good form, put it under sccs
	   control, and put the version number (%W% in the V macro
	   definition, so the received by line reflects the revision.)

	5. Use a makefile and the two scripts showhow and showwhere to
	   develop a test suite for your sendmail. This takes the file
	   debug.in as input. The format is:

		rulesets	address
	or
		ruleset		address comment
if ruleset does not start with a '0'

	   Example:

		0	user@some.do.main
		0	site!user%site2@site3.com
		22,4	user@localsite	Sender_via_UUCP

where 22 is a mailer rewrite ruleset for a mailer (i.e. UUCP).

	Ruleset 0 must be avoided when testing the re-write rules for
	mailers because ruleset 0 outputs a triple, and only one part is
	passed to the mailers.

	   The makefile generates a file in tbl(1) format that
	   lists the following:

		ruleset	address	  mailer hostname user

	   Showing the resolved triplet for each address/ruleset combination

	   I have tested these scripts on Ultrix 3.0 and SunOS 4.0
	   systems. This may not work on all sendmails.
	   The problem is that older sendmails output debug info
	   using ^V, etc. instead of $#.
	   Also - different sendmails use different ^<char> combinations.
	   You may have to experiment.


You may want a makefile set up like this:
The important point is that you have a "golden" copy of the test results
which you compare with the test results generated by the make file.

The debug loop is:

while(wrong) {
	edit the ease file (or .cf file)
	generating the debug.out file
	comparing debug.out with debug.out.golden.
	Look at the differences
	}
-------------------------------------------
sendmail.cf:	/usr/lib/sendmail.cf
	cp /usr/lib/sendmail.cf .
sendmail.cfc:	sendmail.cf
	cfc <sendmail.cf >sendmail.ease
sendmail.out:	sendmail.ease
	et -C <sendmail.ease >sendmail.out

# compare ease output with original input
diff:
	cfdiff sendmail.cf sendmail.out

# assume you have a "golden" copy of the debug results that is correct
test:	debug.out
	diff debug.out debug.out.golden
debug.out:	debug.in sendmail.out
	showwhere < debug.in  >debug.out
debug.tbl:	debug.out
	echo ".TS"	>debug.tbl
	echo "l l l l l"	>>debug.tbl
	echo "l l l l l." >>debug.tbl
	echo "Ruleset	Input	Mailer	hostname	User" >>debug.tbl
	cat debug.out >>debug.tbl
	echo ".TE" >>debug.tbl
Scripts follow
-----------------------------------------CUT HERE-----------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  showhow showwhere debug.in
# Wrapped by barnett@grymoire on Thu Apr 13 17:37:06 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f showhow -a "${1}" != "-c" ; then
  echo shar: Will not over-write existing file \"showhow\"
else
echo shar: Extracting \"showhow\" \(799 characters\)
sed "s/^X//" >showhow <<'END_OF_showhow'
X#!/bin/sh
X# Inspired from
X#	Dan Long
X# 	CSNET Technical Staff
X# 	long@sh.cs.net
X#
X#
X#define your sendmail program compiled for debug
XSENDMAIL=/usr/lib/sendmail -bt -Csendmail.out -d21.12
Xif [ $# -lt 2 ]
Xthen
X	echo 'Usage: showhow rulesets address [mailer]' 1>&2;exit 2;
Xfi
Xcase $1 in
X0*)
X	echo "$1 $2" | ${SENDMAIL} |\
X	egrep '\$\#|\^V' |\
X	tail -1 |tr -d '"' |\
X	sed \
X		-e 's/\^V/$#/' \
X		-e 's/\^X/$:/' \
X		-e 's/\^W/$@/' \
X		-e 's/^[a-zA-Z ][:a-zA-Z0-9 ]*//' \
X		-e 's/local \$:/local $@ local $:/' \
X		-e 's/\$# //' \
X		-e 's/ \$@ /	/' \
X		-e 's/ \$: /	/' \
X		-e 's/ //g'
X	;;
X*)	# else a rewrite rule for a mailer
X	if [ X$3 = X ]
X	then
X		mailer='-';
X	else
X		mailer=$3;
X	fi
X	echo "$1 $2" | ${SENDMAIL}  |\
X	egrep "^rewrite:"|tail -1 |tr -d '" '|\
X	sed "s/^.*:/$mailer	$mailer	/"
X	;;
Xesac
X
X
X
X
END_OF_showhow
if test 799 -ne `wc -c <showhow`; then
    echo shar: \"showhow\" unpacked with wrong size!
fi
chmod +x showhow
# end of overwriting check
fi
if test -f showwhere -a "${1}" != "-c" ; then
  echo shar: Will not over-write existing file \"showwhere\"
else
echo shar: Extracting \"showwhere\" \(261 characters\)
sed "s/^X//" >showwhere <<'END_OF_showwhere'
X#!/bin/sh
X# Inspired from
X# 	Dan Long
X#       CSNET Technical Staff
X#       long@sh.cs.net
Xwhile :
Xdo
X	read username
X#	echo i just read in  $username
X	if [ $? -eq 0 ]
X	then
X		x="`./showhow $username`"
X			echo $username  $x | tr ' ' '	'
X	else
X		exit 0
X	fi
Xdone
END_OF_showwhere
if test 261 -ne `wc -c <showwhere`; then
    echo shar: \"showwhere\" unpacked with wrong size!
fi
chmod +x showwhere
# end of overwriting check
fi
if test -f debug.in -a "${1}" != "-c" ; then
  echo shar: Will not over-write existing file \"debug.in\"
else
echo shar: Extracting \"debug.in\" \(672 characters\)
sed "s/^X//" >debug.in <<'END_OF_debug.in'
X0 user@me.com
X0 @me.com:user
X0 user%anothger.com@me.com
X0 user@me.UUCP
X0 user@bill.me.com
X0 me.com!user%bill
X0 uunet.UUCP!user%random.net
X0 @uunet.UUCP:user%random.net
X0 @uunet.UUCP:user@random.net
X0 @uunet.UU.NET:user@random.net
X0 uunet!me.com!bogus!bogon
X0 random!crazy!guy
X0 uunet!bit.BITNET!user
X0 bit.BITNET!user
X0 user@bit.BITNET
X0 some.random.domain!user
X0 user@here
X0 user@here.me.com
X0 site!user@uunet.uu.net
X0 uunet!me.com!user
X0 uunet!here.me.com!user
X0 @host1,@host2,@host3:a@b.arpa
X0 uunet!site1!site2
X14,4 user@here	From:TCP
X14,4 a!b!user@uuhost.UUCP	From:TCP
X19,4 user@here	From:local
X13,4 user@here	From:UUCP
X24,4 user@here	To:UUCP
X10,4 user@here	To:prog
X
END_OF_debug.in
if test 672 -ne `wc -c <debug.in`; then
    echo shar: \"debug.in\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0

--
Bruce G. Barnett	<barnett@crdgw1.ge.com>  a.k.a. <barnett@[192.35.44.4]>
			uunet!steinmetz!barnett, <barnett@steinmetz.ge.com>

barnett@crdgw1.crd.ge.com (Bruce G. Barnett) (04/22/89)

In article <111@crdgw1.crd.ge.com>, barnett@crdgw1 (Bruce G. Barnett) writes:
>	This is how I test my sendmail files.

Oops. let me make a small change:

In the script showhow, change
	SENDMAIL=/usr/lib/sendmail -bt -Csendmail.out -d21.12
to
	SENDMAIL="/usr/lib/sendmail -bt -Csendmail.out -d21.12"
That is, put quotes around your sendmail invocation.

Also - to get the script to work on an Ultrix 2.0 machine,
change
		-e 's/\^V/$#/' \
		-e 's/\^X/$:/' \
		-e 's/\^W/$@/' \
to
		-e 's/\^U/$#/' \
		-e 's/\^V/$@/' \
		-e 's/\^W/$:/' \

It seems that the internal codes for the $#, $@ and $: tokens
are one higher in Ultrix 3.0 than 2.0.

I haven't heard one peep from anyone since I posted this.
Either everything is clear or I really botched it!

I also realized that some people send me mail asking for the test scripts,
and I gave them the scripts with no instructions (which was in the posting).

If you don't still have the posting, you can just do
	showwhere <debug.in>debug.out

Then you can compare the debug.out file with a known good ruleset output.

--
Bruce G. Barnett	<barnett@crdgw1.ge.com>  a.k.a. <barnett@[192.35.44.4]>
			uunet!steinmetz!barnett, <barnett@steinmetz.ge.com>