OSSP CVS Repository

ossp - ossp-pkg/lmtp2nntp/test/run.sh 1.16
Not logged in
[Honeypot]  [Browse]  [Directory]  [Home]  [Login
[Reports]  [Search]  [Ticket]  [Timeline
  [Raw

ossp-pkg/lmtp2nntp/test/run.sh 1.16
#/bin/sh

# -h news-muc1.de.cw.net
# -h news-ffm2.de.cw.net
# -h news-dus2.de.cw.net
# -h news.ecrc.de
# -h dev16

post1000 ()
{
    for h in 0 1 2 3 4 5 6 7 8 9
    do
       for z in 0 1 2 3 4 5 6 7 8 9
        do
            for e in 0 1 2 3 4 5 6 7 8 9
            do
                echo -n $h$z$e
                newmsg sendmail
                cat $STDIN \
                 | sendmail -i posting+$h$z$e@dev12.dev.de.cw.net
            done
        done
    done
}

lmtp()
{
    newmsg lmtp
    cat $STDIN \
      | ../lmtp2nntp -l $1:$FILE -w 1 -d $2 -g $2 -b dev12 -h dev16,141.1.23.116:nntp -h dev16.de.cw.net:119 $3 >/dev/null; echo $?
     #| ../lmtp2nntp -l $1:$FILE -w 1 -d 255/2.5.5 -g $3 -b 127.0.0.1 $4 >/dev/null; echo $?
     #| ../lmtp2nntp -l $1:$FILE -w 1 -d $2 -g $3 -b 127.0.0.1 -h 127.0.0.2 $4 >/dev/null; echo $?
}

sendmaildup()
{
    newmsg sendmail
    cat $STDIN \
     | sendmail -i posting+cw.de.sd.apps.dev.test@dev12.dev.de.cw.net
    cat $STDIN \
     | sendmail -i posting+cw.de.sd.apps.dev.test@dev12.dev.de.cw.net
}

newmsg()
{
    if [ -r testmessage.via$1 ]
    then
        awk <testmessage.via$1 \
         -v pid=$$ \
         -v id=I${h}${z}${e}D \
         -v date=`date +%Y%m%d%H%M%S` \
         '
            BEGIN          { gotit = 0; IGNORECASE = 1 }
            /^#$/          { gotit = 1; print "#" date " [" pid "] " id }
            /^Message-ID:/ { gotit = 1; print "Message-Id: <" date "-" id "@dev12.dev.de.cw.net>" }
            /^Subject:/    { gotit = 1; print "Subject: [" pid "] " $2 }
                           { if (gotit == 0) { print }; gotit = 0 }
         ' | tee 2>&1 >/dev/null $STDIN
    else
        echo "ERROR: file testmessage.via$1 not readable!"
        exit 1
    fi
}

prolog ()
{
    h="H"
    z="Z"
    e="E"

    for i in $FILE $STDIN $STDOUT $STDERR dmalloc.log
    do
        if [ -e $i ]; then
            rm -f $i
        fi
        touch $i
        chmod 666 $i
    done
}

epilog ()
{
    if [ -r $FILE ]
    then
        read DUMMY
        less -S $FILE
    fi

    if [ -r dmalloc.log ]
    then
        read DUMMY
        less -S dmalloc.log
    fi
}

#   lmtp feed arg
#   lmtp post envelope '*.test.* cw.*.dev.*'
#   lmtp post header '*.test.* cw.*.dev.* *foo*'
#   lmtp feed envelope
#   lmtp post envelope
#   sendmaildup
#   post1000

   LOG="trace"
  FILE="stdlog"
 STDIN="stdin"
STDOUT="stdout"
STDERR="stderr"
 LOCAL="0.0.0.0"
  HOST="0.0.0.0"
 GROUP="my.test"
MFILT=".+@(?:[^.]+\.)*cw\.com"
 NODE="gateway"

# make check with automatic succeed/ fail message.
# more samples and testing below.
newmsg lmtp

# check -v option prints out version, typical output: lmtp2nntp 0.9.4
# (30-Aug-2001)
prolog
../lmtp2nntp -v >$STDOUT 2>$STDERR
RC=`cat $STDOUT | egrep 'lmtp2nntp[ ]+[0-9]+\.[0-9]\.[0-9][ ]+\([0-9]+-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-[0-9]{4}\)' | wc -l`
if [ $RC -ne 1 -o -s $STDERR ]; then
    echo "CHECK ERROR: version test failed $RC"
    exit 1;
fi
echo "CHECK version test succeeded"

# check -? option prints out usage, typical output: USAGE: ../lmtp2nntp
# lmtp2nntp [-b bindaddr[:port]] [-d deliverymode] [-g groupmode] [-h
# host[:port][,host[:port], ...]] [-m mailfrom] [-n nodename] [-s size] [-l
# level[:logfile]] [-v] [-w waittime] newsgroup [newsgroup ...]
prolog
../lmtp2nntp -? >$STDOUT 2>$STDERR
RC=`cat $STDERR | egrep -- '-b.*-d.*-g.*-h.*-m.*-n.*-s.*-l.*-v.*-w.*newsgroup' | wc -l`
if [ $RC -ne 1 -o -s $STDOUT ]; then
    echo "CHECK ERROR: usage test failed"
    exit 1;
fi
echo "CHECK usage test succeeded"

# check dummy posting
#set -v -x
prolog
newmsg lmtp
../lmtp2nntp <$STDIN -b $LOCAL -d 250/2.0.0 -g arg -h $HOST -l $LOG:$FILE -m "$MFILT" -n $NODE -s 1000 -w 1 $GROUP >$STDOUT 2>$STDERR ; RC=$
set +v +x
RC="";
if [ 1 -eq `cat $STDOUT | egrep '^220[ ]+LMTP Service ready'    | wc -l` ]; then RC="${RC}LHLO "; fi
if [ 1 -eq `cat $STDOUT | egrep '^250 2.1.0 Sender ok'          | wc -l` ]; then RC="${RC}MAIL "; fi
if [ 3 -eq `cat $STDOUT | egrep '^250 2.1.5 Recipient accepted' | wc -l` ]; then RC="${RC}RCPT "; fi
if [ 1 -eq `cat $STDOUT | egrep '^354 Enter mail'               | wc -l` ]; then RC="${RC}DATA "; fi
if [ 3 -eq `cat $STDOUT | egrep '^250-2.0.0 NNTP noop fake'     | wc -l` ]; then RC="${RC}post "; fi
if [ 1 -eq `cat $STDOUT | egrep '^221 2.0.0.+closing.+channel'  | wc -l` ]; then RC="${RC}QUIT "; fi
if [ "$RC" != "LHLO MAIL RCPT DATA post QUIT " ]; then
    echo "CHECK ERROR: fake post test failed"
    exit 1;
fi
echo "CHECK fake post test succeeded"

echo "CHECK COMPLETE AND PASSED"
exit 0

#
#   BELOW ARE INTERAL TESTS. CONSIDER THEM AS EXAMPLE.
#
  HOST="dev16,141.1.23.116:nntp -h dev16.de.cw.net:119"
 GROUP="cw.de.sd.apps.dev.test"
newmsg lmtp
../lmtp2nntp <$STDIN -b $LOCAL -d post      -g arg -h $HOST -l $LOG:$FILE -m "$MFILT" -n $NODE -s 1000 -w 1 $GROUP >$STDOUT 2>$STDERR ; RC=$
#./lmtp2nntp <$STDIN -b $LOCAL -d 250/2.0.0 -g arg -h $HOST -l $LOG:$FILE -m "$MFILT" -n $NODE -s 1000 -w 1 $GROUP >$STDOUT 2>$STDERR ; RC=$
/dev/null; echo $?

#newmsg sendmail
# sendmail -i <$STDIN -V nase123baer posting+$GROUP@$LOCAL

after
exit 0


CVSTrac 2.0.1