Fix problem with HTTP decoding
[yaz-moved-to-github.git] / test / tstpqf2cql.sh
1 #!/bin/sh
2 srcdir=${srcdir:-.}
3 oIFS="$IFS"
4 IFS='
5 '
6 secno=0
7 testno=0
8 comment=0
9 ecode=0
10 test -f ${srcdir}/pqf2cqlsample || exit 1
11 test -d pqf2cql || mkdir pqf2cql
12 for f in `cat ${srcdir}/pqf2cqlsample`; do
13         if echo $f | grep '^#' >/dev/null; then
14                 comment=1
15         else
16                 if test "$comment" = "1"; then
17                         secno=`expr $secno + 1`
18                         testno=0
19                 fi
20                 comment=0
21                 testno=`expr $testno + 1`
22                 OUT1=${srcdir}/pqf2cql/$secno.$testno.out
23                 ERR1=${srcdir}/pqf2cql/$secno.$testno.err
24                 OUT2=pqf2cql/$secno.$testno.out.tmp
25                 ERR2=pqf2cql/$secno.$testno.err.tmp
26                 DIFF=pqf2cql/$secno.$testno.diff
27                 ../util/cql2pqf -r - "$f" >$OUT2 2>$ERR2
28                 if test -f $OUT1 -a -f $ERR1; then
29                         if diff $OUT1 $OUT2 >$DIFF; then
30                                 rm $DIFF
31                                 rm $OUT2
32                         else
33                                 echo "diff out $secno $testno $f"
34                                 cat $DIFF
35                                 ecode=1 
36                         fi
37                         if diff $ERR1 $ERR2 >$DIFF; then
38                                 rm $DIFF
39                                 rm $ERR2
40                         else
41                                 echo "diff err $secno $testno $f"
42                                 cat $DIFF
43                                 ecode=1
44                         fi
45                 else
46                         echo "making test $secno $testno $f"
47                         mv $OUT2 $OUT1
48                         mv $ERR2 $ERR1
49                         ecode=1
50                 fi      
51         fi              
52 done
53 IFS="$oIFS"
54 exit $ecode