diff --git a/Makefile b/Makefile index e60408dc..d5335db5 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,8 @@ mostlyclean clean: config/config.mk # for packaging. distclean: clean rm -f config.log config.status libtool - rm -f *~ *.bak *# + rm -f *~ *.bak + rm -rf bin # This removes almost everything, including the configure script! maintainer-clean: distclean diff --git a/samples/Makefile b/samples/Makefile index b41163ac..27a67e61 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -60,16 +60,13 @@ BINSRC = addmoddel.cpp \ exifcomment.cpp \ exifdata-test.cpp \ exifprint.cpp \ - geotag.cpp \ iotest.cpp \ iptceasy.cpp \ iptcprint.cpp \ iptctest.cpp \ key-test.cpp \ largeiptc-test.cpp \ - metacopy.cpp \ mmap-test.cpp \ - path-test.cpp \ prevtest.cpp \ stringto-test.cpp \ taglist.cpp \ diff --git a/test/addmoddel.sh b/test/addmoddel.sh index 481697fe..c15a130a 100755 --- a/test/addmoddel.sh +++ b/test/addmoddel.sh @@ -1,30 +1,14 @@ -#! /bin/sh +#!/bin/bash # Test driver to run the addmoddel sample program -results="./tmp/addmoddel.out" -good="./data/addmoddel.out" -diffargs="--strip-trailing-cr" -tmpfile=tmp/ttt -touch $tmpfile -diff -q $diffargs $tmpfile $tmpfile 2>/dev/null -if [ $? -ne 0 ] ; then - diffargs="" -fi +source ./functions.source + ( -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -cp -f ./data/exiv2-empty.jpg ./tmp -cd ./tmp -$bin/addmoddel exiv2-empty.jpg -$bin/exiv2 -pv exiv2-empty.jpg + copyTestFile exiv2-empty.jpg + runTest addmoddel exiv2-empty.jpg + runTest exiv2 -pv exiv2-empty.jpg ) > $results -diff -q $diffargs $results $good -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff $diffargs $results $good -fi +reportTest + +# That's all Folks! +## \ No newline at end of file diff --git a/test/bugfixes-test.sh b/test/bugfixes-test.sh index 601473ee..16f40002 100755 --- a/test/bugfixes-test.sh +++ b/test/bugfixes-test.sh @@ -1,257 +1,233 @@ -#! /bin/sh +#!/bin/bash # Test driver with regression tests for bugfixes -export LC_ALL=C -results="./tmp/bugfixes-test.out" -good="./data/bugfixes-test.out" - -prep_file() -{ - echo `prep_any_file $1 exiv2-bug$1.jpg` -} - -prep_empty_file() -{ - echo `prep_any_file $1 exiv2-empty.jpg` -} - -prep_any_file() -{ - printf "$1 " >&3 - echo '------>' Bug $1 '<-------' >&2 - cp -f ../data/$2 exiv2-bug$1.jpg - echo exiv2-bug$1.jpg -} + +source ./functions.source ( -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -cd ./tmp - -num=426 -filename=`prep_file $num` -$bin/exiv2 -u -pi $filename - -num=440 -filename=`prep_file $num` -$bin/exiv2 -u -pi $filename - -num=443 -filename=`prep_file $num` -$bin/exiv2 -u -b -pt $filename - -num=444 -filename=`prep_file $num` -$bin/exiv2 -u -pi $filename - -num=445 -filename=`prep_file $num` -$bin/exiv2 -u -v -M'set Exif.Photo.UserComment A comment' $filename -$bin/exiv2 -u -b -pt $filename -filename=exiv2-empty.jpg -cp -f ../data/$filename . -$bin/exiv2 -u -v -M'set Exif.Photo.UserComment A comment' $filename -$bin/exiv2 -u -b -pt $filename - -num=447 # Problem only visible in Valgrind -filename=`prep_file $num` -$bin/exiv2 -u -pi $filename - -num=452 -filename=`prep_empty_file $num` -$bin/exiv2 -u -v -M"set Exif.GPSInfo.GPSLatitude SRational -1/3 -2/3 -3/3" $filename -$bin/exiv2 -u -pv $filename -$bin/exiv2 -u -v -M"set Exif.GPSInfo.GPSLatitude Rational 1/3 2/3 3/3" $filename -$bin/exiv2 -u -pv $filename - -num=460 -filename=`prep_file $num` -$bin/exiv2 -u -pt $filename - -num=479 -filename=`prep_file $num` -$bin/exiv2 -u -pt $filename - -num=480 -filename=`prep_file $num` -$bin/largeiptc-test $filename ../data/imagemagick.png - -num=495 -filename=`prep_file $num` -$bin/exiv2 -u -pi $filename - -num=498 -filename=`prep_empty_file $num` -$bin/exiv2 -u -v -M"set Exif.GPSInfo.GPSLatitude 0/1 1/1 2/1" $filename -$bin/exiv2 -u -v -pv $filename -$bin/exiv2 -u -v -M"del Exif.GPSInfo.GPSLatitude" $filename -$bin/exiv2 -u -v -pv $filename - -num=501 -filename=`prep_file $num` -$bin/exiv2 -u -pi $filename - -num=528 -filename=`prep_file $num` -$bin/exiv2 -u -pt $filename -$bin/exiv2 -u -v -M"set Exif.Image.Software GI" $filename - -num=540 -filename=`prep_file $num` -$bin/exiv2 -u -px $filename - -num=554 -filename=`prep_empty_file $num` -$bin/exiv2 -u -v -M"set Exif.Image.DateTime Date 2007-05-27" $filename -$bin/exiv2 -u -pt $filename - -num=662 -filename=`prep_empty_file $num` - -$bin/exiv2 -u -M"set Exif.Photo.UserComment charset=Ascii An ascii comment" $filename -$bin/exiv2 -u -PEnh $filename - -$bin/exiv2 -u -M"set Exif.Photo.UserComment charset=Ascii A\\nnewline" $filename -$bin/exiv2 -u -PEnh $filename - -$bin/exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode A Unicode comment" $filename -$bin/exiv2 -u -PEnh $filename - -$bin/exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode \\u01c4" $filename -$bin/exiv2 -u -PEnh $filename - -$bin/exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode A\\u01c4C" $filename -$bin/exiv2 -u -PEnh $filename - -$bin/exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode With\\nNewline" $filename -$bin/exiv2 -u -PEnh $filename - -$bin/exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode With\\tTab" $filename -$bin/exiv2 -u -PEnh $filename - -# Test invalid escape sequences -$bin/exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode \\ugggg" $filename -$bin/exiv2 -u -PEnh $filename - -num=666 -filename=`prep_empty_file $num` + cd ./tmp + + num=426 + filename=`prep_file $num` + runTest exiv2 -u -pi $filename + + num=440 + filename=`prep_file $num` + runTest exiv2 -u -pi $filename + + num=443 + filename=`prep_file $num` + runTest exiv2 -u -b -pt $filename + + num=444 + filename=`prep_file $num` + runTest exiv2 -u -pi $filename + + num=445 + filename=`prep_file $num` + runTest exiv2 -u -v -M'set Exif.Photo.UserComment A comment' $filename + runTest exiv2 -u -b -pt $filename + filename=exiv2-empty.jpg + copyTestFile $filename + runTest exiv2 -u -v -M'set Exif.Photo.UserComment A comment' $filename + runTest exiv2 -u -b -pt $filename + + num=447 # Problem only visible in Valgrind + filename=`prep_file $num` + runTest exiv2 -u -pi $filename + + num=452 + filename=`prep_empty_file $num` + runTest exiv2 -u -v -M"set Exif.GPSInfo.GPSLatitude SRational -1/3 -2/3 -3/3" $filename + runTest exiv2 -u -pv $filename + runTest exiv2 -u -v -M"set Exif.GPSInfo.GPSLatitude Rational 1/3 2/3 3/3" $filename + runTest exiv2 -u -pv $filename + + num=460 + filename=`prep_file $num` + runTest exiv2 -u -pt $filename + + num=479 + filename=`prep_file $num` + runTest exiv2 -u -pt $filename + + num=480 + filename=`prep_file $num` + runTest largeiptc-test $filename ../data/imagemagick.png + + num=495 + filename=`prep_file $num` + runTest exiv2 -u -pi $filename + + num=498 + filename=`prep_empty_file $num` + runTest exiv2 -u -v -M"set Exif.GPSInfo.GPSLatitude 0/1 1/1 2/1" $filename + runTest exiv2 -u -v -pv $filename + runTest exiv2 -u -v -M"del Exif.GPSInfo.GPSLatitude" $filename + runTest exiv2 -u -v -pv $filename + + num=501 + filename=`prep_file $num` + runTest exiv2 -u -pi $filename -$bin/exiv2 -u -v -M'set Exif.Image.Make NIKON' \ + num=528 + filename=`prep_file $num` + runTest exiv2 -u -pt $filename + runTest exiv2 -u -v -M"set Exif.Image.Software GI" $filename + + num=540 + filename=`prep_file $num` + runTest exiv2 -u -px $filename + + num=554 + filename=`prep_empty_file $num` + runTest exiv2 -u -v -M"set Exif.Image.DateTime Date 2007-05-27" $filename + runTest exiv2 -u -pt $filename + + num=662 + filename=`prep_empty_file $num` + + runTest exiv2 -u -M"set Exif.Photo.UserComment charset=Ascii An ascii comment" $filename + runTest exiv2 -u -PEnh $filename + + runTest exiv2 -u -M"set Exif.Photo.UserComment charset=Ascii A\\nnewline" $filename + runTest exiv2 -u -PEnh $filename + + runTest exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode A Unicode comment" $filename + runTest exiv2 -u -PEnh $filename + + runTest exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode \\u01c4" $filename + runTest exiv2 -u -PEnh $filename + + runTest exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode A\\u01c4C" $filename + runTest exiv2 -u -PEnh $filename + + runTest exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode With\\nNewline" $filename + runTest exiv2 -u -PEnh $filename + + runTest exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode With\\tTab" $filename + runTest exiv2 -u -PEnh $filename + + # Test invalid escape sequences + runTest exiv2 -u -M"set Exif.Photo.UserComment charset=Unicode \\ugggg" $filename + runTest exiv2 -u -PEnh $filename + + num=666 + filename=`prep_empty_file $num` + + runTest exiv2 -u -v -M'set Exif.Image.Make NIKON' \ -M'set Exif.Image.Model D90' \ -M'set Exif.Nikon3.ShutterCount 100' \ -M'set Exif.Nikon3.SerialNumber 123' \ -M'set Exif.NikonSi02xx.Version 48 50 51 52' \ -M'set Exif.NikonSi02xx.ShutterCount 100' $filename -$bin/exiv2 -u -pa -u -b $filename - -num=683 -filename=`prep_any_file $num exiv2-nikon-d70.jpg` -rm -f 2004-03-30-Tue-090.jpg -$bin/exiv2 -u -f -r %Y-%m-%d-%a-%j $filename -ls 2004-03-30-Tue-090.jpg - -num=711 -printf "$num " >&3 -# Little endian (II) -filename=exiv2-bug${num}-1.jpg -cp -f ../data/exiv2-empty.jpg $filename -echo '------>' Bug $num '<-------' >&2 -$bin/exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Initial values, read from the command line' \ - -M'set Exif.Image.DocumentName Float 0.12345' \ - -M'set Exif.Image.ImageDescription Double 0.987654321' $filename -$bin/exiv2 -u -v -PEkyct $filename -$bin/exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Non-intrusive update' $filename -$bin/exiv2 -u -v -PEkyct $filename -$bin/exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Intrusive update, writing the structure from scratch' $filename -$bin/exiv2 -u -v -PEkyct $filename -# Big endian (MM) -filename=exiv2-bug${num}-2.jpg -cp -f ../data/exiv2-kodak-dc210.jpg $filename -$bin/exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Initial values, read from the command line' \ - -M'set Exif.Image.DocumentName Float 0.12345' \ - -M'set Exif.Image.ImageDescription Double 0.987654321' $filename -$bin/exiv2 -u -v -PEkyct $filename -$bin/exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Non-intrusive update' $filename -$bin/exiv2 -u -v -PEkyct $filename -$bin/exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Intrusive update, writing the structure from scratch' $filename -$bin/exiv2 -u -v -PEkyct $filename - -# Test easy-access keys (using a dummy bug number) -if { test -f $bin/easyaccess-test || test -f $bin/easyaccess-test.exe; }; then - num=726 - filename=`prep_empty_file $num` - $bin/exiv2 -u -v -M"set Exif.Image.Make Samsung" $filename - $bin/easyaccess-test $filename -else - echo "bugfixes-test.sh: easyaccess-test executable not found. Skipping regression test for issue #726." -fi - -# Test 'migration of XMP namespaces' (see #751 and related forum post) -num=751 -filename=`prep_empty_file $num` -xmpname=exiv2-bug$num.xmp -$bin/exiv2 -v -M'reg imageapp orig/' -M 'set Xmp.imageapp.uuid abcd' $filename -$bin/exiv2 -f -eX $filename -cat $xmpname -$bin/exiv2 -v -M'reg imageapp dest/' -M 'set Xmp.imageapp.uuid abcd' $filename -$bin/exiv2 -f -eX $filename -cat $xmpname - -num=769 -filename=`prep_empty_file $num` -$bin/exiv2 -u -v -M"add Exif.Image.Make Canon" -M"add Exif.CanonCs.0x0001 Short 1" -M"add Exif.CanonCs.0x0000 Short 2" $filename -$bin/exiv2 -u -v -PEkyct $filename - -num=799 -filename=`prep_empty_file $num` -$bin/exiv2 -v -m ../data/bug$num.cmd $filename -$bin/exiv2 -v -pa $filename -$bin/exiv2 -f -eX $filename -cat exiv2-bug$num.xmp - -num=800 -printf "$num " >&3 -for type in 8BIM AgHg DCSR PHUT; do - for format in jpg psd; do - echo "------> Bug $num ($type in $format) <-------" >&2 - filename=exiv2-bug$num-$type.$format - cp -f ../data/$filename . - $bin/exiv2 -u -v -M'set Exif.Photo.UserComment Test' $filename - $bin/exiv2 -u -pt $filename - done -done - -num=831 -filename=exiv2-bug$num.tif -printf "$num " >&3 -echo '------>' Bug $num '<-------' >&2 -cp -f ../data/mini9.tif $filename -$bin/exiv2 -v -Qd -M'set Exif.Image.ImageDescription Just GIMP' $filename -$bin/exiv2 -v -pa $filename - -num=836 -filename=exiv2-bug$num.eps -echo '------>' Bug $num '<-------' >&2 -cp -f ../data/$filename $filename -if [ -e $filename/rsrc ]; then - printf "$num " >&3 - cp -f ../data/$filename.rsrc $filename/rsrc - $bin/exiv2 -M'set Exif.Photo.UserComment Test' $filename - diff -q ../data/$filename.rsrc $filename/rsrc -else - # skip this test on systems which do not have resource forks - printf "($num skipped) " >&3 -fi - -num=841 -filename=exiv2-bug$num.png -printf "$num " >&3 -echo '------>' Bug $num '<-------' >&2 -cp -f ../data/$filename $filename -$bin/exiv2 $filename + runTest exiv2 -u -pa -u -b $filename + + num=683 + filename=`prep_any_file $num exiv2-nikon-d70.jpg` + rm -f 2004-03-30-Tue-090.jpg + runTest exiv2 -u -f -r %Y-%m-%d-%a-%j $filename + ls 2004-03-30-Tue-090.jpg + + num=711 + printf "$num " >&3 + # Little endian (II) + filename=exiv2-bug${num}-1.jpg + copyTestFile exiv2-empty.jpg $filename + echo '------>' Bug $num '<-------' >&2 + runTest exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Initial values, read from the command line' \ + -M'set Exif.Image.DocumentName Float 0.12345' \ + -M'set Exif.Image.ImageDescription Double 0.987654321' $filename + runTest exiv2 -u -v -PEkyct $filename + runTest exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Non-intrusive update' $filename + runTest exiv2 -u -v -PEkyct $filename + runTest exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Intrusive update, writing the structure from scratch' $filename + runTest exiv2 -u -v -PEkyct $filename + # Big endian (MM) + filename=exiv2-bug${num}-2.jpg + copyTestFile exiv2-kodak-dc210.jpg $filename + runTest exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Initial values, read from the command line' \ + -M'set Exif.Image.DocumentName Float 0.12345' \ + -M'set Exif.Image.ImageDescription Double 0.987654321' $filename + runTest exiv2 -u -v -PEkyct $filename + runTest exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Non-intrusive update' $filename + runTest exiv2 -u -v -PEkyct $filename + runTest exiv2 -u -v -M'set Exif.Image.ProcessingSoftware Intrusive update, writing the structure from scratch' $filename + runTest exiv2 -u -v -PEkyct $filename + + # Test easy-access keys (using a dummy bug number) + if [ 1 = $(existsTest easyaccess-test) ]; then + num=726 + filename=`prep_empty_file $num` + runTest exiv2 -u -v -M"set Exif.Image.Make Samsung" $filename + runTest easyaccess-test $filename + else + echo "bugfixes-test.sh: easyaccess-test executable not found. Skipping regression test for issue #726." + fi + + # Test 'migration of XMP namespaces' (see #751 and related forum post) + num=751 + filename=`prep_empty_file $num` + xmpname=exiv2-bug$num.xmp + runTest exiv2 -v -M'reg imageapp orig/' -M 'set Xmp.imageapp.uuid abcd' $filename + runTest exiv2 -f -eX $filename + cat $xmpname + runTest exiv2 -v -M'reg imageapp dest/' -M 'set Xmp.imageapp.uuid abcd' $filename + runTest exiv2 -f -eX $filename + cat $xmpname + + num=769 + filename=`prep_empty_file $num` + runTest exiv2 -u -v -M"add Exif.Image.Make Canon" -M"add Exif.CanonCs.0x0001 Short 1" -M"add Exif.CanonCs.0x0000 Short 2" $filename + runTest exiv2 -u -v -PEkyct $filename + + num=799 + filename=`prep_empty_file $num` + runTest exiv2 -v -m ../data/bug$num.cmd $filename + runTest exiv2 -v -pa $filename + runTest exiv2 -f -eX $filename + cat exiv2-bug$num.xmp + + num=800 + printf "$num " >&3 + for type in 8BIM AgHg DCSR PHUT; do + for format in jpg psd; do + echo "------> Bug $num ($type in $format) <-------" >&2 + filename=exiv2-bug$num-$type.$format + copyTestFile $filename + runTest exiv2 -u -v -M'set Exif.Photo.UserComment Test' $filename + runTest exiv2 -u -pt $filename + done + done + + num=831 + filename=exiv2-bug$num.tif + printf "$num " >&3 + echo '------>' Bug $num '<-------' >&2 + copyTestFile mini9.tif $filename + runTest exiv2 -v -Qd -M'set Exif.Image.ImageDescription Just GIMP' $filename + runTest exiv2 -v -pa $filename + + num=836 + filename=exiv2-bug$num.eps + echo '------>' Bug $num '<-------' >&2 + copyTestFile $filename $filename + if [ -e $filename/rsrc ]; then + printf "$num " >&3 + copyTestFile $filename.rsrc $filename/rsrc + runTest exiv2 -M'set Exif.Photo.UserComment Test' $filename + diff -q ../data/$filename.rsrc $filename/rsrc + else + # skip this test on systems which do not have resource forks + printf "($num skipped) " >&3 + fi + + num=841 + filename=exiv2-bug$num.png + printf "$num " >&3 + echo '------>' Bug $num '<-------' >&2 + copyTestFile $filename + runTest exiv2 $filename ) 3>&1 > $results 2>&1 @@ -260,10 +236,7 @@ printf "\n" # ---------------------------------------------------------------------- # Evaluate results cat $results | sed 's/\x0d$//' > $results-stripped -diff -q $results-stripped $good -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff -u $good $results-stripped -fi +reportTest $results-stripped $good + +# That's all Folks! +## \ No newline at end of file diff --git a/test/conversions.sh b/test/conversions.sh index 67dcd11b..0eb0dcf8 100755 --- a/test/conversions.sh +++ b/test/conversions.sh @@ -1,21 +1,13 @@ -#! /bin/sh +#!/bin/bash # XMP parser test driver # ---------------------------------------------------------------------- # Setup -export LC_ALL=C -results="./conversions.out" -good="../data/conversions.out" -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -cd ./tmp +source ./functions.source # ---------------------------------------------------------------------- # Check if xmpparser-test exists -if [ ! -e ../../bin/xmpparser-test -a ! -e "$EXIV2_BINDIR/xmpparser-test" ] ; then +if [ $(existsTest xmpparser-test) == 0 ] ; then echo "xmpparser-test not found. Assuming XMP support is not enabled." exit 0 fi @@ -23,18 +15,19 @@ fi # ---------------------------------------------------------------------- # Main routine ( +cd ./tmp IMG=../data/exiv2-empty.jpg # 1) Convert Exif ImageDescription to XMP x-default langAlt value echo Testcase 1 echo ========== \cp $IMG h.jpg -$bin/exiv2 -M'set Exif.Image.ImageDescription The Exif image description' h.jpg +runTest exiv2 -M'set Exif.Image.ImageDescription The Exif image description' h.jpg rm -f h.xmp -$bin/exiv2 -eX h.jpg -$bin/exiv2 -px h.xmp -$bin/exiv2 -PEkycv h.xmp -$bin/exiv2 -pi h.xmp +runTest exiv2 -eX h.jpg +runTest exiv2 -px h.xmp +runTest exiv2 -PEkycv h.xmp +runTest exiv2 -pi h.xmp # 2) Convert XMP x-default langAlt value back to Exif ImageDescription echo @@ -42,10 +35,10 @@ echo Testcase 2 echo ========== \cp $IMG i.jpg \cp h.xmp i.xmp -$bin/exiv2 -iX i.jpg -$bin/exiv2 -px i.jpg -$bin/exiv2 -PEkycv i.jpg -$bin/exiv2 -pi i.jpg +runTest exiv2 -iX i.jpg +runTest exiv2 -px i.jpg +runTest exiv2 -PEkycv i.jpg +runTest exiv2 -pi i.jpg # 3) Convert XMP single non-x-default langAlt value to Exif ImageDescription echo @@ -53,10 +46,10 @@ echo Testcase 3 echo ========== sed s/x-default/de-DE/ i.xmp > j.xmp \cp $IMG j.jpg -$bin/exiv2 -iX j.jpg -$bin/exiv2 -px j.jpg -$bin/exiv2 -PEkycv j.jpg -$bin/exiv2 -pi j.jpg +runTest exiv2 -iX j.jpg +runTest exiv2 -px j.jpg +runTest exiv2 -PEkycv j.jpg +runTest exiv2 -pi j.jpg # 4) This shouldn't work: No x-default, more than one language echo @@ -64,36 +57,36 @@ echo Testcase 4 echo ========== sed 's,The Exif image description,The Exif image descriptionCiao bella,' j.xmp > k.xmp \cp $IMG k.jpg -$bin/exiv2 -iX k.jpg -$bin/exiv2 -px k.jpg -$bin/exiv2 -v -PEkycv k.jpg -$bin/exiv2 -v -pi k.jpg +runTest exiv2 -iX k.jpg +runTest exiv2 -px k.jpg +runTest exiv2 -v -PEkycv k.jpg +runTest exiv2 -v -pi k.jpg # 5) Add a default language to the XMP file and convert to Exif and IPTC echo echo Testcase 5 echo ========== \cp k.xmp l.xmp -$bin/exiv2 -M'set Xmp.dc.description lang="x-default" How to fix this mess' l.xmp +runTest exiv2 -M'set Xmp.dc.description lang="x-default" How to fix this mess' l.xmp grep x-default l.xmp \cp $IMG l.jpg -$bin/exiv2 -iX l.jpg -$bin/exiv2 -px l.jpg -$bin/exiv2 -PEkycv l.jpg -$bin/exiv2 -pi l.jpg +runTest exiv2 -iX l.jpg +runTest exiv2 -px l.jpg +runTest exiv2 -PEkycv l.jpg +runTest exiv2 -pi l.jpg # 6) Convert an Exif user comment to XMP echo echo Testcase 6 echo ========== \cp $IMG m.jpg -$bin/exiv2 -M'set Exif.Photo.UserComment charset=Jis This is a JIS encoded Exif user comment. Or was it?' m.jpg -$bin/exiv2 -PEkycv m.jpg +runTest exiv2 -M'set Exif.Photo.UserComment charset=Jis This is a JIS encoded Exif user comment. Or was it?' m.jpg +runTest exiv2 -PEkycv m.jpg rm -f m.xmp -$bin/exiv2 -eX m.jpg -$bin/exiv2 -px m.xmp -$bin/exiv2 -PEkycv m.xmp -$bin/exiv2 -v -pi m.xmp +runTest exiv2 -eX m.jpg +runTest exiv2 -px m.xmp +runTest exiv2 -PEkycv m.xmp +runTest exiv2 -v -pi m.xmp # 7) And back to Exif echo @@ -101,25 +94,25 @@ echo Testcase 7 echo ========== \cp $IMG n.jpg \cp m.xmp n.xmp -$bin/exiv2 -iX n.jpg -$bin/exiv2 -px n.jpg -$bin/exiv2 -PEkycv n.jpg -$bin/exiv2 -v -pi n.jpg +runTest exiv2 -iX n.jpg +runTest exiv2 -px n.jpg +runTest exiv2 -PEkycv n.jpg +runTest exiv2 -v -pi n.jpg # 8) Convert IPTC keywords to XMP echo echo Testcase 8 echo ========== \cp $IMG o.jpg -$bin/exiv2 -M'add Iptc.Application2.Keywords Sex' o.jpg -$bin/exiv2 -M'add Iptc.Application2.Keywords Drugs' o.jpg -$bin/exiv2 -M"add Iptc.Application2.Keywords Rock'n'roll" o.jpg -$bin/exiv2 -pi o.jpg +runTest exiv2 -M'add Iptc.Application2.Keywords Sex' o.jpg +runTest exiv2 -M'add Iptc.Application2.Keywords Drugs' o.jpg +runTest exiv2 -M"add Iptc.Application2.Keywords Rock'n'roll" o.jpg +runTest exiv2 -pi o.jpg rm -f o.xmp -$bin/exiv2 -eX o.jpg -$bin/exiv2 -px o.xmp -$bin/exiv2 -v -PEkycv o.xmp -$bin/exiv2 -pi o.xmp +runTest exiv2 -eX o.jpg +runTest exiv2 -px o.xmp +runTest exiv2 -v -PEkycv o.xmp +runTest exiv2 -pi o.xmp # 9) And back to IPTC echo @@ -127,23 +120,23 @@ echo Testcase 9 echo ========== \cp $IMG p.jpg \cp o.xmp p.xmp -$bin/exiv2 -iX p.jpg -$bin/exiv2 -px p.jpg -$bin/exiv2 -v -PEkycv p.jpg -$bin/exiv2 -pi p.jpg +runTest exiv2 -iX p.jpg +runTest exiv2 -px p.jpg +runTest exiv2 -v -PEkycv p.jpg +runTest exiv2 -pi p.jpg # 10) Convert an Exif tag to an XMP text value echo echo Testcase 10 echo =========== \cp $IMG q.jpg -$bin/exiv2 -M'set Exif.Image.Software Exiv2' q.jpg -$bin/exiv2 -PEkycv q.jpg +runTest exiv2 -M'set Exif.Image.Software Exiv2' q.jpg +runTest exiv2 -PEkycv q.jpg rm -f q.xmp -$bin/exiv2 -eX q.jpg -$bin/exiv2 -px q.xmp -$bin/exiv2 -PEkycv q.xmp -$bin/exiv2 -v -pi q.xmp +runTest exiv2 -eX q.jpg +runTest exiv2 -px q.xmp +runTest exiv2 -PEkycv q.xmp +runTest exiv2 -v -pi q.xmp # 11) And back to Exif echo @@ -151,23 +144,23 @@ echo Testcase 11 echo =========== \cp $IMG r.jpg \cp q.xmp r.xmp -$bin/exiv2 -iX r.jpg -$bin/exiv2 -px r.jpg -$bin/exiv2 -PEkycv r.jpg -$bin/exiv2 -v -pi r.jpg +runTest exiv2 -iX r.jpg +runTest exiv2 -px r.jpg +runTest exiv2 -PEkycv r.jpg +runTest exiv2 -v -pi r.jpg # 12) Convert an IPTC dataset to an XMP text value echo echo Testcase 12 echo =========== \cp $IMG s.jpg -$bin/exiv2 -M'set Iptc.Application2.SubLocation Kuala Lumpur' s.jpg -$bin/exiv2 -pi s.jpg +runTest exiv2 -M'set Iptc.Application2.SubLocation Kuala Lumpur' s.jpg +runTest exiv2 -pi s.jpg rm -f s.xmp -$bin/exiv2 -eX s.jpg -$bin/exiv2 -px s.xmp -$bin/exiv2 -v -PEkycv s.xmp -$bin/exiv2 -pi s.xmp +runTest exiv2 -eX s.jpg +runTest exiv2 -px s.xmp +runTest exiv2 -v -PEkycv s.xmp +runTest exiv2 -pi s.xmp # 13) And back to IPTC echo @@ -175,34 +168,34 @@ echo Testcase 13 echo =========== \cp $IMG t.jpg \cp s.xmp t.xmp -$bin/exiv2 -iX t.jpg -$bin/exiv2 -px t.jpg -$bin/exiv2 -v -PEkycv t.jpg -$bin/exiv2 -pi t.jpg +runTest exiv2 -iX t.jpg +runTest exiv2 -px t.jpg +runTest exiv2 -v -PEkycv t.jpg +runTest exiv2 -pi t.jpg # 14) Convert a few other tags of interest from Exif/IPTC to XMP echo echo Testcase 14 echo =========== \cp $IMG u.jpg -$bin/exiv2 -M'set Exif.Photo.DateTimeOriginal 2003:12:14 12:01:44' u.jpg -$bin/exiv2 -M'set Exif.Photo.SubSecTimeOriginal 999999999' u.jpg -$bin/exiv2 -M'set Exif.Photo.ExifVersion 48 50 50 49' u.jpg -$bin/exiv2 -M'set Exif.Photo.ComponentsConfiguration 1 2 3 0' u.jpg -$bin/exiv2 -M'set Exif.Photo.Flash 73' u.jpg -$bin/exiv2 -M'set Exif.GPSInfo.GPSLatitude 3/1 8/1 29734512/1000000' u.jpg -$bin/exiv2 -M'set Exif.GPSInfo.GPSLatitudeRef N' u.jpg -$bin/exiv2 -M'set Exif.GPSInfo.GPSVersionID 2 2 0 1' u.jpg -$bin/exiv2 -M'set Exif.GPSInfo.GPSTimeStamp 1/1 2/1 999999999/1000000000' u.jpg -$bin/exiv2 -M'set Iptc.Application2.DateCreated 2007-05-09' u.jpg - -$bin/exiv2 -PEkycv u.jpg -$bin/exiv2 -pi u.jpg +runTest exiv2 -M'set Exif.Photo.DateTimeOriginal 2003:12:14 12:01:44' u.jpg +runTest exiv2 -M'set Exif.Photo.SubSecTimeOriginal 999999999' u.jpg +runTest exiv2 -M'set Exif.Photo.ExifVersion 48 50 50 49' u.jpg +runTest exiv2 -M'set Exif.Photo.ComponentsConfiguration 1 2 3 0' u.jpg +runTest exiv2 -M'set Exif.Photo.Flash 73' u.jpg +runTest exiv2 -M'set Exif.GPSInfo.GPSLatitude 3/1 8/1 29734512/1000000' u.jpg +runTest exiv2 -M'set Exif.GPSInfo.GPSLatitudeRef N' u.jpg +runTest exiv2 -M'set Exif.GPSInfo.GPSVersionID 2 2 0 1' u.jpg +runTest exiv2 -M'set Exif.GPSInfo.GPSTimeStamp 1/1 2/1 999999999/1000000000' u.jpg +runTest exiv2 -M'set Iptc.Application2.DateCreated 2007-05-09' u.jpg + +runTest exiv2 -PEkycv u.jpg +runTest exiv2 -pi u.jpg rm -f u.xmp -$bin/exiv2 -eX u.jpg -$bin/exiv2 -px u.xmp -$bin/exiv2 -PEkycv u.xmp -$bin/exiv2 -pi u.xmp +runTest exiv2 -eX u.jpg +runTest exiv2 -px u.xmp +runTest exiv2 -PEkycv u.xmp +runTest exiv2 -pi u.xmp # 15) And back to Exif/IPTC echo @@ -210,21 +203,18 @@ echo Testcase 15 echo =========== \cp $IMG v.jpg \cp u.xmp v.xmp -$bin/exiv2 -M'set Xmp.tiff.DateTime 2003-12-14T12:01:44Z' v.xmp -TZ=GMT-8 $bin/exiv2 -iX v.jpg -$bin/exiv2 -px v.jpg -$bin/exiv2 -PEkycv v.jpg -$bin/exiv2 -pi v.jpg +runTest exiv2 -M'set Xmp.tiff.DateTime 2003-12-14T12:01:44Z' v.xmp +TZ=GMT-8 runTest exiv2 -iX v.jpg +runTest exiv2 -px v.jpg +runTest exiv2 -PEkycv v.jpg +runTest exiv2 -pi v.jpg ) > $results 2>&1 # ---------------------------------------------------------------------- # Evaluate results cat $results | sed 's/\x0d$//' | tr '\033' '$' > $results-stripped -diff -q $results-stripped $good -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff $results-stripped $good -fi +reportTest $results-stripped $good + +# That's all Folks! +## \ No newline at end of file diff --git a/test/eps-test.sh b/test/eps-test.sh index c955b83b..2c59e3d7 100755 --- a/test/eps-test.sh +++ b/test/eps-test.sh @@ -1,15 +1,11 @@ -#! /bin/sh +#!/bin/bash # Test driver for EPS files # ---------------------------------------------------------------------- # Setup -export LC_ALL=C +source ./functions.source + cd tmp/ -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi exiv2version="`$bin/exiv2 -V | sed -n '1 s,^exiv2 [^ ]* \([^ ]*\).*,\1,p'`" if [ -z "$exiv2version" ]; then echo "Error: Unable to determine Exiv2 version" @@ -37,11 +33,11 @@ done echo echo "-----> $image.eps <-----" - cp "../data/eps/$image.eps" ./ + copyTestFile "eps/$image.eps" "$image.eps" echo echo "Command: exiv2 -u -pa $image.eps" - $bin/exiv2 -u -pa "$image.eps" + runTest exiv2 -u -pa "$image.eps" exitcode="$?" echo "Exit code: $exitcode" @@ -51,7 +47,7 @@ done echo echo "Command: exiv2 -dx $image.eps" - $bin/exiv2 -dx "$image.eps" + runTest exiv2 -dx "$image.eps" exitcode="$?" echo "Exit code: $exitcode" @@ -69,7 +65,7 @@ done echo echo "Command: exiv2 -f -ex $image.eps" - $bin/exiv2 -f -ex "$image.eps" + runTest exiv2 -f -ex "$image.eps" echo "Exit code: $?" if ! diff -q "../data/eps/eps-test-delxmp.exv" "$image.exv" ; then @@ -79,11 +75,11 @@ done echo echo "Restore: $image.eps" - cp "../data/eps/$image.eps" ./ + copyTestFile "eps/$image.eps" "$image.eps" echo echo "Command: exiv2 -f -eX $image.eps" - $bin/exiv2 -f -eX "$image.eps" + runTest exiv2 -f -eX "$image.eps" echo "Exit code: $?" diff -q "../data/eps/$image.xmp" "$image.xmp" @@ -91,11 +87,11 @@ done # Using "-ix" instead of "-iX" because the latter # executes writeMetadata() twice, making it hard to debug. - cp "../data/eps/eps-test-newxmp.xmp" "$image.exv" + copyTestFile "eps/eps-test-newxmp.xmp" "$image.exv" echo echo "Command: exiv2 -ix $image.eps" - $bin/exiv2 -ix "$image.eps" + runTest exiv2 -ix "$image.eps" exitcode="$?" echo "Exit code: $exitcode" @@ -112,7 +108,7 @@ done echo echo "Command: (2) exiv2 -ix $image.eps" - $bin/exiv2 -ix "$image.eps" + runTest exiv2 -ix "$image.eps" echo "Exit code: $?" diff -q "$image.eps.newxmp" "$image.eps" @@ -123,7 +119,7 @@ done echo echo "Command: exiv2 -f -ex $image.eps" - $bin/exiv2 -f -ex "$image.eps" + runTest exiv2 -f -ex "$image.eps" echo "Exit code: $?" diff -q "../data/eps/eps-test-newxmp.exv" "$image.exv" @@ -139,3 +135,6 @@ if ! diff -q $diffargs "../data/eps/eps-test.out" "eps-test.out" ; then exit 1 fi echo "All testcases passed." + +# That's all Folks! +## \ No newline at end of file diff --git a/test/exifdata-test.sh b/test/exifdata-test.sh index cca7c527..4a42f011 100755 --- a/test/exifdata-test.sh +++ b/test/exifdata-test.sh @@ -1,33 +1,17 @@ -#! /bin/sh +#!/bin/bash # Test driver for exifdata copy construction and assignment unit tests -results="./tmp/exifdata-test.out" -good="./data/exifdata-test.out" -diffargs="--strip-trailing-cr" -tmpfile=tmp/ttt -touch $tmpfile -diff -q $diffargs $tmpfile $tmpfile 2>/dev/null -if [ $? -ne 0 ] ; then - diffargs="" -fi +source ./functions.source + ( -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -cp -f ./data/exiv2-gc.jpg ./tmp -cp -f ./data/exiv2-canon-powershot-s40.jpg ./tmp -cp -f ./data/exiv2-nikon-d70.jpg ./tmp -cd ./tmp -$bin/exifdata-test exiv2-gc.jpg -$bin/exifdata-test exiv2-canon-powershot-s40.jpg -$bin/exifdata-test exiv2-nikon-d70.jpg + copyTestFiles exiv2-gc.jpg exiv2-canon-powershot-s40.jpg exiv2-nikon-d70.jpg + + runTest exifdata-test exiv2-gc.jpg + runTest exifdata-test exiv2-canon-powershot-s40.jpg + runTest exifdata-test exiv2-nikon-d70.jpg + ) | tr -d '\r' > $results -diff -q $diffargs $results $good -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff $diffargs $results $good -fi +reportTest + +# That's all Folks! +## \ No newline at end of file diff --git a/test/exiv2-test.sh b/test/exiv2-test.sh index 66084766..b8006b4a 100755 --- a/test/exiv2-test.sh +++ b/test/exiv2-test.sh @@ -1,41 +1,14 @@ -#! /bin/bash +#!/bin/bash # Test driver for exiv2 utility tests -os=$(uname) -if [ "${os:0:4}" == "CYGW" ]; then - # use the diff.exe in msvc - # cygwin's diff does not handle binary files as expected - export "PATH=$PWD/../msvc:$PATH" -fi - -export LC_ALL=C -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -results="./tmp/exiv2-test.out" -good="./data/exiv2-test.out" -tmpfile=tmp/ttt -touch $tmpfile -da1="--strip-trailing-cr" -diff -q $da1 $tmpfile $tmpfile 2>/dev/null -if [ $? -ne 0 ] ; then - da1="" -fi -da2="--ignore-matching-lines=^Usage:.*exiv2" -diff -q $da2 $tmpfile $tmpfile 2>/dev/null -if [ $? -ne 0 ] ; then - da2="" -fi -diffargs="$da1 $da2" +source ./functions.source ( -# Add each image to the following three lists. -# The image basename in the second and third lists -# is the Exif timestamp adjusted by -12:01:01. + # Add each image to the following three lists. + # The image basename in the second and third lists + # is the Exif timestamp adjusted by -12:01:01. -images="exiv2-empty.jpg \ + images="exiv2-empty.jpg \ exiv2-canon-powershot-s40.jpg \ exiv2-nikon-e990.jpg \ exiv2-nikon-d70.jpg \ @@ -51,7 +24,7 @@ images="exiv2-empty.jpg \ exiv2-canon-eos-d30.jpg \ exiv2-canon-powershot-a520.jpg" -image2="exiv2-empty.jpg \ + image2="exiv2-empty.jpg \ 20031214_000043.jpg \ 20000506_020544.jpg \ 20040329_224245.jpg \ @@ -67,7 +40,7 @@ image2="exiv2-empty.jpg \ 20001004_015404.jpg \ 20060127_225027.jpg" -image3="exiv2-empty.exv \ + image3="exiv2-empty.exv \ 20031214_000043.exv \ 20000506_020544.exv \ 20040329_224245.exv \ @@ -83,65 +56,57 @@ image3="exiv2-empty.exv \ 20001004_015404.exv \ 20060127_225027.exv" -for i in $images; do cp -f data/$i tmp/; done -echo "Exiv2 test directory -----------------------------------------------------" -cd tmp/ >/dev/null || exit 1; -echo tmp/ -echo -echo "Exiv2 version ------------------------------------------------------------" -$bin/exiv2 -u -V | sed '1 s, (.. bit build)$, (__ bit build),' -echo -echo "Exiv2 help ---------------------------------------------------------------" -$bin/exiv2 -u -h -echo -echo "Adjust -------------------------------------------------------------------" -$bin/exiv2 -u -v -a-12:01:01 adjust $images -echo -echo "Rename -------------------------------------------------------------------" -$bin/exiv2 -u -vf rename $images -echo -echo "Print --------------------------------------------------------------------" -$bin/exiv2 -u -v print $image2 -$bin/exiv2 -u -v -b -pt print $image2 -$bin/exiv2 -u -v -b -pt print $image2 > iii -echo -echo "Extract Exif data --------------------------------------------------------" -$bin/exiv2 -u -vf extract $image2 -echo -echo "Extract Thumbnail --------------------------------------------------------" -$bin/exiv2 -u -vf -et extract $image2 -$bin/exiv2 -u -v -b -pt print $image3 > jjj -echo -echo "Compare image data and extracted data ------------------------------------" -diff iii jjj -echo -echo "Delete Thumbnail ---------------------------------------------------------" -$bin/exiv2 -u -v -dt delete $image2 -$bin/exiv2 -u -vf -et extract $image2 -echo -echo "Delete Exif data ---------------------------------------------------------" -$bin/exiv2 -u -v delete $image2 -$bin/exiv2 -u -v print $image2 -echo -echo "Insert Exif data ---------------------------------------------------------" -$bin/exiv2 -u -v insert $image2 -$bin/exiv2 -u -v -b -pt print $image3 > kkk -echo -echo "Compare original and inserted image data ---------------------------------" -diff iii kkk + for i in $images; do copyTestFile $i; done + echo "Exiv2 test directory -----------------------------------------------------" + cd tmp/ >/dev/null || exit 1; + echo tmp/ + echo + echo "Exiv2 version ------------------------------------------------------------" + runTest exiv2 -u -V | sed '1 s, (.. bit build)$, (__ bit build),' + echo + echo "Exiv2 help ---------------------------------------------------------------" + runTest exiv2 -u -h + echo + echo "Adjust -------------------------------------------------------------------" + runTest exiv2 -u -v -a-12:01:01 adjust $images + echo + echo "Rename -------------------------------------------------------------------" + runTest exiv2 -u -vf rename $images + echo + echo "Print --------------------------------------------------------------------" + runTest exiv2 -u -v print $image2 + runTest exiv2 -u -v -b -pt print $image2 + runTest exiv2 -u -v -b -pt print $image2 > iii + echo + echo "Extract Exif data --------------------------------------------------------" + runTest exiv2 -u -vf extract $image2 + echo + echo "Extract Thumbnail --------------------------------------------------------" + runTest exiv2 -u -vf -et extract $image2 + runTest exiv2 -u -v -b -pt print $image3 > jjj + echo + echo "Compare image data and extracted data ------------------------------------" + diff iii jjj + echo + echo "Delete Thumbnail ---------------------------------------------------------" + runTest exiv2 -u -v -dt delete $image2 + runTest exiv2 -u -vf -et extract $image2 + echo + echo "Delete Exif data ---------------------------------------------------------" + runTest exiv2 -u -v delete $image2 + runTest exiv2 -u -v print $image2 + echo + echo "Insert Exif data ---------------------------------------------------------" + runTest exiv2 -u -v insert $image2 + runTest exiv2 -u -v -b -pt print $image3 > kkk + echo + echo "Compare original and inserted image data ---------------------------------" + diff iii kkk ) > $results 2>&1 -if [ -e `which dos2unix` ]; then - sed 's,\\,/,g' $results > ${results}-new - mv -f ${results}-new $results - unix2dos $results >/dev/null 2>&1 -fi +diffargs="-w $diffargs" +reportTest -diff -q -w $diffargs $results $good -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff -w $diffargs $results $good -fi +# That's all Folks! +## \ No newline at end of file diff --git a/test/functions.source b/test/functions.source new file mode 100644 index 00000000..9de060ae --- /dev/null +++ b/test/functions.source @@ -0,0 +1,273 @@ +#!/bin/bash + +#locale setting + +## +# initialize globals +export LC_ALL=C + +this=$(basename $0 .sh) +here=$PWD + +if [ -z "$EXIV2_BINDIR" ] ; then + bin="$here/../bin" +else + bin="$EXIV2_BINDIR" +fi + +exe=$(uname) +if [ $exe==cygwin -o $exe==mingw ]; then + exe=.exe +else + unset exe +fi + +## +# run a test +runTest() +{ + local prog=$1 + shift + ( + cd $here/tmp + if [ ! -z $EXIV2_ECHO ]; then + echoTest $VALGRIND $bin/$prog "$@" + fi + $VALGRIND $bin/$prog "$@" + ) +} + +## +# echo commands and arguments +echoTest() +{ + local count=1 + for i in $@ ; do + echo $((count++)): $i + done + echo ----------------------- +} + +## +# predictate +existsTest() +{ + local prog=$1 + result=0 + if [ -e $bin/$prog -o -e $bin/$prog.exe ]; then + result=1 + fi + echo $result +} + +## +# copy file from data to tmp (copyTestFile from to +copyTestFile() +{ + if [ $# == 2 ]; then + cp -f "$here/data/$1" "$here/tmp/$2" + elif [ $# == 1 ]; then + cp -f "$here/data/$1" "$here/tmp/$1" + else + echo "*** error copyTestFile: illegal number of inputs = $# ***" + fi + +} + +## +# copy 1 or more files from data to tmp +copyTestFiles() +{ + for i in "$@" ; do + copyTestFile "$i" "$i" + done +} + +## +# result analysis +reportTest() +{ + if [ -e `which dos2unix` ]; then + sed 's,\\,/,g' $results > ${results}-new + mv -f ${results}-new $results + unix2dos $results >/dev/null 2>&1 + fi + + if [ $# -eq 0 ]; then + lhs=$results + rhs=$good + else + if [ $# -eq 3 ] ; then + diffargs=$1 + lhs=$2 + rhs=$3 + else + lhs=$1 + rhs=$2 + fi + fi + + diff -q $diffargs $lhs $rhs + rc=$? + if [ $rc -eq 0 ] ; then + echo "all testcases passed." + else + diff $diffargs $lhs $rhs + fi +} + +## +# moved here from write-test.sh +runTestCase() +{ + rtc_number=$1 + rtc_infile=$2 + + rtc_outfile=$datapath/test${rtc_number}.jpg + rtc_jpgthumb=$datapath/thumb${rtc_number}.jpg + rtc_tifthumb=$datapath/thumb${rtc_number}.tif + + rm -f $rtc_outfile $rtc_jpgthumb $rtc_tifthumb + rm -f $datapath/iii $datapath/ttt; + + echo "------------------------------------------------------------" + runTest exifprint $rtc_infile > $datapath/iii; + cp $rtc_infile $rtc_outfile; + runTest write-test $rtc_infile $rtc_number > $datapath/ttt; + diff -a $datapath/iii $datapath/ttt +} + +## +# moved here from bugfixes-test.sh +prep_file() +{ + echo `prep_any_file $1 exiv2-bug$1.jpg` +} + +prep_empty_file() +{ + echo `prep_any_file $1 exiv2-empty.jpg` +} + +prep_any_file() +{ + printf "$1 " >&3 + echo '------>' Bug $1 '<-------' >&2 + copyTestFile $2 exiv2-bug$1.jpg + echo exiv2-bug$1.jpg +} + +## +# moved here from imagetest.sh +eraseTest() +{ + src=$1 + test=${src}.etst + good=$datapath/${src}.egd + + #setup + cp $datapath/$src $test + + #run tests + $bin/metacopy $test $test + + #check results + diffCheck $test $good + printf "." +} + +copyTest() +{ + num=$1 + src=$2 + dst=$3 + test=${dst}.c${num}tst + good=$datapath/${dst}.c${num}gd + + #setup + cp $datapath/$dst $test + + #run tests + $bin/metacopy -a $datapath/$src $test + + #check results + diffCheck $test $good + printf "." +} + +iptcTest() +{ + num=$1 + src=$2 + dst=$3 + test=${dst}.i${num}tst + good=$datapath/${dst}.i${num}gd + + #setup + cp $datapath/$dst $test + + #run tests + $bin/metacopy -ip $datapath/$src $test + + #check results + diffCheck $test $good + printf "." +} + +# Make sure to pass the test file first and the known good file second +diffCheck() +{ + test=$1 + good=$2 + + #run diff and check results + diff -q --binary $test $good + if [ $? -ne 0 ]; then + errors=`expr $errors + 1` + else + rm $test + fi +} + +## +# prepare temp files +prepareTest() +{ + diffargs="--strip-trailing-cr" + good="$here/data/${this}.out" + results="$here/tmp/${this}.out" + + ## + # cygwin needs a private version of diff for linux compatibility + os=$(uname) + if [ "${os:0:4}" == "CYGW" ]; then + export "PATH=$PWD/../msvc:$PATH" + fi + + tmpfile=$here/tmp/$this + touch $tmpfile + diff -q $diffargs $tmpfile $tmpfile 2>/dev/null + if [ $? -ne 0 ]; then + diffargs="" + fi + + tmpfile=tmp/ttt + touch $tmpfile + da1="--strip-trailing-cr" + diff -q $da1 $tmpfile $tmpfile 2>/dev/null + if [ $? -ne 0 ] ; then + da1="" + fi + da2="--ignore-matching-lines=^Usage:.*exiv2" + diff -q $da2 $tmpfile $tmpfile 2>/dev/null + if [ $? -ne 0 ] ; then + da2="" + fi + diffargs="$da1 $da2" + +} + +prepareTest + +# That's all Folks! +## \ No newline at end of file diff --git a/test/imagetest.sh b/test/imagetest.sh index 84f54214..51583928 100755 --- a/test/imagetest.sh +++ b/test/imagetest.sh @@ -1,85 +1,9 @@ -#! /bin/sh +#!/bin/bash # Test driver for image file i/o -eraseTest() -{ - src=$1 - test=${src}.etst - good=$datapath/${src}.egd - - #setup - cp $datapath/$src $test - - #run tests - $bin/metacopy $test $test - - #check results - diffCheck $test $good - printf "." -} - -copyTest() -{ - num=$1 - src=$2 - dst=$3 - test=${dst}.c${num}tst - good=$datapath/${dst}.c${num}gd - - #setup - cp $datapath/$dst $test - - #run tests - $bin/metacopy -a $datapath/$src $test - - #check results - diffCheck $test $good - printf "." -} - -iptcTest() -{ - num=$1 - src=$2 - dst=$3 - test=${dst}.i${num}tst - good=$datapath/${dst}.i${num}gd - - #setup - cp $datapath/$dst $test - - #run tests - $bin/metacopy -ip $datapath/$src $test - - #check results - diffCheck $test $good - printf "." -} - - -# Make sure to pass the test file first and the known good file second -diffCheck() -{ - test=$1 - good=$2 - - #run diff and check results - diff -q --binary $test $good - if [ $? -ne 0 ]; then - errors=`expr $errors + 1` - else - rm $test - fi -} - # ********************************************************************** # main - -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi +source ./functions.source datapath="../data" @@ -130,3 +54,6 @@ if [ $errors -eq 0 ]; then else echo $errors 'test case(s) failed!' fi + +# That's all Folks! +## diff --git a/test/iotest.sh b/test/iotest.sh index 845b17f4..8bb49b0e 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash # Test driver for image file i/o ioTest() @@ -8,7 +8,7 @@ ioTest() out2=${1}.2 #run tests - $bin/iotest $src $out1 $out2 + runTest iotest $src $out1 $out2 if [ $? -ne 0 ]; then errors=`expr $errors + 1` return @@ -37,12 +37,7 @@ diffCheck() # ********************************************************************** # main - -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi +source ./functions.source datapath="../data" @@ -61,3 +56,6 @@ if [ $errors -eq 0 ]; then else echo $errors 'test case(s) failed!' fi + +# That's all Folks! +## \ No newline at end of file diff --git a/test/iptctest.sh b/test/iptctest.sh index f1f04961..c1c2629c 100755 --- a/test/iptctest.sh +++ b/test/iptctest.sh @@ -1,6 +1,8 @@ -#! /bin/sh +#!/bin/bash # Test driver for Iptc metadata +source ./functions.source + printTest() { src=$1 @@ -8,7 +10,7 @@ printTest() good=$datapath/${src}.ipgd #run tests - $bin/iptcprint $datapath/$src > $test + runTest iptcprint $datapath/$src > $test #check results diffCheck $test $good @@ -26,7 +28,7 @@ removeTest() cp $datapath/$src $tmp #run tests - $bin/iptctest $tmp <<-eoc + runTest iptctest $tmp <<-eoc r Iptc.Application2.Byline r Iptc.Application2.Caption r Iptc.Application2.Keywords @@ -34,7 +36,7 @@ removeTest() r Iptc.Application2.Keywords r Iptc.Application2.CountryName eoc - $bin/iptcprint $tmp > $test + runTest iptcprint $tmp > $test #check results diffCheck $test $good @@ -53,7 +55,7 @@ addModTest() cp $datapath/$src $tmp #run tests - $bin/iptctest $tmp <<-eoc + runTest iptctest $tmp <<-eoc a Iptc.Application2.Headline The headline I am a Iptc.Application2.Keywords Yet another keyword m Iptc.Application2.DateCreated 2004-8-3 @@ -63,7 +65,7 @@ addModTest() a Iptc.Envelope.TimeSent 14:41:0-05:00 a Iptc.Application2.RasterizedCaption 230 42 34 2 90 84 23 146 eoc - $bin/iptcprint $tmp > $test + runTest iptcprint $tmp > $test #check results diffCheck $test $good @@ -82,8 +84,8 @@ extendedTest() cp $datapath/$src $tmp #run tests - $bin/iptctest $tmp < $datapath/ext.dat - $bin/iptcprint $tmp > $test + runTest iptctest $tmp < $datapath/ext.dat + runTest iptcprint $tmp > $test #check results diffCheck $test $good @@ -110,19 +112,8 @@ diffCheck() # ********************************************************************** # main -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi datapath="../data" diffargs="--strip-trailing-cr" -tmpfile=tmp/ttt -touch $tmpfile -diff -q $diffargs $tmpfile $tmpfile 2>/dev/null -if [ $? -ne 0 ] ; then - diffargs="" -fi test_files="glider.exv \ iptc-noAPP13.jpg \ @@ -168,3 +159,6 @@ if [ $errors -eq 0 ]; then else echo $errors 'test case(s) failed!' fi + +# That's all Folks! +## \ No newline at end of file diff --git a/test/modify-test.sh b/test/modify-test.sh index a793b73b..b4206409 100755 --- a/test/modify-test.sh +++ b/test/modify-test.sh @@ -1,35 +1,17 @@ -#! /bin/sh +#!/bin/bash # Test driver for write unit tests to build Exif metadata from scratch -export LC_ALL=C -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -results="./tmp/modify-test.out" -good="./data/modify-test.out" -diffargs="--strip-trailing-cr" -tmpfile=tmp/ttt -touch $tmpfile -diff -q $diffargs $tmpfile $tmpfile 2>/dev/null -if [ $? -ne 0 ] ; then - diffargs="" -fi -( -cp -f ./data/exiv2-empty.jpg ./tmp -cp -f ./data/exiv2-gc.jpg ./tmp -cd ./tmp -$bin/exiv2 -v -m ../data/modifycmd1.txt exiv2-empty.jpg -$bin/exiv2 -v -m ../data/modifycmd2.txt exiv2-gc.jpg -$bin/exiv2 -v -pi exiv2-empty.jpg -$bin/exiv2 -v -pt exiv2-empty.jpg exiv2-gc.jpg +source ./functions.source +( + copyTestFiles exiv2-empty.jpg exiv2-gc.jpg + cd ./tmp + runTest exiv2 -v -m ../data/modifycmd1.txt exiv2-empty.jpg + runTest exiv2 -v -m ../data/modifycmd2.txt exiv2-gc.jpg + runTest exiv2 -v -pi exiv2-empty.jpg + runTest exiv2 -v -pt exiv2-empty.jpg exiv2-gc.jpg ) > $results -diff -q $diffargs $results $good -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff $diffargs $results $good -fi +reportTest + +# That's all Folks! +## \ No newline at end of file diff --git a/test/path-test.sh b/test/path-test.sh index b7b445bb..42144c22 100755 --- a/test/path-test.sh +++ b/test/path-test.sh @@ -1,14 +1,13 @@ -#! /bin/sh +#!/bin/bash # Mini test-driver for path utility functions -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi +source ./functions.source cd ./tmp -if { test -f $bin/path-test || test -f $bin/path-test.exe; }; then - $bin/path-test ../data/path-test.txt +if [ $(existsTest path-test) == 1 ] ; then + runTest path-test ../data/path-test.txt else - echo "path-test.sh: path-test executable not found. Skipping path tests." + echo "$0: path-test executable not found. Skipping path tests." fi + +# That's all Folks! +## \ No newline at end of file diff --git a/test/preview-test.sh b/test/preview-test.sh index 4dfea1c2..6c858a0b 100755 --- a/test/preview-test.sh +++ b/test/preview-test.sh @@ -1,19 +1,12 @@ -#! /bin/sh +#!/bin/bash # Test driver for previews # ---------------------------------------------------------------------- # Setup -export LC_ALL=C +source ./functions.source +prepareTest cd tmp/ -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -diffargs="--strip-trailing-cr" -if ! diff -q $diffargs /dev/null /dev/null 2>/dev/null ; then - diffargs="" -fi + # ---------------------------------------------------------------------- # Tests @@ -148,3 +141,6 @@ if ! diff -q $diffargs "../data/preview/preview-test.out" "preview-test.out" ; t exit 1 fi echo "All testcases passed." + +# That's all Folks! +## \ No newline at end of file diff --git a/test/stringto-test.sh b/test/stringto-test.sh index d6636473..1a26fc40 100755 --- a/test/stringto-test.sh +++ b/test/stringto-test.sh @@ -1,28 +1,13 @@ -#! /bin/sh +#!/bin/bash # Test driver for tests of stringToLong/Float/Rational -results="./tmp/stringto-test.out" -good="./data/stringto-test.out" -diffargs="--strip-trailing-cr" -tmpfile=tmp/ttt -touch $tmpfile -diff -q $diffargs $tmpfile $tmpfile 2>/dev/null -if [ $? -ne 0 ] ; then - diffargs="" -fi +source ./functions.source +prepareTest + ( -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -cd ./tmp -$bin/stringto-test + runTest stringto-test ) > $results -diff -q $diffargs $results $good -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff $diffargs $results $good -fi +reportTest + +# That's all Folks! +## \ No newline at end of file diff --git a/test/testMSVC.sh b/test/testMSVC.sh index eccfdd39..5934be07 100755 --- a/test/testMSVC.sh +++ b/test/testMSVC.sh @@ -2,7 +2,7 @@ msvc=$1 test=$2 -home=$(dirname $0) +home=$(dirname $(readlink -f $0)) if [ -z $msvc ]; then echo usage: $0 \ [test] @@ -30,5 +30,4 @@ for d in $(find "$msvc" -name exiv2.exe -exec dirname {} ";"); do done # That's all Folks! -## - +## \ No newline at end of file diff --git a/test/tiff-test.sh b/test/tiff-test.sh index e7e16d50..14a53d13 100644 --- a/test/tiff-test.sh +++ b/test/tiff-test.sh @@ -1,8 +1,9 @@ -#! /bin/sh +#!/bin/bash # TIFF parser test driver # ---------------------------------------------------------------------- # Check if the exifprobe tool is available + if [ `which exifprobe 2>/dev/null`x = x ] ; then echo "tiff-test.sh: exifprobe not found. Skipping TIFF tests." exit 0 @@ -10,36 +11,20 @@ fi # ---------------------------------------------------------------------- # Setup -results="./tmp/tiff-test.out" -good="./data/tiff-test.out" +source ./functions.source +prepareTest # ---------------------------------------------------------------------- # Main routine ( -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -cd ./tmp - -# ---------------------------------------------------------------------- -# Basic write test -testfile=mini9.tif -cp -f ../data/$testfile . +runTest mini9.tif exifprobe $testfile -$bin/tiff-test $testfile -exifprobe $testfile - ) > $results # ---------------------------------------------------------------------- # Evaluate results cat $results | sed 's/\x0d$//' > $results-stripped -diff -q $results-stripped $good -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff $results-stripped $good -fi +reportTest $results-stripped $good + +# That's all Folks! +## \ No newline at end of file diff --git a/test/verifyMSVC.sh b/test/verifyMSVC.sh index a2f1ee71..10e8cb46 100755 --- a/test/verifyMSVC.sh +++ b/test/verifyMSVC.sh @@ -29,4 +29,4 @@ nl "$filename" | grep "\-\-\-\-\ " | while read i ; do done # That's all Folks -## +## \ No newline at end of file diff --git a/test/video-test.sh b/test/video-test.sh index b98cf454..fc1fdb90 100755 --- a/test/video-test.sh +++ b/test/video-test.sh @@ -8,48 +8,34 @@ # ---------------------------------------------------------------------- # Setup -export LC_ALL=C -os=$(uname) -if [ "${os:0:4}" == "CYGW" ]; then - export "PATH=$PWD/../msvc:$PATH" -fi +source ./functions.source + cd tmp/ -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -diffargs="--strip-trailing-cr" -if ! diff -q $diffargs /dev/null /dev/null 2>/dev/null ; then - diffargs="" -fi # ---------------------------------------------------------------------- # Tests ( for file in ../data/video/video-*; do video="`basename "$file"`" - if [ $video = "video-test.out" ] ; then - continue - fi - - printf "." >&3 + if [ $video != "video-test.out" ] ; then - echo - echo "-----> $video <-----" + printf "." >&3 - cp "../data/video/$video" ./ + echo + echo "-----> $video <-----" - echo - echo "Command: exiv2 -u -pa $video" - $bin/exiv2 -u -pa "$video" - exitcode="$?" - echo "Exit code: $exitcode" + copyTestFile "video/$video" "$video" - if [ "$exitcode" -ne 0 -a "$exitcode" -ne 253 ] ; then - continue - fi + echo + echo "Command: exiv2 -u -pa $video" + runTest exiv2 -u -pa "$video" + exitcode="$?" + echo "Exit code: $exitcode" + if [ "$exitcode" -ne 0 -a "$exitcode" -ne 253 ] ; then + continue + fi + fi done ) 3>&1 > "video-test.out" 2>&1 @@ -62,3 +48,6 @@ if ! diff -q $diffargs "../data/video/video-test.out" "video-test.out" ; then exit 1 fi echo "All testcases passed." + +# That's all Folks! +## \ No newline at end of file diff --git a/test/write-test.sh b/test/write-test.sh index 0b7016a3..9f8ae763 100755 --- a/test/write-test.sh +++ b/test/write-test.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash # Test driver for the write unit tests # Function: @@ -8,44 +8,14 @@ # file : Input file # Abstract: # Run the requested test case number with the given file -( -runTestCase() -{ - rtc_number=$1 - rtc_infile=$2 - - rtc_outfile=$datapath/test${rtc_number}.jpg - rtc_jpgthumb=$datapath/thumb${rtc_number}.jpg - rtc_tifthumb=$datapath/thumb${rtc_number}.tif - - rm -f $rtc_outfile $rtc_jpgthumb $rtc_tifthumb - rm -f $datapath/iii $datapath/ttt; - echo "------------------------------------------------------------" - $bin/exifprint $rtc_infile > $datapath/iii; - cp $rtc_infile $rtc_outfile; - $bin/write-test $rtc_infile $rtc_number > $datapath/ttt; - diff -a $datapath/iii $datapath/ttt -} +source ./functions.source -# ********************************************************************** -# main - -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -datapath="." -diffargs="--strip-trailing-cr" -tmpfile=tmp/ttt -touch $tmpfile -diff -q $diffargs $tmpfile $tmpfile 2>/dev/null -if [ $? -ne 0 ] ; then - diffargs="" -fi +( + cd ./tmp + datapath=. -images="exiv2-canon-powershot-s40.jpg \ + images="exiv2-canon-powershot-s40.jpg \ exiv2-kodak-dc210.jpg \ exiv2-fujifilm-finepix-s2pro.jpg \ exiv2-sigma-d10.jpg \ @@ -53,27 +23,22 @@ images="exiv2-canon-powershot-s40.jpg \ exiv2-nikon-d70.jpg \ exiv2-nikon-e950.jpg" -for i in $images; do cp -f ./data/$i ./tmp; done -cd ./tmp + copyTestFiles ${images[@]} -runTestCase 1 $datapath/exiv2-canon-powershot-s40.jpg -runTestCase 2 $datapath/exiv2-canon-powershot-s40.jpg -runTestCase 3 $datapath/exiv2-kodak-dc210.jpg -runTestCase 4 $datapath/exiv2-canon-powershot-s40.jpg -runTestCase 5 $datapath/exiv2-canon-powershot-s40.jpg -runTestCase 6 $datapath/exiv2-kodak-dc210.jpg -runTestCase 7 $datapath/exiv2-fujifilm-finepix-s2pro.jpg -runTestCase 8 $datapath/exiv2-sigma-d10.jpg -runTestCase 9 $datapath/exiv2-nikon-e990.jpg -runTestCase 10 $datapath/exiv2-nikon-e950.jpg -runTestCase 11 $datapath/exiv2-nikon-d70.jpg + runTestCase 1 $datapath/exiv2-canon-powershot-s40.jpg + runTestCase 2 $datapath/exiv2-canon-powershot-s40.jpg + runTestCase 3 $datapath/exiv2-kodak-dc210.jpg + runTestCase 4 $datapath/exiv2-canon-powershot-s40.jpg + runTestCase 5 $datapath/exiv2-canon-powershot-s40.jpg + runTestCase 6 $datapath/exiv2-kodak-dc210.jpg + runTestCase 7 $datapath/exiv2-fujifilm-finepix-s2pro.jpg + runTestCase 8 $datapath/exiv2-sigma-d10.jpg + runTestCase 9 $datapath/exiv2-nikon-e990.jpg + runTestCase 10 $datapath/exiv2-nikon-e950.jpg + runTestCase 11 $datapath/exiv2-nikon-d70.jpg ) > tmp/write-test.out 2>&1 +reportTest -diff -q -w -a $diffargs tmp/write-test.out data/write-test.out -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff -w -a $diffargs tmp/write-test.out data/write-test.out -fi +# That's all Folks! +## \ No newline at end of file diff --git a/test/write2-test.sh b/test/write2-test.sh index f24706a8..4efd1afb 100755 --- a/test/write2-test.sh +++ b/test/write2-test.sh @@ -1,29 +1,14 @@ #! /bin/sh # Test driver for write unit tests to build Exif metadata from scratch -results="./tmp/write2-test.out" -good="./data/write2-test.out" -diffargs="--strip-trailing-cr" -tmpfile=tmp/ttt -touch $tmpfile -diff -q $diffargs $tmpfile $tmpfile 2>/dev/null -if [ $? -ne 0 ] ; then - diffargs="" -fi + +source ./functions.source + ( -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -cp -f ./data/exiv2-empty.jpg ./tmp -cd ./tmp -$bin/write2-test exiv2-empty.jpg + copyTestFile exiv2-empty.jpg + runTest write2-test exiv2-empty.jpg ) > $results -diff -q $diffargs $results $good -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff $diffargs $results $good -fi +reportTest + +# That's all Folks! +## \ No newline at end of file diff --git a/test/xmpparser-test.sh b/test/xmpparser-test.sh index dcaa98dd..4dd6cace 100755 --- a/test/xmpparser-test.sh +++ b/test/xmpparser-test.sh @@ -1,71 +1,47 @@ #! /bin/sh # XMP parser test driver -# ---------------------------------------------------------------------- -# Setup -export LC_ALL=C -results="./xmpparser-test.out" -good="../data/xmpparser-test.out" -if [ -z "$EXIV2_BINDIR" ] ; then - bin="$VALGRIND ../../bin" -else - bin="$VALGRIND $EXIV2_BINDIR" -fi -cd ./tmp +source ./functions.source -# ---------------------------------------------------------------------- +## # Check if xmpparser-test exists -if [ ! -e ../../bin/xmpparser-test -a ! -e "$EXIV2_BINDIR/xmpparser-test" ] ; then +if [ $(existsTest xmpparser-test) != 1 ] ; then echo "xmpparser-test not found. Assuming XMP support is not enabled." exit 0 fi -# ---------------------------------------------------------------------- -# Main routine ( -# ---------------------------------------------------------------------- -# BlueSquare -testfile=BlueSquare.xmp -cp -f ../data/$testfile . -$bin/xmpparser-test $testfile -diff $testfile ${testfile}-new + cd ./tmp -# ---------------------------------------------------------------------- -# StaffPhotographer-Example -testfile=StaffPhotographer-Example.xmp -cp -f ../data/$testfile . -$bin/xmpparser-test $testfile -diff $testfile ${testfile}-new + files=(BlueSquare.xmp StaffPhotographer-Example.xmp xmpsdk.xmp) + copyTestFiles ${files[@]} -# ---------------------------------------------------------------------- -# xmpsdk -testfile=xmpsdk.xmp -cp -f ../data/$testfile . -$bin/xmpparser-test $testfile -diff $testfile ${testfile}-new -$bin/xmpparse ${testfile} > t1 2>&1 -$bin/xmpparse ${testfile}-new > t2 2>&1 -diff t1 t2 + for f in ${files[@]} ; do + runTest xmpparser-test $f + diff $f ${f}-new + done -# ---------------------------------------------------------------------- -# xmpsample -$bin/xmpsample + testfile=xmpsdk.xmp + runTest xmpparse ${testfile} > t1 2>&1 + runTest xmpparse ${testfile}-new > t2 2>&1 + diff t1 t2 -# ---------------------------------------------------------------------- -# XMP sample commands -cp -f ../data/exiv2-empty.jpg . -$bin/exiv2 -v -m ../data/cmdxmp.txt exiv2-empty.jpg -$bin/exiv2 -v -px exiv2-empty.jpg + # ---------------------------------------------------------------------- + # xmpsample + runTest xmpsample + + # ---------------------------------------------------------------------- + # XMP sample commands + copyTestFile exiv2-empty.jpg + runTest exiv2 -v -m ../data/cmdxmp.txt exiv2-empty.jpg + runTest exiv2 -v -px exiv2-empty.jpg ) > $results 2>&1 # ---------------------------------------------------------------------- # Evaluate results cat $results | sed 's/\x0d$//' > $results-stripped -diff -q $results-stripped $good -rc=$? -if [ $rc -eq 0 ] ; then - echo "All testcases passed." -else - diff $results-stripped $good -fi +reportTest $results-stripped $good + +# That's all Folks! +##