1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
#!/bin/sh
# HOME so it finds the right .pyzor
export HOME=.
export PYTHONPATH=../lib
start_server()
{
./pyzord --homedir . > pyzord.log &
PYZORD_PID=$!
echo "started server with pid $PYZORD_PID"
}
pyzor()
{
./pyzor --homedir . "$@"
}
pyzor_bob()
{
pyzor --homedir bob "$@"
}
check()
{
pyzor check < test.in.0
}
check_bob()
{
pyzor_bob check < test.in.0
}
kill_server()
{
echo "killing server (pid $PYZORD_PID)"
kill $PYZORD_PID
}
fail()
{
echo "failed: $1"
exit 1;
}
setcount()
{
count=`pyzor check < test.in.0 | cut -f 3`
}
setcount_bob()
{
count=`pyzor_bob check < test.in.0 | cut -f 3`
}
fail_cmp()
{
fail "got $1; expected $2"
}
rm -f pyzord.*
echo "starting server"
start_server
# sleep to give it time to start listening
sleep 2
[ ! -z $PYZORD_PID ] || fail "we didn't get a process id for the server!"
kill -0 $PYZORD_PID || fail "process is dead"
trap kill_server 0
echo "anonymous: pinging"
pyzor ping || fail
echo "anonymous: ensuring a count of 0 at start"
setcount
[ ${count:--1} = 0 ] || fail
check && fail
echo "bob: ensuring a count of 0 at start"
setcount_bob
[ ${count:--1} = 0 ] || fail
check_bob && fail
echo "anonymous: reporting"
pyzor report < test.in.0 && fail
echo "anonymous: reporting"
pyzor report < test.in.0 && fail
echo "bob: reporting"
pyzor_bob report < test.in.0 || fail
echo "bob: reporting"
pyzor_bob report < test.in.0 || fail
echo "anonymous: counting reports"
setcount
[ ${count:--1} = 2 ] || fail
check || fail
echo "bob: counting reports"
setcount_bob
[ ${count:--1} = 2 ] || fail_cmp ${count:--1} 2
check_bob || fail "checking failed"
echo "bob: reporting a mailbox"
pyzor_bob report --mbox < test.in.mbox || fail
echo "bob: counting reports"
setcount_bob
[ ${count:--1} = 3 ] || fail_cmp ${count:--1} 3
check_bob || fail "checking exit code failed"
echo "bob: getting info"
# check exit
pyzor_bob info < test.in.0 || fail
# check lines
[ `pyzor_bob info < test.in.0 | wc -l` = 7 ] || fail
echo "anonymous: whitelisting"
pyzor whitelist < test.in.0 && fail
echo "bob: whitelisting"
pyzor_bob whitelist < test.in.0 || fail
echo "bob: getting info"
# check exit
pyzor_bob info < test.in.0 || fail
# check lines
[ `pyzor_bob info < test.in.0 | wc -l` = 7 ] || fail
echo "bob: counting reports"
setcount_bob
[ ${count:--1} = 0 ] || fail_cmp ${count:--1} 0
check && fail
echo "checking for logfile"
[ -s pyzord.log ] || fail
echo "passed"
|