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