New pazpar2 option -X which puts pazpar2 in debug (insecure) mode.
[pazpar2-moved-to-github.git] / test / test_http.sh
1 #!/bin/sh
2 # $Id: test_http.sh,v 1.7 2007-05-23 21:58:29 adam Exp $
3 #
4 # Regression test using pazpar2 against z3950.indexdata.com/marc
5 # Reads Pazpar2 URLs from test_http_urls
6 #            Outputs to test_http_<no>.log
7 #            Matches against results in test_http_<no>.res
8 #
9
10
11 # srcdir might be set by make
12 srcdir=${srcdir:-"."}
13
14 wget=""
15 lynx=""
16 if test -x /usr/bin/wget; then
17     wget=/usr/bin/wget
18 fi
19 if test -x /usr/bin/lynx; then
20     lynx=/usr/bin/lynx
21 fi
22
23 # Fire up pazpar2
24 rm -f pazpar2.log
25 ../src/pazpar2 -X -l pazpar2.log -f ${srcdir}/test_http.cfg -t ${srcdir}/test_http.xml >extra_pazpar2.log 2>&1 &
26 PP2PID=$!
27
28 # Give it a chance to start properly..
29 sleep 1
30
31 # Set to success by default.. Will be set to non-zero in case of failure
32 code=0
33
34 if ps -p $PP2PID >/dev/null 2>&1; then
35     :
36 else
37     code=1
38     PP2PID=""
39     echo "pazpar2 failed to start"
40 fi
41
42 # We can start test for real
43
44 oIFS="$IFS"
45 IFS='
46 '
47
48 testno=1
49 for f in `cat ${srcdir}/test_http_urls`; do
50     if echo $f | grep '^http' >/dev/null; then
51         OUT1=${srcdir}/test_http_${testno}.res
52         OUT2=test_http_${testno}.log
53         DIFF=test_http_${testno}.dif
54         if test -f $OUT1; then
55             rm -f $OUT2
56             if test -n "${wget}"; then
57                 ${wget} -q -O $OUT2 $f
58             elif test -n "${lynx}"; then
59                 ${lynx} -dump $f >$OUT2
60             else
61                 break
62             fi
63             if diff $OUT1 $OUT2 >$DIFF; then
64                 :
65             else
66                 echo "Test $testno: Failed. See $OUT1, $OUT2 and $DIFF"
67                 code=1
68             fi
69         else
70             echo "Test $testno: Making for the first time"
71             ${wget} -q -O $OUT1 $f
72             code=1
73         fi
74         testno=`expr $testno + 1`
75     else
76         sleep $f
77     fi
78     if ps -p $PP2PID >/dev/null 2>&1; then
79         :
80     else
81         echo "pazpar2 died"
82     fi
83 done
84 IFS="$oIFS"
85
86 sleep 1
87 # Kill programs
88
89 if test -n "$PP2PID"; then
90     kill $PP2PID
91 fi
92
93 exit $code
94
95 # Local Variables:
96 # mode:shell-script
97 # sh-indentation: 2
98 # sh-basic-offset: 4
99 # End: