Fixed bug #687: Missing log lines. Immediate logging (i.e. flush) is no
[yaz-moved-to-github.git] / test / tstmarciso.sh
1 #!/bin/sh
2 # $Id: tstmarciso.sh,v 1.3 2006-08-28 12:34:42 adam Exp $
3 # Tests reading of ISO2709 and checks that we get identical MARCXML
4
5 # Reads marc?.marc files , Generates marc?.xml files
6 srcdir=${srcdir:-.}
7 ecode=0
8 for f in ${srcdir}/marc?.marc; do
9     fb=`basename ${f} .marc`
10     CHR=${srcdir}/${fb}.chr
11     NEW=${fb}.new.xml
12     OLD=${srcdir}/${fb}.xml
13     DIFF=`basename ${f}`.diff
14     ../util/yaz-marcdump -f `cat $CHR` -t utf-8 -X $f > $NEW
15     if test $? != "0"; then
16         echo "$f: yaz-marcdump returned error"
17         ecode=1
18     elif test -f $OLD; then
19         if diff $OLD $NEW >$DIFF; then
20             rm $DIFF
21             rm $NEW
22         else
23             echo "$f: $NEW and $OLD differ"
24             ecode=1
25         fi
26     else
27         echo "$f: Making test result $OLD for the first time"
28         if test -x /usr/bin/xmllint; then
29             if xmllint --noout $NEW >out 2>stderr; then
30                 echo "$f: $NEW is well-formed"
31                 mv $NEW $OLD
32             else
33                 echo "$f: $NEW not well-formed"
34                 ecode=1
35             fi
36         else
37             echo "xmllint not found. install libxml2-utils"
38             ecode=1
39         fi
40     fi
41 done
42 exit $ecode
43
44 # Local Variables:
45 # mode:shell-script
46 # sh-indentation: 2
47 # sh-basic-offset: 4
48 # End: