Regression test, test_http.sh, moved to sub directory test. The test
[pazpar2-moved-to-github.git] / test / test_http.sh
1 #!/bin/sh
2 # $Id: test_http.sh,v 1.1 2007-05-15 15:50:48 adam Exp $
3 #
4 # Regression test using pazpar2 against yaz-ztest
5 # Reads Pazpar2 URLs from test_http_urls
6 #            Outputs to test_http_<no>.log
7 #            Matches against results in test_htttp_<no>.res
8 #
9
10
11 # srcdir might be set by make
12 srcdir=${srcdir:-"."}
13
14 # Find a suitable yaz-ztest
15 yt=""
16 for d in /usr/bin /usr/local/bin ../../yaz/ztest; do
17     yt=${d}/yaz-ztest
18     if test -x ${yt}; then
19         break
20     fi
21 done
22 if test -z "${yt}"; then
23     echo "No yaz-ztest found. Skipping"
24     exit 0
25 fi
26
27 # Fire up yaz-ztest (should match port in test_http.xml)
28 $yt -l test_http_ztest.log tcp:@:9764 &
29 YTPID=$!
30
31 # Fire yp pazpar2
32 ../src/pazpar2 -f ${srcdir}/test_http.cfg -t ${srcdir}/test_http.xml >test_http_pp2.log 2>&1 &
33 PP2PID=$!
34
35 # Give both programs room to start properly..
36 sleep 1
37
38 # Set to success by default.. Will be set to non-zero in case of failure
39 code=0
40
41 if ps -p $PP2PID >/dev/null 2>&1; then
42     :
43 else
44     code=1
45     PP2PID=""
46     echo "pazpar2 failed to start"
47 fi
48
49 if ps -p $YTPID >/dev/null 2>&1; then
50     :
51 else
52     code=1
53     YTPID=""
54     echo "yaz-ztest failed to start"
55 fi
56 # We can start test for real
57
58 testno=1
59 for f in `cat ${srcdir}/test_http_urls`; do
60     OUT1=${srcdir}/test_http_${testno}.res
61     OUT2=${srcdir}/test_http_${testno}.log
62     DIFF=${srcdir}/test_http_${testno}.dif
63     if test -f $OUT1; then
64         rm -f $OUT2
65         wget -q -O $OUT2 $f
66         if diff $OUT1 $OUT2 >$DIFF; then
67             echo "Test $testno: OK"
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 done
79
80 sleep 1
81 # Kill programs
82 if test -n "$YTPID"; then
83     kill $YTPID
84 fi
85
86 if test -n "$PP2PID"; then
87     kill $PP2PID
88 fi
89
90 exit $code
91
92 # Local Variables:
93 # mode:shell-script
94 # sh-indentation: 2
95 # sh-basic-offset: 4
96 # End: