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 "Test $PREFIX: curl not found"
77 if test "$icu" = "true"; then
78 if ../src/pazpar2 -V |grep icu:enabled >/dev/null; then
81 echo "Skipping test ${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 if test -z "$F"; then
101 echo "Skipping test ${PREFIX}: recent yaz-ztest not found"
105 rm -f ${PREFIX}_ztest.log
106 $F -l ${PREFIX}_ztest.log -p ztest.pid -D tcp:localhost:9999
108 if test ! -f ztest.pid; then
109 echo "yaz-ztest could not be started"
114 # remove log if starting pazpar2
115 if [ -z "$SKIP_PAZPAR2" ] ; then
116 rm -f ${PREFIX}_pazpar2.log
121 VALGRINDLOG=${PREFIX}_valgrind.log
123 if test `uname` = "Linux"; then
130 LEVELS=loglevel,fatal,warn,log,debug,notime,zoom,zoomdetails
131 if test -n "$PAZPAR2_USE_VALGRIND"; then
132 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 &
136 elif test -n "$SKIP_PAZPAR2"; then
137 echo "Test ${PREFIX}: not starting Pazpar2 (should be running already)"
139 ../src/pazpar2 -v $LEVELS -d -X -l ${PREFIX}_pazpar2.log -f ${srcdir}/${CFG} >${PREFIX}_extra_pazpar2.log 2>&1 &
144 if [ -z "$SKIP_PAZPAR2" -a -z "$WAIT_PAZPAR2" ] ; then
145 if ps -p $PP2PID >/dev/null 2>&1; then
146 (sleep $WAIT; kill_pazpar2 >/dev/null) &
148 trap kill_pazpar2 INT
149 trap kill_pazpar2 HUP
151 echo "Test ${PREFIX}: pazpar2 failed to start"
152 if test -f ztest.pid; then
160 GET='$curl --silent --output $OUT2 "$f"'
161 POST='$curl --silent --header "Content-Type: text/xml" --data-binary "@$postfile" --output $OUT2 "$f"'
163 # Set to success by default.. Will be set to non-zero in case of failure
166 # We can start test for real
169 for f in `cat ${srcdir}/${URLS}`; do
170 if echo $f | grep '^http' >/dev/null; then
171 OUT1=${srcdir}/${PREFIX}_${testno}.res
172 OUT2=${PREFIX}_${testno}.log
173 DIFF=${PREFIX}_${testno}.dif
175 if [ -n "$DEBUG" ] ; then
176 echo "test $testno: $f"
178 while test $rounds -gt 0; do
179 if test -n "${postfile}"; then
184 if test ! -f $OUT2; then
187 rounds=`expr $rounds - 1`
188 if test -f $OUT1 -a -z "$PAZPAR2_OVERRIDE_TEST"; then
189 if diff $OUT1 $OUT2 >$DIFF 2>/dev/null; then
194 if test $rounds -eq 0; then
195 echo "Test $testno: Failed. See $OUT1, $OUT2 and $DIFF"
201 if test $rounds -eq 0; then
202 echo "Test $testno: Making for the first time"
207 if test $rounds -gt 0; then
211 testno=`expr $testno + 1`
214 elif echo $f | grep '^[0-9]' >/dev/null; then
217 if test -f $srcdir/$f; then
220 echo "File $f does not exist"
224 if [ -z "$SKIP_PAZPAR2" ] ; then
225 if ps -p $PP2PID >/dev/null 2>&1; then
229 if test -n "$SLEEP_PID"; then
230 echo "Test $testno: pazpar2 terminated (timeout, probably)"
232 echo "Test $testno: pazpar2 died"
239 if [ "$WAIT_PAZPAR2" ] ; then
241 while test $i -lt $WAIT_PAZPAR2; do
249 if test -f ztest.pid; then
254 if [ -z "$SKIP_PAZPAR2" ] ; then