Fire test against z3950.indexdata.com/marc instead.
[pazpar2-moved-to-github.git] / test / test_http.sh
1 #!/bin/sh
2 # $Id: test_http.sh,v 1.4 2007-05-16 08:31:17 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 # Fire yp pazpar2
15 rm -f pazpar2.log
16 ../src/pazpar2 -l pazpar2.log -f ${srcdir}/test_http.cfg -t ${srcdir}/test_http.xml >extra_pazpar2.log 2>&1 &
17 PP2PID=$!
18
19 # Give it a chance to start properly..
20 sleep 1
21
22 # Set to success by default.. Will be set to non-zero in case of failure
23 code=0
24
25 if ps -p $PP2PID >/dev/null 2>&1; then
26     :
27 else
28     code=1
29     PP2PID=""
30     echo "pazpar2 failed to start"
31 fi
32
33 # We can start test for real
34
35 oIFS="$IFS"
36 IFS='
37 '
38
39 testno=1
40 for f in `cat ${srcdir}/test_http_urls`; do
41     if echo $f | grep '^http' >/dev/null; then
42         OUT1=${srcdir}/test_http_${testno}.res
43         OUT2=test_http_${testno}.log
44         DIFF=test_http_${testno}.dif
45         if test -f $OUT1; then
46             rm -f $OUT2
47             wget -q -O $OUT2 $f
48             if diff $OUT1 $OUT2 >$DIFF; then
49                 :
50             else
51                 echo "Test $testno: Failed. See $OUT1, $OUT2 and $DIFF"
52                 code=1
53             fi
54         else
55             echo "Test $testno: Making for the first time"
56             wget -q -O $OUT1 $f
57             code=1
58         fi
59         testno=`expr $testno + 1`
60     else
61         sleep $f
62     fi
63 done
64 IFS="$oIFS"
65
66 sleep 1
67 # Kill programs
68
69 if test -n "$PP2PID"; then
70     kill $PP2PID
71 fi
72
73 exit $code
74
75 # Local Variables:
76 # mode:shell-script
77 # sh-indentation: 2
78 # sh-basic-offset: 4
79 # End: