2 # Tests reading of ISO2709 and checks that we get identical MARCXML
4 # Reads marc?.marc files , Generates marc*.xml files
5 # If Libxml2 is present, also turbomarc*xml.
6 # as well as reverse transformation from *marc*.xml files are parsed again..
11 ../util/yaz-marcdump -i marcxml >/dev/null 2>&1
12 if test $? = "3"; then
16 ../util/yaz-marcdump -o xml,marcxml >/dev/null 2>&1
17 if test $? = "4"; then
26 for f in ${srcdir}/marc[0-9].marc; do
27 fb=`basename ${f} .marc`
28 CHR=`cat ${srcdir}/${fb}.chr`
29 NEW=${PREFIX}${fb}.new.${SUFFIX}
30 OLD=${srcdir}/${PREFIX}${fb}.${SUFFIX}
31 DIFF=`basename ${f}`.diff
32 ../util/yaz-marcdump -f $CHR -t utf-8 -i marc -o ${OUTPUT_FORMAT} $f > $NEW
33 if test $? != "0"; then
34 echo "$f: yaz-marcdump returned error"
36 elif test -f $OLD; then
37 if diff $OLD $NEW >$DIFF; then
41 echo "$f: $NEW and $OLD differ"
45 echo "$f: Making test result $OLD for the first time"
46 if test "$SUFFIX" = "xml"; then
47 if test -x /usr/bin/xmllint; then
48 if xmllint --noout $NEW >out 2>stderr; then
49 echo "$f: $NEW is well-formed"
52 echo "$f: $NEW not well-formed"
56 echo "xmllint not found. install libxml2-utils"
59 elif test "$SUFFIX" = "json"; then
60 if ../util/yaz-json-parse < $NEW >out 2>stderr; then
61 echo "$f: $NEW is JSON OK"
64 echo "$f: $NEW is NOT JSON OK"
68 echo "Bad suffix $SUFFIX"
73 if test -z "$noxml"; then
76 # compare with original (binary) marc record.
78 NEW=`basename ${f}`.new.marc
79 DIFF=`basename ${f}`.diff
80 # echo "../util/yaz-marcdump -f utf-8 -t utf-8 -i ${REVERT_FORMAT} -o marc $f > $NEW"
81 ../util/yaz-marcdump -f utf-8 -t utf-8 -i ${REVERT_FORMAT} -o marc $f > $NEW
82 if test $? != "0"; then
83 echo "Failed decode of $f"
85 elif test -f $OLD; then
86 if diff $OLD $NEW >$DIFF; then
90 echo "$f: $NEW and $OLD Differ"
94 echo "$f: Making test result $OLD for the first time"
98 REVERT=`basename ${f}`.marc.revert
99 #../util/yaz-marcdump -f utf-8 -t $CHR -i ${REVERT_FORMAT} -o marc $f > $REVERT
100 #hexdump -cx $REVERT > $REVERT.hex
101 #hexdump -cx $ORIGINAL > $ORIGINAL.hex
102 #diff $REVERT.hex $ORIGINAL.hex > $REVERT.diff
108 binmarc_convert "marcxml" "marcxml" "" xml
109 echo "binmarc -> marcxml: $?"
111 if test -z "$noxmlwrite"; then
112 binmarc_convert "xml,marcxml" "marcxml" "xml2" xml
113 echo "binmarc -> marcxml(libxml2): $?"
116 binmarc_convert "turbomarc" "turbomarc" "t" xml
117 echo "binmarc -> turbomarc: $?"
119 if test -z "$noxmlwrite"; then
120 binmarc_convert "xml,turbomarc" "turbomarc" "xml2t" xml
121 echo "binmarc -> turbomarc(libxml2): $?"
124 binmarc_convert "json" "json" "" json
125 echo "binmarc -> json: $?"