~ubuntu-branches/ubuntu/saucy/fdm/saucy

« back to all changes in this revision

Viewing changes to regress/test-pop3/test-pop3.sh

  • Committer: Bazaar Package Importer
  • Author(s): Frank Terbeck
  • Date: 2008-04-27 08:41:35 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080427084135-xy4fxa7xkp63o63w
Tags: 1.5-3
* The "this time I tried kfreebsd in qemu" release
* Update 04support_debianbsds.diff to actually build on GNU/k*BSD.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# $Id: test-pop3.sh,v 1.3 2007/10/10 22:31:24 nicm Exp $
 
3
 
 
4
[ -z "$FDM" ] && exit 1
 
5
 
 
6
TEST=$1
 
7
FIFO=$TEST.fifo
 
8
TYPE=pop3
 
9
 
 
10
cat <<EOF >$TEST.conf
 
11
set lock-file "$TEST.lock"
 
12
account 'account' $TYPE
 
13
        pipe "cat $FIFO.in & cat >$FIFO.out" user "test" pass "test"
 
14
match all action drop
 
15
EOF
 
16
 
 
17
rm -f $FIFO.in $FIFO.out
 
18
mkfifo $FIFO.in $FIFO.out || exit 1
 
19
 
 
20
$FDM -mvvvv -f $TEST.conf f >$TEST.log 2>&1 &
 
21
PID=$!
 
22
cat $FIFO.out |&
 
23
 
 
24
hold() {
 
25
    while kill -0 $! 2>/dev/null; do
 
26
        perl -e 'select(undef,undef,undef,0.01)'
 
27
    done
 
28
}
 
29
quit() {
 
30
    rm -f $FIFO.in $FIFO.out $TEST.conf
 
31
    [ "$DEBUG" = "" ] && rm -f $TEST.log
 
32
    
 
33
    if [ $1 -ne 1 ]; then
 
34
        echo "$TEST: PASSED"
 
35
    else
 
36
        echo "$TEST: FAILED"
 
37
    fi
 
38
 
 
39
    exit $1
 
40
}
 
41
 
 
42
awk '/^\>/ { print substr($0, 2) }' $TEST >$FIFO.in || exit 1
 
43
awk '/^\</ { print substr($0, 2) }; /^--$/ { print "--" }' $TEST|\
 
44
while read i; do
 
45
    if [ "$i" != "--" ]; then
 
46
        read -p j
 
47
    
 
48
        if [ "$DEBUG" != "" ]; then
 
49
            echo IN:  $i
 
50
            echo OUT: $j
 
51
        fi
 
52
        [ "$i" = "$j" ] || quit 1
 
53
 
 
54
        continue;
 
55
    fi
 
56
 
 
57
    hold
 
58
    MSG=`tail -1 $TEST`
 
59
    grep "^account: $MSG" $TEST.log >/dev/null || quit 1
 
60
    grep "^account: fetching error. aborted" $TEST.log >/dev/null || quit 1
 
61
    quit 2
 
62
done
 
63
 
 
64
if [ $? -eq 0 ]; then
 
65
    hold
 
66
    grep "^account: [0-9]* messages processed" $TEST.log >/dev/null || quit 1
 
67
    quit 0
 
68
fi