3 # Regression test using pazpar2 against z3950.indexdata.com/marc or gils
4 # Reads Pazpar2 URLs from $1
5 # Outputs to $1_<no>.log
6 # Matches against results in $1_<no>.res
9 # srcdir might be set by make
12 # terminate pazpar2 if test takes more than this (in seconds)
17 if test -n "$PP2PID"; then
20 if test -f ztest.pid; then
24 if test -n "$SLEEP_PID"; then
32 while test $# -gt 0; do
34 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
55 if test "x${PREFIX}" = "x"; then
56 echo Missing prefix for run_pazpar2.sh
60 # look for curl in PATH
65 if test -x $p/curl; then
72 if test -z $curl; then
73 echo "$PREFIX: curl not found"
77 if test "$icu" = "true"; then
78 if ../src/pazpar2 -V |grep icu:enabled >/dev/null; then
81 echo "Skipping ${PREFIX}: ICU support unavailable"
86 if test "$ztest" = "true" ; then
91 if test -x $p/yaz-ztest -a -x $p/yaz-client; then
92 VERSION=`$p/yaz-client -V|awk '{print $3;}'|awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
93 if test $VERSION -ge 4002052; then
100 for p in ${srcdir}/../../yaz ${srcdir}/../../yaz-*; do
101 if test -x $p/ztest/yaz-ztest -a -x $p/client/yaz-client; then
102 VERSION=`$p/client/yaz-client -V|awk '{print $3;}'|awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
103 if test $VERSION -ge 4002052; then
111 if test -z "$F"; then
112 echo "Skipping ${PREFIX}: recent yaz-ztest not found"
116 rm -f ${PREFIX}_ztest.log
117 $F -l ${PREFIX}_ztest.log -p ztest.pid -D tcp:localhost:9999
119 if test ! -f ztest.pid; then
120 echo "yaz-ztest could not be started"
125 # remove log if starting pazpar2
126 if [ -z "$SKIP_PAZPAR2" ] ; then
127 rm -f ${PREFIX}_pazpar2.log
132 VALGRINDLOG=${PREFIX}_valgrind.log
134 if test `uname` = "Linux"; then
141 LEVELS=loglevel,fatal,warn,log,debug,notime,zoom,zoomdetails
142 if test -n "$PAZPAR2_USE_VALGRIND"; then
143 valgrind --num-callers=30 --show-reachable=yes --leak-check=full --log-file=$VALGRINDLOG ../src/pazpar2 -v $LEVELS -X -l ${PREFIX}_pazpar2.log -f ${CFG} >${PREFIX}_extra_pazpar2.log 2>&1 &
147 elif test -n "$SKIP_PAZPAR2"; then
148 echo "${PREFIX}: not starting Pazpar2 (should be running already)"
150 ../src/pazpar2 -v $LEVELS -d -X -l ${PREFIX}_pazpar2.log -f ${srcdir}/${CFG} >${PREFIX}_extra_pazpar2.log 2>&1 &
155 if [ -z "$SKIP_PAZPAR2" -a -z "$WAIT_PAZPAR2" ] ; then
156 if ps -p $PP2PID >/dev/null 2>&1; then
157 (sleep $WAIT; kill_pazpar2 >/dev/null) &
159 trap kill_pazpar2 INT
160 trap kill_pazpar2 HUP
162 echo "${PREFIX}: pazpar2 failed to start"
163 if test -f ztest.pid; then
171 GET='$curl --silent --output $OUT2 "$f"'
172 POST='$curl --silent --header "Content-Type: text/xml" --data-binary "@$postfile" --output $OUT2 "$f"'
174 # Set to success by default.. Will be set to non-zero in case of failure
177 # We can start test for real
180 for f in `cat ${srcdir}/${URLS}`; do
181 if echo $f | grep '^http' >/dev/null; then
182 OUT1=${srcdir}/${PREFIX}_${testno}.res
183 OUT2=${PREFIX}_${testno}.log
184 DIFF=${PREFIX}_${testno}.dif
186 if [ -n "$DEBUG" ] ; then
187 echo "test $testno: $f"
189 while test $rounds -gt 0; do
190 if test -n "${postfile}"; then
195 if test ! -f $OUT2; then
198 rounds=`expr $rounds - 1`
199 if test -f $OUT1 -a -z "$PAZPAR2_OVERRIDE_TEST"; then
200 if diff $OUT1 $OUT2 >$DIFF 2>/dev/null; then
205 if test $rounds -eq 0; then
206 echo "${PREFIX} $testno: Failed. See $OUT1, $OUT2 and $DIFF"
212 if test $rounds -eq 0; then
213 echo "${PREFIX} $testno: Making for the first time"
218 if test $rounds -gt 0; then
222 testno=`expr $testno + 1`
225 elif echo $f | grep '^[0-9]' >/dev/null; then
228 if test -f $srcdir/$f; then
231 echo "File $f does not exist"
235 if [ -z "$SKIP_PAZPAR2" ] ; then
236 if ps -p $PP2PID >/dev/null 2>&1; then
240 if test -n "$SLEEP_PID"; then
241 echo "${PREFIX} $testno: pazpar2 terminated (timeout, probably)"
243 echo "${PREFIX} $testno: pazpar2 died"
250 if [ "$WAIT_PAZPAR2" ] ; then
252 while test $i -lt $WAIT_PAZPAR2; do
260 if test -f ztest.pid; then
265 if [ -z "$SKIP_PAZPAR2" ] ; then