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 -n "$SLEEP_PID"; then
28 while test $# -gt 0; do
30 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
51 if test "x${PREFIX}" = "x"; then
52 echo Missing prefix for run_pazpar2.sh
56 # look for curl in PATH
61 if test -x $p/curl; then
68 if test -z $curl; then
69 echo "curl not found. $PREFIX can not be tested"
73 if test "$ztest" = "true" ; then
78 if test -x $p/yaz-ztest -a -x $p/yaz-client; then
79 VERSION=`$p/yaz-client -V|awk '{print $3;}'|awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
80 if test $VERSION -ge 4002052; then
88 echo "yaz-ztest not found"
92 rm -f ${PREFIX}_ztest.log
93 $F -l ${PREFIX}_ztest.log -p ztest.pid -D tcp:localhost:9999
95 if test ! -f ztest.pid; then
96 echo "yaz-ztest could not be started"
101 GET='$curl --silent --output $OUT2 "$f"'
102 POST='$curl --silent --header "Content-Type: text/xml" --data-binary "@$postfile" --output $OUT2 "$f"'
104 if test "$icu" = "true"; then
105 if ../src/pazpar2 -V |grep icu:enabled >/dev/null; then
112 # remove log if starting pazpar2
113 if [ -z "$SKIP_PAZPAR2" ] ; then
114 rm -f ${PREFIX}_pazpar2.log
119 VALGRINDLOG=${PREFIX}_valgrind.log
121 if test `uname` = "Linux"; then
128 LEVELS=loglevel,fatal,warn,log,debug,notime,zoom,zoomdetails
129 if test -n "$PAZPAR2_USE_VALGRIND"; then
130 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 &
133 elif test -n "$SKIP_PAZPAR2"; then
134 echo "Skipping pazpar2. Must already be running with correct config!!! "
136 ../src/pazpar2 -v $LEVELS -d -X -l ${PREFIX}_pazpar2.log -f ${srcdir}/${CFG} >${PREFIX}_extra_pazpar2.log 2>&1 &
141 if [ -z "$SKIP_PAZPAR2" -a -z "$WAIT_PAZPAR2" ] ; then
142 if ps -p $PP2PID >/dev/null 2>&1; then
143 (sleep $WAIT; kill_pazpar2 >/dev/null) &
145 trap kill_pazpar2 INT
146 trap kill_pazpar2 HUP
148 echo "pazpar2 failed to start"
149 if test -f ztest.pid; then
157 # Set to success by default.. Will be set to non-zero in case of failure
160 # We can start test for real
163 for f in `cat ${srcdir}/${URLS}`; do
164 if echo $f | grep '^http' >/dev/null; then
165 OUT1=${srcdir}/${PREFIX}_${testno}.res
166 OUT2=${PREFIX}_${testno}.log
167 DIFF=${PREFIX}_${testno}.dif
169 if [ -n "$DEBUG" ] ; then
170 echo "test $testno: $f"
172 while test $rounds -gt 0; do
173 if test -n "${postfile}"; then
178 if test ! -f $OUT2; then
181 rounds=`expr $rounds - 1`
182 if test -f $OUT1 -a -z "$PAZPAR2_OVERRIDE_TEST"; then
183 if diff $OUT1 $OUT2 >$DIFF; then
188 if test $rounds -eq 0; then
189 echo "Test $testno: Failed. See $OUT1, $OUT2 and $DIFF"
195 if test $rounds -eq 0; then
196 echo "Test $testno: Making for the first time"
201 if test $rounds -gt 0; then
205 testno=`expr $testno + 1`
208 elif echo $f | grep '^[0-9]' >/dev/null; then
211 if test -f $srcdir/$f; then
214 echo "File $f does not exist"
218 if [ -z "$SKIP_PAZPAR2" ] ; then
219 if ps -p $PP2PID >/dev/null 2>&1; then
223 if test -n "$SLEEP_PID"; then
224 echo "Test $testno: pazpar2 terminated (timeout, probably)"
226 echo "Test $testno: pazpar2 died"
233 if [ "$WAIT_PAZPAR2" ] ; then
235 while test $i -lt $WAIT_PAZPAR2; do
243 if test -f ztest.pid; then
248 if [ -z "$SKIP_PAZPAR2" ] ; then