1#! /bin/sh 2# $Id: getlist.t 7169 2005-04-10 10:08:34Z rra $ 3# 4# Test suite for getlist. 5 6# The count starts at 1 and is updated each time ok is printed. printcount 7# takes "ok" or "not ok". 8count=1 9printcount () { 10 echo "$1 $count $2" 11 count=`expr $count + 1` 12} 13 14# Takes a file, a grep expression and then arguments for getlist, calls 15# getlist with those arguments, and compares the result from the results of 16# running grep on the file. 17getlist () { 18 file="$1" 19 shift 20 grep="$1" 21 shift 22 grep "$grep" "$file" > wanted 23 $getlist -h localhost -p 11119 "$@" > seen 24 if [ $? = 0 ] && diff wanted seen ; then 25 printcount "ok" 26 else 27 printcount "not ok" 28 fi 29 rm wanted seen 30} 31 32# Find the right directory. 33getlist="../../frontends/getlist" 34dirs='. clients tests/clients' 35for dir in $dirs ; do 36 if [ -r "$dir/server-list" ] ; then 37 cd $dir 38 break 39 fi 40done 41if [ ! -x "$getlist" ] ; then 42 echo 'Could not find getlist' >&2 43 exit 1 44fi 45if [ ! -x 'server-list' ] ; then 46 echo 'Could not find server-list' >&2 47 exit 1 48fi 49 50# Print out the count of tests. 51echo 15 52 53# Point getlist at the appropriate inn.conf file. 54INNCONF=../data/etc/inn.conf; export INNCONF 55 56# Start the daemon. 57./server-list 58 59# Run the tests. 60getlist ../data/db/active . 61getlist ../data/db/active . active 62getlist ../data/db/active . active '*' 63getlist ../data/db/active . active '*' ymx= 64getlist ../data/db/active '\.test ' active '*.test' 65getlist ../data/db/active '\.test ' active '*.test' y 66getlist ../data/db/active '#######' active '*.test' m 67getlist ../data/db/active ' =' active '*' = 68getlist ../data/db/active ' x$' active 'example.*' x 69getlist ../data/db/active ' y$' active '*' y 70getlist ../data/db/newsgroups . newsgroups 71getlist ../data/db/newsgroups . newsgroups '*' 72getlist ../data/db/newsgroups 'config' newsgroups '*.config' 73getlist ../data/db/active.times . active.times 74getlist ../data/db/distributions . distributions 75 76# Kill the server. 77kill `cat pid` 78rm pid 79