Test use of pz:xslt=auto
[pazpar2-moved-to-github.git] / test / test_http.sh
1 #!/bin/sh
2 # $Id: test_http.sh,v 1.8 2007-07-18 13:39:11 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 rm -f marc21.xsl
24 ln -s ${srcdir}/../etc/marc21.xsl
25
26 # Fire up pazpar2
27 rm -f pazpar2.log
28 ../src/pazpar2 -X -l pazpar2.log -f ${srcdir}/test_http.cfg -t ${srcdir}/test_http.xml >extra_pazpar2.log 2>&1 &
29 PP2PID=$!
30
31 # Give it a chance to start properly..
32 sleep 1
33
34 # Set to success by default.. Will be set to non-zero in case of failure
35 code=0
36
37 if ps -p $PP2PID >/dev/null 2>&1; then
38     :
39 else
40     code=1
41     PP2PID=""
42     echo "pazpar2 failed to start"
43 fi
44
45 # We can start test for real
46
47 oIFS="$IFS"
48 IFS='
49 '
50
51 testno=1
52 for f in `cat ${srcdir}/test_http_urls`; do
53     if echo $f | grep '^http' >/dev/null; then
54         OUT1=${srcdir}/test_http_${testno}.res
55         OUT2=test_http_${testno}.log
56         DIFF=test_http_${testno}.dif
57         if test -f $OUT1; then
58             rm -f $OUT2
59             if test -n "${wget}"; then
60                 ${wget} -q -O $OUT2 $f
61             elif test -n "${lynx}"; then
62                 ${lynx} -dump $f >$OUT2
63             else
64                 break
65             fi
66             if diff $OUT1 $OUT2 >$DIFF; then
67                 :
68             else
69                 echo "Test $testno: Failed. See $OUT1, $OUT2 and $DIFF"
70                 code=1
71             fi
72         else
73             echo "Test $testno: Making for the first time"
74             ${wget} -q -O $OUT1 $f
75             code=1
76         fi
77         testno=`expr $testno + 1`
78     else
79         sleep $f
80     fi
81     if ps -p $PP2PID >/dev/null 2>&1; then
82         :
83     else
84         echo "pazpar2 died"
85     fi
86 done
87 IFS="$oIFS"
88
89 sleep 1
90 # Kill programs
91
92 if test -n "$PP2PID"; then
93     kill $PP2PID
94 fi
95
96 exit $code
97
98 # Local Variables:
99 # mode:shell-script
100 # sh-indentation: 2
101 # sh-basic-offset: 4
102 # End: