Make sure test only write to build directory to make distcheck happier.
[yaz-moved-to-github.git] / test / tstmarc.sh
1 #!/bin/sh
2 # $Id: tstmarc.sh,v 1.2 2004-11-16 17:12:28 adam Exp $
3 srcdir=${srcdir:-.}
4 ecode=0
5 for f in ${srcdir}/marc?; do
6     NEW=`basename ${f}`.new.xml
7     OLD=${f}.xml
8     DIFF=`basename ${f}`.diff
9     ../util/yaz-marcdump -f iso-8859-1 -t utf-8 -X $f > $NEW
10     if test $? != "0"; then
11         echo "Failed decode of $f"
12         ecode=1
13     elif test -f $OLD; then
14         if diff $OLD $NEW >$DIFF; then
15             rm $DIFF
16             rm $NEW
17         else
18             echo "Differ in $f"
19             ecode=1
20         fi
21     else
22         echo "Making test $f for the first time"
23         if test -x /usr/bin/xmllint; then
24             if xmllint --noout $NEW >out 2>stderr; then
25                 echo "XML for $f is OK"
26                 mv $NEW $OLD
27             else
28                 echo "XML for $f is invalid"
29                 ecode=1
30             fi
31         else
32             echo "xmllint not found. install libxml2-utils"
33             ecode=1
34         fi
35     fi
36 done
37 exit $ecode
38