diff --git a/test/Makefile b/test/Makefile index 0ac3d20b..5607f0de 100644 --- a/test/Makefile +++ b/test/Makefile @@ -84,6 +84,9 @@ TESTS = addmoddel.sh \ TESTV = video-test.sh TESTE = eps-test.sh +tests: + cd .. ; make tests + test: @list='$(TESTS)'; for p in $$list; do \ echo Running $$p ...; \ diff --git a/test/addmoddel.sh b/test/addmoddel.sh index c15a130a..d72ea901 100755 --- a/test/addmoddel.sh +++ b/test/addmoddel.sh @@ -2,10 +2,12 @@ # Test driver to run the addmoddel sample program source ./functions.source -( +( cd "$testdir" + copyTestFile exiv2-empty.jpg runTest addmoddel exiv2-empty.jpg runTest exiv2 -pv exiv2-empty.jpg + ) > $results reportTest diff --git a/test/bugfixes-test.sh b/test/bugfixes-test.sh index 16f40002..8e1b11d4 100755 --- a/test/bugfixes-test.sh +++ b/test/bugfixes-test.sh @@ -3,8 +3,7 @@ source ./functions.source -( - cd ./tmp +( cd "$testdir" num=426 filename=`prep_file $num` @@ -52,7 +51,7 @@ source ./functions.source num=480 filename=`prep_file $num` - runTest largeiptc-test $filename ../data/imagemagick.png + runTest largeiptc-test $filename $datadir/imagemagick.png num=495 filename=`prep_file $num` @@ -183,7 +182,8 @@ source ./functions.source num=799 filename=`prep_empty_file $num` - runTest exiv2 -v -m ../data/bug$num.cmd $filename + copyTestFile bug$num.cmd + runTest exiv2 -v -m bug$num.cmd $filename runTest exiv2 -v -pa $filename runTest exiv2 -f -eX $filename cat exiv2-bug$num.xmp @@ -216,7 +216,7 @@ source ./functions.source printf "$num " >&3 copyTestFile $filename.rsrc $filename/rsrc runTest exiv2 -M'set Exif.Photo.UserComment Test' $filename - diff -q ../data/$filename.rsrc $filename/rsrc + diff -q $datadir/$filename.rsrc $filename/rsrc else # skip this test on systems which do not have resource forks printf "($num skipped) " >&3 diff --git a/test/conversions.sh b/test/conversions.sh index 0eb0dcf8..71aa45e5 100755 --- a/test/conversions.sh +++ b/test/conversions.sh @@ -12,202 +12,200 @@ if [ $(existsTest xmpparser-test) == 0 ] ; then exit 0 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 -runTest exiv2 -M'set Exif.Image.ImageDescription The Exif image description' h.jpg -rm -f 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 -echo Testcase 2 -echo ========== -\cp $IMG i.jpg -\cp h.xmp i.xmp -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 -echo Testcase 3 -echo ========== -sed s/x-default/de-DE/ i.xmp > j.xmp -\cp $IMG 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 -echo Testcase 4 -echo ========== -sed 's,The Exif image description,The Exif image descriptionCiao bella,' j.xmp > k.xmp -\cp $IMG 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 -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 -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 -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 -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 -echo Testcase 7 -echo ========== -\cp $IMG n.jpg -\cp m.xmp n.xmp -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 -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 -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 -echo Testcase 9 -echo ========== -\cp $IMG p.jpg -\cp o.xmp p.xmp -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 -runTest exiv2 -M'set Exif.Image.Software Exiv2' q.jpg -runTest exiv2 -PEkycv q.jpg -rm -f 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 -echo Testcase 11 -echo =========== -\cp $IMG r.jpg -\cp q.xmp r.xmp -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 -runTest exiv2 -M'set Iptc.Application2.SubLocation Kuala Lumpur' s.jpg -runTest exiv2 -pi s.jpg -rm -f 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 -echo Testcase 13 -echo =========== -\cp $IMG t.jpg -\cp s.xmp t.xmp -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 -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 -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 -echo Testcase 15 -echo =========== -\cp $IMG v.jpg -\cp u.xmp v.xmp -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 +( cd "$testdir" + + IMG=exiv2-empty.jpg + + # 1) Convert Exif ImageDescription to XMP x-default langAlt value + echo Testcase 1 + echo ========== + copyTestFile $IMG h.jpg + runTest exiv2 -M'set Exif.Image.ImageDescription The Exif image description' h.jpg + rm -f 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 + echo Testcase 2 + echo ========== + copyTestFile $IMG i.jpg + copy h.xmp i.xmp + 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 + echo Testcase 3 + echo ========== + sed s/x-default/de-DE/ i.xmp > j.xmp + copyTestFile $IMG 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 + echo Testcase 4 + echo ========== + sed 's,The Exif image description,The Exif image descriptionCiao bella,' j.xmp > k.xmp + copyTestFile $IMG 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 ========== + copy k.xmp l.xmp + runTest exiv2 -M'set Xmp.dc.description lang="x-default" How to fix this mess' l.xmp + grep x-default l.xmp + copyTestFile $IMG 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 ========== + copyTestFile $IMG 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 + 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 + echo Testcase 7 + echo ========== + copyTestFile $IMG n.jpg + copy m.xmp n.xmp + 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 ========== + copyTestFile $IMG 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 + 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 + echo Testcase 9 + echo ========== + copyTestFile $IMG p.jpg + copy o.xmp p.xmp + 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 =========== + copyTestFile $IMG q.jpg + runTest exiv2 -M'set Exif.Image.Software Exiv2' q.jpg + runTest exiv2 -PEkycv q.jpg + rm -f 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 + echo Testcase 11 + echo =========== + copyTestFile $IMG r.jpg + copy q.xmp r.xmp + 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 =========== + copyTestFile $IMG s.jpg + runTest exiv2 -M'set Iptc.Application2.SubLocation Kuala Lumpur' s.jpg + runTest exiv2 -pi s.jpg + rm -f 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 + echo Testcase 13 + echo =========== + copyTestFile $IMG t.jpg + copy s.xmp t.xmp + 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 =========== + copyTestFile $IMG 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 + 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 + echo Testcase 15 + echo =========== + copyTestFile $IMG v.jpg + copy u.xmp v.xmp + 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 diff --git a/test/eps-test.sh b/test/eps-test.sh index 2c59e3d7..85ff8efb 100755 --- a/test/eps-test.sh +++ b/test/eps-test.sh @@ -1,31 +1,31 @@ #!/bin/bash # Test driver for EPS files -# ---------------------------------------------------------------------- -# Setup source ./functions.source -cd tmp/ -exiv2version="`$bin/exiv2 -V | sed -n '1 s,^exiv2 [^ ]* \([^ ]*\).*,\1,p'`" -if [ -z "$exiv2version" ]; then - echo "Error: Unable to determine Exiv2 version" - exit 1 -fi -diffargs="--strip-trailing-cr" -if ! diff -q $diffargs /dev/null /dev/null 2>/dev/null ; then - diffargs="" -fi -for file in ../data/eps/eps-*.eps.*; do - if ! grep "_Exiv2Version_" "$file" >/dev/null ; then - echo "Error: $file contains hard-coded Exiv2 version" - exit 1 - fi -done -# ---------------------------------------------------------------------- -# Tests -( - for file in ../data/eps/eps-*.eps; do +( cd "$testdir" + + ## + # what version of exiv2 are we using? + exiv2version="`$bin/exiv2 -V | sed -n '1 s,^exiv2 [^ ]* \([^ ]*\).*,\1,p'`" + if [ -z "$exiv2version" ]; then + echo "Error: Unable to determine Exiv2 version" + exit 1 + fi + + ## + # ensure that no data file is already stamped with the current version + for file in $datadir/eps/eps-*.eps.*; do + if ! grep "_Exiv2Version_" "$file" >/dev/null ; then + echo "Error: $file contains hard-coded Exiv2 version" + exit 1 + fi + done + + ## + # get down to work! + for file in $datadir/eps/eps-*.eps; do image="`basename "$file" .eps`" printf "." >&3 @@ -53,7 +53,7 @@ done if [ "$exitcode" -eq 0 ] ; then # using perl instead of sed, because on some systems sed adds a line ending at EOF - perl -pe "s,_Exiv2Version_,$exiv2version," < "../data/eps/$image.eps.delxmp" > "$image.eps.delxmp" + perl -pe "s,_Exiv2Version_,$exiv2version," < "$datadir/eps/$image.eps.delxmp" > "$image.eps.delxmp" if ! diff -q "$image.eps.delxmp" "$image.eps" ; then continue @@ -68,7 +68,7 @@ done runTest exiv2 -f -ex "$image.eps" echo "Exit code: $?" - if ! diff -q "../data/eps/eps-test-delxmp.exv" "$image.exv" ; then + if ! diff -q "$datadir/eps/eps-test-delxmp.exv" "$image.exv" ; then continue fi fi @@ -82,7 +82,7 @@ done runTest exiv2 -f -eX "$image.eps" echo "Exit code: $?" - diff -q "../data/eps/$image.xmp" "$image.xmp" + diff -q "$datadir/eps/$image.xmp" "$image.xmp" # Using "-ix" instead of "-iX" because the latter # executes writeMetadata() twice, making it hard to debug. @@ -100,7 +100,7 @@ done fi # using perl instead of sed, because on some systems sed adds a line ending at EOF - perl -pe "s,_Exiv2Version_,$exiv2version," < "../data/eps/$image.eps.newxmp" > "$image.eps.newxmp" + perl -pe "s,_Exiv2Version_,$exiv2version," < "$datadir/eps/$image.eps.newxmp" > "$image.eps.newxmp" if ! diff -q "$image.eps.newxmp" "$image.eps" ; then continue @@ -122,16 +122,17 @@ done runTest exiv2 -f -ex "$image.eps" echo "Exit code: $?" - diff -q "../data/eps/eps-test-newxmp.exv" "$image.exv" + diff -q "$datadir/eps/eps-test-newxmp.exv" "$image.exv" done -) 3>&1 > "eps-test.out" 2>&1 + +) 3>&1 > "$testdir/eps-test.out" 2>&1 echo "." # ---------------------------------------------------------------------- # Result -if ! diff -q $diffargs "../data/eps/eps-test.out" "eps-test.out" ; then - diff -u $diffargs "../data/eps/eps-test.out" "eps-test.out" +if ! diff -q $diffargs "$testdir/$datadir/eps/eps-test.out" "$testdir/eps-test.out" ; then + diff -u $diffargs "$testdir/$datadir/eps/eps-test.out" "$testdir/eps-test.out" exit 1 fi echo "All testcases passed." diff --git a/test/exifdata-test.sh b/test/exifdata-test.sh index 4a42f011..a99b3add 100755 --- a/test/exifdata-test.sh +++ b/test/exifdata-test.sh @@ -2,7 +2,8 @@ # Test driver for exifdata copy construction and assignment unit tests source ./functions.source -( +( cd "$testdir" + copyTestFiles exiv2-gc.jpg exiv2-canon-powershot-s40.jpg exiv2-nikon-d70.jpg runTest exifdata-test exiv2-gc.jpg diff --git a/test/exiv2-test.sh b/test/exiv2-test.sh index b8006b4a..3f94ab7b 100755 --- a/test/exiv2-test.sh +++ b/test/exiv2-test.sh @@ -3,7 +3,8 @@ source ./functions.source -( +( cd "$testdir" + # 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. @@ -58,7 +59,8 @@ source ./functions.source for i in $images; do copyTestFile $i; done echo "Exiv2 test directory -----------------------------------------------------" - cd tmp/ >/dev/null || exit 1; + cd "$testdir" + echo tmp/ echo echo "Exiv2 version ------------------------------------------------------------" diff --git a/test/functions.source b/test/functions.source index d05537f8..95c267ba 100644 --- a/test/functions.source +++ b/test/functions.source @@ -6,9 +6,11 @@ export LC_ALL=C ## # initialize globals - this=$(basename $0 .sh) here=$PWD +datapath="../data" +testdir="$here/tmp" +datadir="../data" if [ -z "$EXIV2_BINDIR" ] ; then bin="$here/../bin" @@ -61,6 +63,13 @@ existsTest() echo $result } +## +# copy file +copy() +{ + \cp "$1" "$2" +} + ## # copy file from data to tmp (copyTestFile from to copyTestFile() @@ -123,6 +132,13 @@ reportTest() ## # moved here from write-test.sh +# Function: +# runTestCase number file +# Params: +# number: Test case number +# file : Input file +# Abstract: +# Run the requested test case number with the given file runTestCase() { rtc_number=$1 @@ -234,6 +250,121 @@ diffCheck() fi } + +## +# moved here from iotest.sh +ioTest() +{ + src=$datapath/$1 + out1=${1}.1 + out2=${1}.2 + + #run tests + runTest iotest $src $out1 $out2 + if [ $? -ne 0 ]; then + errors=`expr $errors + 1` + return + fi + + #check results + diffCheck $out1 $src + diffCheck $out2 $src + printf "." +} + + +## +# moved here from iptctest.sh +printTest() +{ + src=$1 + test=${src}.iptst + good=$datapath/${src}.ipgd + + #run tests + runTest iptcprint $datapath/$src > $test + + #check results + diffCheck $test $good + printf "." +} + +removeTest() +{ + src=$1 + tmp="temp" + test=${src}.irtst + good=$datapath/${src}.irgd + + #setup + cp $datapath/$src $tmp + + #run tests + runTest iptctest $tmp <<-eoc + r Iptc.Application2.Byline + r Iptc.Application2.Caption + r Iptc.Application2.Keywords + r Iptc.Application2.Keywords + r Iptc.Application2.Keywords + r Iptc.Application2.CountryName +eoc + runTest iptcprint $tmp > $test + + #check results + diffCheck $test $good + printf "." + rm $tmp +} + +addModTest() +{ + src=$1 + tmp="temp" + test=${src}.iatst + good=$datapath/${src}.iagd + + #setup + cp $datapath/$src $tmp + + #run tests + 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 + a Iptc.Application2.Urgency 3 + m Iptc.Application2.SuppCategory "bla bla ba" + a Iptc.Envelope.ModelVersion 2 + a Iptc.Envelope.TimeSent 14:41:0-05:00 + a Iptc.Application2.RasterizedCaption 230 42 34 2 90 84 23 146 +eoc + runTest iptcprint $tmp > $test + + #check results + diffCheck $test $good + printf "." + rm $tmp +} + +extendedTest() +{ + src=$1 + tmp="temp" + test=${src}.ixtst + good=$datapath/${src}.ixgd + + #setup + cp $datapath/$src $tmp + + #run tests + runTest iptctest $tmp < $datapath/ext.dat + runTest iptcprint $tmp > $test + + #check results + diffCheck $test $good + printf "." + rm $tmp +} + ## # prepare temp files prepareTest() diff --git a/test/imagetest.sh b/test/imagetest.sh index 51583928..eba1b8f6 100755 --- a/test/imagetest.sh +++ b/test/imagetest.sh @@ -5,55 +5,55 @@ # main source ./functions.source -datapath="../data" - -test_files="table.jpg smiley1.jpg smiley2.jpg" - -erase_test_files="glider.exv \ - iptc-noAPP13.jpg \ - iptc-psAPP13-noIPTC.jpg \ - iptc-psAPP13-noIPTC-psAPP13-wIPTC.jpg \ - iptc-psAPP13s-noIPTC-psAPP13s-wIPTC.jpg \ - iptc-psAPP13s-wIPTC-psAPP13s-noIPTC.jpg \ - iptc-psAPP13s-wIPTCs-psAPP13s-wIPTCs.jpg \ - iptc-psAPP13-wIPTC1-psAPP13-wIPTC2.jpg \ - iptc-psAPP13-wIPTCbeg.jpg \ - iptc-psAPP13-wIPTCempty.jpg \ - iptc-psAPP13-wIPTCempty-psAPP13-wIPTC.jpg \ - iptc-psAPP13-wIPTCend.jpg \ - iptc-psAPP13-wIPTCmid1-wIPTCempty-wIPTCmid2.jpg \ - iptc-psAPP13-wIPTCmid.jpg \ - iptc-psAPP13-wIPTC-psAPP13-noIPTC.jpg" - -errors=0 -cd ./tmp -echo - -printf "Erase all tests" -for i in $test_files $erase_test_files; do eraseTest $i; done - -echo -printf "Copy all tests" -c=0 -for src in $test_files; do - c=`expr $c + 1` - for dst in $test_files; do copyTest $c $src $dst; done -done - -echo -printf "Copy iptc tests" -c=0 -for src in $test_files; do - c=`expr $c + 1` - for dst in $test_files; do iptcTest $c $src $dst; done -done - -printf "\n---------------------------------------------------------\n" -if [ $errors -eq 0 ]; then - echo 'All test cases passed' -else - echo $errors 'test case(s) failed!' -fi +( cd "$testdir" + + test_files="table.jpg smiley1.jpg smiley2.jpg" + + erase_test_files="glider.exv \ + iptc-noAPP13.jpg \ + iptc-psAPP13-noIPTC.jpg \ + iptc-psAPP13-noIPTC-psAPP13-wIPTC.jpg \ + iptc-psAPP13s-noIPTC-psAPP13s-wIPTC.jpg \ + iptc-psAPP13s-wIPTC-psAPP13s-noIPTC.jpg \ + iptc-psAPP13s-wIPTCs-psAPP13s-wIPTCs.jpg \ + iptc-psAPP13-wIPTC1-psAPP13-wIPTC2.jpg \ + iptc-psAPP13-wIPTCbeg.jpg \ + iptc-psAPP13-wIPTCempty.jpg \ + iptc-psAPP13-wIPTCempty-psAPP13-wIPTC.jpg \ + iptc-psAPP13-wIPTCend.jpg \ + iptc-psAPP13-wIPTCmid1-wIPTCempty-wIPTCmid2.jpg \ + iptc-psAPP13-wIPTCmid.jpg \ + iptc-psAPP13-wIPTC-psAPP13-noIPTC.jpg" + + errors=0 + + echo + printf "Erase all tests" + for i in $test_files $erase_test_files; do eraseTest $i; done + + echo + printf "Copy all tests" + c=0 + for src in $test_files; do + c=`expr $c + 1` + for dst in $test_files; do copyTest $c $src $dst; done + done + + echo + printf "Copy iptc tests" + c=0 + for src in $test_files; do + c=`expr $c + 1` + for dst in $test_files; do iptcTest $c $src $dst; done + done + + printf "\n---------------------------------------------------------\n" + if [ $errors -eq 0 ]; then + echo 'All test cases passed' + else + echo $errors 'test case(s) failed!' + fi +) # That's all Folks! ## diff --git a/test/iotest.sh b/test/iotest.sh index 8bb49b0e..4599edd5 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -1,61 +1,23 @@ #!/bin/bash # Test driver for image file i/o -ioTest() -{ - src=$datapath/$1 - out1=${1}.1 - out2=${1}.2 - - #run tests - runTest iotest $src $out1 $out2 - if [ $? -ne 0 ]; then - errors=`expr $errors + 1` - return - fi - - #check results - diffCheck $out1 $src - diffCheck $out2 $src - 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 source ./functions.source -datapath="../data" - -test_files="table.jpg smiley2.jpg ext.dat" - -errors=0 -cd ./tmp -echo - -printf "Io tests" -for i in $test_files; do ioTest $i; done - -printf "\n---------------------------------------------------------\n" -if [ $errors -eq 0 ]; then - echo 'All test cases passed' -else - echo $errors 'test case(s) failed!' -fi +( cd "$testdir" + + errors=0 + test_files="table.jpg smiley2.jpg ext.dat" + echo + printf "Io tests" + for i in $test_files; do ioTest $i; done + + printf "\n---------------------------------------------------------\n" + if [ $errors -eq 0 ]; then + echo 'All test cases passed' + 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 c1c2629c..ce6faa88 100755 --- a/test/iptctest.sh +++ b/test/iptctest.sh @@ -3,162 +3,52 @@ source ./functions.source -printTest() -{ - src=$1 - test=${src}.iptst - good=$datapath/${src}.ipgd - - #run tests - runTest iptcprint $datapath/$src > $test - - #check results - diffCheck $test $good - printf "." -} - -removeTest() -{ - src=$1 - tmp="temp" - test=${src}.irtst - good=$datapath/${src}.irgd - - #setup - cp $datapath/$src $tmp - - #run tests - runTest iptctest $tmp <<-eoc - r Iptc.Application2.Byline - r Iptc.Application2.Caption - r Iptc.Application2.Keywords - r Iptc.Application2.Keywords - r Iptc.Application2.Keywords - r Iptc.Application2.CountryName -eoc - runTest iptcprint $tmp > $test - - #check results - diffCheck $test $good - printf "." - rm $tmp -} - -addModTest() -{ - src=$1 - tmp="temp" - test=${src}.iatst - good=$datapath/${src}.iagd - - #setup - cp $datapath/$src $tmp - - #run tests - 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 - a Iptc.Application2.Urgency 3 - m Iptc.Application2.SuppCategory "bla bla ba" - a Iptc.Envelope.ModelVersion 2 - a Iptc.Envelope.TimeSent 14:41:0-05:00 - a Iptc.Application2.RasterizedCaption 230 42 34 2 90 84 23 146 -eoc - runTest iptcprint $tmp > $test - - #check results - diffCheck $test $good - printf "." - rm $tmp -} - -extendedTest() -{ - src=$1 - tmp="temp" - test=${src}.ixtst - good=$datapath/${src}.ixgd - - #setup - cp $datapath/$src $tmp - - #run tests - runTest iptctest $tmp < $datapath/ext.dat - runTest iptcprint $tmp > $test - - #check results - diffCheck $test $good - printf "." - rm $tmp -} - - -# 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 $diffargs $test $good - if [ $? -ne 0 ]; then - errors=`expr $errors + 1` - else - rm $test - fi -} - -# ********************************************************************** -# main - -datapath="../data" -diffargs="--strip-trailing-cr" - -test_files="glider.exv \ - iptc-noAPP13.jpg \ - iptc-psAPP13-noIPTC.jpg \ - iptc-psAPP13-noIPTC-psAPP13-wIPTC.jpg \ - iptc-psAPP13s-noIPTC-psAPP13s-wIPTC.jpg \ - iptc-psAPP13s-wIPTC-psAPP13s-noIPTC.jpg \ - iptc-psAPP13s-wIPTCs-psAPP13s-wIPTCs.jpg \ - iptc-psAPP13-wIPTC1-psAPP13-wIPTC2.jpg \ - iptc-psAPP13-wIPTCbeg.jpg \ - iptc-psAPP13-wIPTCempty.jpg \ - iptc-psAPP13-wIPTCempty-psAPP13-wIPTC.jpg \ - iptc-psAPP13-wIPTCend.jpg \ - iptc-psAPP13-wIPTCmid1-wIPTCempty-wIPTCmid2.jpg \ - iptc-psAPP13-wIPTCmid.jpg \ - iptc-psAPP13-wIPTC-psAPP13-noIPTC.jpg \ - smiley1.jpg \ - smiley2.jpg \ - table.jpg" - -errors=0 -cd ./tmp -echo - -printf "Read tests" -for i in $test_files; do printTest $i; done - -echo -printf "Remove tests" -for i in $test_files; do removeTest $i; done - -echo -printf "Add/Mod tests" -for i in $test_files; do addModTest $i; done - -echo -printf "Extended tests" -for i in $test_files; do extendedTest $i; done - -printf "\n---------------------------------------------------------\n" -if [ $errors -eq 0 ]; then - echo 'All test cases passed' -else - echo $errors 'test case(s) failed!' -fi +( cd "$testdir" + + errors=0 + + test_files="glider.exv \ + iptc-noAPP13.jpg \ + iptc-psAPP13-noIPTC.jpg \ + iptc-psAPP13-noIPTC-psAPP13-wIPTC.jpg \ + iptc-psAPP13s-noIPTC-psAPP13s-wIPTC.jpg \ + iptc-psAPP13s-wIPTC-psAPP13s-noIPTC.jpg \ + iptc-psAPP13s-wIPTCs-psAPP13s-wIPTCs.jpg \ + iptc-psAPP13-wIPTC1-psAPP13-wIPTC2.jpg \ + iptc-psAPP13-wIPTCbeg.jpg \ + iptc-psAPP13-wIPTCempty.jpg \ + iptc-psAPP13-wIPTCempty-psAPP13-wIPTC.jpg \ + iptc-psAPP13-wIPTCend.jpg \ + iptc-psAPP13-wIPTCmid1-wIPTCempty-wIPTCmid2.jpg \ + iptc-psAPP13-wIPTCmid.jpg \ + iptc-psAPP13-wIPTC-psAPP13-noIPTC.jpg \ + smiley1.jpg \ + smiley2.jpg \ + table.jpg" + + echo + printf "Read tests" + for i in $test_files; do printTest $i; done + + echo + printf "Remove tests" + for i in $test_files; do removeTest $i; done + + echo + printf "Add/Mod tests" + for i in $test_files; do addModTest $i; done + + echo + printf "Extended tests" + for i in $test_files; do extendedTest $i; done + + printf "\n---------------------------------------------------------\n" + if [ $errors -eq 0 ]; then + echo 'All test cases passed' + 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 b4206409..5cfcdce8 100755 --- a/test/modify-test.sh +++ b/test/modify-test.sh @@ -2,13 +2,14 @@ # Test driver for write unit tests to build Exif metadata from scratch 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 +( cd "$testdir" + + copyTestFiles exiv2-empty.jpg exiv2-gc.jpg modifycmd1.txt modifycmd2.txt + runTest exiv2 -v -m modifycmd1.txt exiv2-empty.jpg + runTest exiv2 -v -m modifycmd2.txt exiv2-gc.jpg runTest exiv2 -v -pi exiv2-empty.jpg runTest exiv2 -v -pt exiv2-empty.jpg exiv2-gc.jpg + ) > $results reportTest diff --git a/test/path-test.sh b/test/path-test.sh index 42144c22..bae2c9b3 100755 --- a/test/path-test.sh +++ b/test/path-test.sh @@ -1,13 +1,16 @@ #!/bin/bash # Mini test-driver for path utility functions source ./functions.source -cd ./tmp -if [ $(existsTest path-test) == 1 ] ; then - runTest path-test ../data/path-test.txt -else - echo "$0: path-test executable not found. Skipping path tests." -fi +( cd "$testdir" + + if [ $(existsTest path-test) == 1 ] ; then + copyTestFile path-test.txt + runTest path-test path-test.txt + else + 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 6c858a0b..53a270b1 100755 --- a/test/preview-test.sh +++ b/test/preview-test.sh @@ -4,13 +4,10 @@ # ---------------------------------------------------------------------- # Setup source ./functions.source -prepareTest -cd tmp/ +( cd "$testdir" -# ---------------------------------------------------------------------- -# Tests -images="eps/eps-flat_coreldraw-x3-lev2.eps \ + images="eps/eps-flat_coreldraw-x3-lev2.eps \ eps/eps-flat_coreldraw-x5-lev2.eps \ eps/eps-flat_inkscape-epsi.eps \ eps/eps-flat_oodraw_ai-10-lev2.eps \ @@ -101,7 +98,7 @@ images="eps/eps-flat_coreldraw-x3-lev2.eps \ iptc-psAPP13-wIPTCmid.jpg \ iptc-psAPP13-wIPTCmid1-wIPTCempty-wIPTCmid2.jpg \ smiley2.jpg" -( + for filepath in $images; do filename=`basename "$filepath"` image=`echo "$filename" | sed 's,\.[^.]*$,,'` @@ -130,6 +127,7 @@ images="eps/eps-flat_coreldraw-x3-lev2.eps \ diff -q "../data/preview/$image-preview$preview."* "$image-preview$preview."* done done + ) 3>&1 > "preview-test.out" 2>&1 echo "." diff --git a/test/stringto-test.sh b/test/stringto-test.sh index 1a26fc40..220f3f0d 100755 --- a/test/stringto-test.sh +++ b/test/stringto-test.sh @@ -1,10 +1,11 @@ #!/bin/bash # Test driver for tests of stringToLong/Float/Rational source ./functions.source -prepareTest -( +( cd "$testdir" + runTest stringto-test + ) > $results reportTest diff --git a/test/tiff-test.sh b/test/tiff-test.sh index 14a53d13..aef0a135 100644 --- a/test/tiff-test.sh +++ b/test/tiff-test.sh @@ -12,13 +12,13 @@ fi # ---------------------------------------------------------------------- # Setup source ./functions.source -prepareTest -# ---------------------------------------------------------------------- -# Main routine -( -runTest mini9.tif -exifprobe $testfile +( cd "$testdir" + + copyTestFile mini9.tif + runTest mini9.tif + exifprobe $testfile + ) > $results # ---------------------------------------------------------------------- diff --git a/test/video-test.sh b/test/video-test.sh index 79b9c65e..944d843d 100755 --- a/test/video-test.sh +++ b/test/video-test.sh @@ -10,11 +10,10 @@ # Setup source ./functions.source -cd tmp/ - # ---------------------------------------------------------------------- # Tests -( +( cd "$testdir" + for file in ../data/video/video-*; do video="`basename "$file"`" if [ $video != "video-test.out" ] ; then @@ -37,14 +36,14 @@ cd tmp/ fi fi done -) 3>&1 > "video-test.out" 2>&1 +) 3>&1 > "$testdir/video-test.out" 2>&1 echo "." # ---------------------------------------------------------------------- # Result -if ! diff -q $diffargs "../data/video/video-test.out" "video-test.out" ; then - diff -u -a $diffargs "../data/video/video-test.out" "video-test.out" +if ! diff -q $diffargs "$testdir/$datadir/video/video-test.out" "$testdir/video-test.out" ; then + diff -u -a $diffargs "$testdir/$datadir/video/video-test.out" "$testdir/video-test.out" exit 1 fi echo "All testcases passed." diff --git a/test/write-test.sh b/test/write-test.sh index 9f8ae763..a0a0832d 100755 --- a/test/write-test.sh +++ b/test/write-test.sh @@ -1,19 +1,9 @@ #!/bin/bash # Test driver for the write unit tests -# Function: -# runTestCase number file -# Params: -# number: Test case number -# file : Input file -# Abstract: -# Run the requested test case number with the given file - source ./functions.source -( - cd ./tmp - datapath=. +( cd "$testdir" images="exiv2-canon-powershot-s40.jpg \ exiv2-kodak-dc210.jpg \ @@ -25,19 +15,20 @@ source ./functions.source 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 - -) > tmp/write-test.out 2>&1 + runTestCase 1 ./exiv2-canon-powershot-s40.jpg + runTestCase 2 ./exiv2-canon-powershot-s40.jpg + runTestCase 3 ./exiv2-kodak-dc210.jpg + runTestCase 4 ./exiv2-canon-powershot-s40.jpg + runTestCase 5 ./exiv2-canon-powershot-s40.jpg + runTestCase 6 ./exiv2-kodak-dc210.jpg + runTestCase 7 ./exiv2-fujifilm-finepix-s2pro.jpg + runTestCase 8 ./exiv2-sigma-d10.jpg + runTestCase 9 ./exiv2-nikon-e990.jpg + runTestCase 10 ./exiv2-nikon-e950.jpg + runTestCase 11 ./exiv2-nikon-d70.jpg + +) > $testdir/write-test.out 2>&1 + reportTest # That's all Folks! diff --git a/test/write2-test.sh b/test/write2-test.sh index eb7f0256..d64f814e 100755 --- a/test/write2-test.sh +++ b/test/write2-test.sh @@ -3,9 +3,11 @@ source ./functions.source -( +( cd "$testdir" + copyTestFile exiv2-empty.jpg runTest write2-test exiv2-empty.jpg + ) > $results reportTest diff --git a/test/xmpparser-test.sh b/test/xmpparser-test.sh index c08c0a46..9125844f 100755 --- a/test/xmpparser-test.sh +++ b/test/xmpparser-test.sh @@ -10,8 +10,7 @@ if [ $(existsTest xmpparser-test) != 1 ] ; then exit 0 fi -( - cd ./tmp +( cd "$testdir" files=(BlueSquare.xmp StaffPhotographer-Example.xmp xmpsdk.xmp) copyTestFiles ${files[@]} @@ -32,8 +31,8 @@ fi # ---------------------------------------------------------------------- # XMP sample commands - copyTestFile exiv2-empty.jpg - runTest exiv2 -v -m ../data/cmdxmp.txt exiv2-empty.jpg + copyTestFiles exiv2-empty.jpg cmdxmp.txt + runTest exiv2 -v -m cmdxmp.txt exiv2-empty.jpg runTest exiv2 -v -px exiv2-empty.jpg ) > $results 2>&1