9bf324d1716d814a294b0e6059aebf03e1828fb5
[yaz-moved-to-github.git] / test / tstmarciso.sh
1 #!/bin/sh
2 # $Id: tstmarciso.sh,v 1.1 2006-04-19 10:05:04 adam Exp $
3 # Tests reading of ISO2709 and checks that we get identical MARCXML
4 srcdir=${srcdir:-.}
5 ecode=0
6 for f in ${srcdir}/marc?; do
7     NEW=`basename ${f}`.new.xml
8     OLD=${f}.xml
9     DIFF=`basename ${f}`.diff
10     ../util/yaz-marcdump -f `cat ${f}.chr` -t utf-8 -X $f > $NEW
11     if test $? != "0"; then
12         echo "Failed decode of $f"
13         ecode=1
14     elif test -f $OLD; then
15         if diff $OLD $NEW >$DIFF; then
16             rm $DIFF
17             rm $NEW
18         else
19             echo "Differ in $f"
20             ecode=1
21         fi
22     else
23         echo "Making test $f for the first time"
24         if test -x /usr/bin/xmllint; then
25             if xmllint --noout $NEW >out 2>stderr; then
26                 echo "XML for $f is OK"
27                 mv $NEW $OLD
28             else
29                 echo "XML for $f is invalid"
30                 ecode=1
31             fi
32         else
33             echo "xmllint not found. install libxml2-utils"
34             ecode=1
35         fi
36     fi
37 done
38 exit $ecode
39