Issue: #850. More test script refactoring. See SVN: 2935.

v0.27.3
Robin Mills 13 years ago
parent 4dd396c278
commit f3f10c5992

@ -84,6 +84,9 @@ TESTS = addmoddel.sh \
TESTV = video-test.sh TESTV = video-test.sh
TESTE = eps-test.sh TESTE = eps-test.sh
tests:
cd .. ; make tests
test: test:
@list='$(TESTS)'; for p in $$list; do \ @list='$(TESTS)'; for p in $$list; do \
echo Running $$p ...; \ echo Running $$p ...; \

@ -2,10 +2,12 @@
# Test driver to run the addmoddel sample program # Test driver to run the addmoddel sample program
source ./functions.source source ./functions.source
( ( cd "$testdir"
copyTestFile exiv2-empty.jpg copyTestFile exiv2-empty.jpg
runTest addmoddel exiv2-empty.jpg runTest addmoddel exiv2-empty.jpg
runTest exiv2 -pv exiv2-empty.jpg runTest exiv2 -pv exiv2-empty.jpg
) > $results ) > $results
reportTest reportTest

@ -3,8 +3,7 @@
source ./functions.source source ./functions.source
( ( cd "$testdir"
cd ./tmp
num=426 num=426
filename=`prep_file $num` filename=`prep_file $num`
@ -52,7 +51,7 @@ source ./functions.source
num=480 num=480
filename=`prep_file $num` filename=`prep_file $num`
runTest largeiptc-test $filename ../data/imagemagick.png runTest largeiptc-test $filename $datadir/imagemagick.png
num=495 num=495
filename=`prep_file $num` filename=`prep_file $num`
@ -183,7 +182,8 @@ source ./functions.source
num=799 num=799
filename=`prep_empty_file $num` 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 -v -pa $filename
runTest exiv2 -f -eX $filename runTest exiv2 -f -eX $filename
cat exiv2-bug$num.xmp cat exiv2-bug$num.xmp
@ -216,7 +216,7 @@ source ./functions.source
printf "$num " >&3 printf "$num " >&3
copyTestFile $filename.rsrc $filename/rsrc copyTestFile $filename.rsrc $filename/rsrc
runTest exiv2 -M'set Exif.Photo.UserComment Test' $filename runTest exiv2 -M'set Exif.Photo.UserComment Test' $filename
diff -q ../data/$filename.rsrc $filename/rsrc diff -q $datadir/$filename.rsrc $filename/rsrc
else else
# skip this test on systems which do not have resource forks # skip this test on systems which do not have resource forks
printf "($num skipped) " >&3 printf "($num skipped) " >&3

@ -12,202 +12,200 @@ if [ $(existsTest xmpparser-test) == 0 ] ; then
exit 0 exit 0
fi fi
# ---------------------------------------------------------------------- ( cd "$testdir"
# Main routine
( IMG=exiv2-empty.jpg
cd ./tmp
IMG=../data/exiv2-empty.jpg # 1) Convert Exif ImageDescription to XMP x-default langAlt value
echo Testcase 1
# 1) Convert Exif ImageDescription to XMP x-default langAlt value echo ==========
echo Testcase 1 copyTestFile $IMG h.jpg
echo ========== runTest exiv2 -M'set Exif.Image.ImageDescription The Exif image description' h.jpg
\cp $IMG h.jpg rm -f h.xmp
runTest exiv2 -M'set Exif.Image.ImageDescription The Exif image description' h.jpg runTest exiv2 -eX h.jpg
rm -f h.xmp runTest exiv2 -px h.xmp
runTest exiv2 -eX h.jpg runTest exiv2 -PEkycv h.xmp
runTest exiv2 -px h.xmp runTest exiv2 -pi h.xmp
runTest exiv2 -PEkycv h.xmp
runTest exiv2 -pi h.xmp # 2) Convert XMP x-default langAlt value back to Exif ImageDescription
echo
# 2) Convert XMP x-default langAlt value back to Exif ImageDescription echo Testcase 2
echo echo ==========
echo Testcase 2 copyTestFile $IMG i.jpg
echo ========== copy h.xmp i.xmp
\cp $IMG i.jpg runTest exiv2 -iX i.jpg
\cp h.xmp i.xmp runTest exiv2 -px i.jpg
runTest exiv2 -iX i.jpg runTest exiv2 -PEkycv i.jpg
runTest exiv2 -px i.jpg runTest exiv2 -pi 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
# 3) Convert XMP single non-x-default langAlt value to Exif ImageDescription echo Testcase 3
echo echo ==========
echo Testcase 3 sed s/x-default/de-DE/ i.xmp > j.xmp
echo ========== copyTestFile $IMG j.jpg
sed s/x-default/de-DE/ i.xmp > j.xmp runTest exiv2 -iX j.jpg
\cp $IMG j.jpg runTest exiv2 -px j.jpg
runTest exiv2 -iX j.jpg runTest exiv2 -PEkycv j.jpg
runTest exiv2 -px j.jpg runTest exiv2 -pi 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
# 4) This shouldn't work: No x-default, more than one language echo Testcase 4
echo echo ==========
echo Testcase 4 sed 's,<rdf:li xml:lang="de-DE">The Exif image description</rdf:li>,<rdf:li xml:lang="de-DE">The Exif image description</rdf:li><rdf:li xml:lang="it-IT">Ciao bella</rdf:li>,' j.xmp > k.xmp
echo ========== copyTestFile $IMG k.jpg
sed 's,<rdf:li xml:lang="de-DE">The Exif image description</rdf:li>,<rdf:li xml:lang="de-DE">The Exif image description</rdf:li><rdf:li xml:lang="it-IT">Ciao bella</rdf:li>,' j.xmp > k.xmp runTest exiv2 -iX k.jpg
\cp $IMG k.jpg runTest exiv2 -px k.jpg
runTest exiv2 -iX k.jpg runTest exiv2 -v -PEkycv k.jpg
runTest exiv2 -px k.jpg runTest exiv2 -v -pi 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
# 5) Add a default language to the XMP file and convert to Exif and IPTC echo Testcase 5
echo echo ==========
echo Testcase 5 copy k.xmp l.xmp
echo ========== runTest exiv2 -M'set Xmp.dc.description lang="x-default" How to fix this mess' l.xmp
\cp k.xmp l.xmp grep x-default l.xmp
runTest exiv2 -M'set Xmp.dc.description lang="x-default" How to fix this mess' l.xmp copyTestFile $IMG l.jpg
grep x-default l.xmp runTest exiv2 -iX l.jpg
\cp $IMG l.jpg runTest exiv2 -px l.jpg
runTest exiv2 -iX l.jpg runTest exiv2 -PEkycv l.jpg
runTest exiv2 -px l.jpg runTest exiv2 -pi l.jpg
runTest exiv2 -PEkycv l.jpg
runTest exiv2 -pi l.jpg # 6) Convert an Exif user comment to XMP
echo
# 6) Convert an Exif user comment to XMP echo Testcase 6
echo echo ==========
echo Testcase 6 copyTestFile $IMG m.jpg
echo ========== runTest exiv2 -M'set Exif.Photo.UserComment charset=Jis This is a JIS encoded Exif user comment. Or was it?' m.jpg
\cp $IMG m.jpg runTest 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 rm -f m.xmp
runTest exiv2 -PEkycv m.jpg runTest exiv2 -eX m.jpg
rm -f m.xmp runTest exiv2 -px m.xmp
runTest exiv2 -eX m.jpg runTest exiv2 -PEkycv m.xmp
runTest exiv2 -px m.xmp runTest exiv2 -v -pi m.xmp
runTest exiv2 -PEkycv m.xmp
runTest exiv2 -v -pi m.xmp # 7) And back to Exif
echo
# 7) And back to Exif echo Testcase 7
echo echo ==========
echo Testcase 7 copyTestFile $IMG n.jpg
echo ========== copy m.xmp n.xmp
\cp $IMG n.jpg runTest exiv2 -iX n.jpg
\cp m.xmp n.xmp runTest exiv2 -px n.jpg
runTest exiv2 -iX n.jpg runTest exiv2 -PEkycv n.jpg
runTest exiv2 -px n.jpg runTest exiv2 -v -pi n.jpg
runTest exiv2 -PEkycv n.jpg
runTest exiv2 -v -pi n.jpg # 8) Convert IPTC keywords to XMP
echo
# 8) Convert IPTC keywords to XMP echo Testcase 8
echo echo ==========
echo Testcase 8 copyTestFile $IMG o.jpg
echo ========== runTest exiv2 -M'add Iptc.Application2.Keywords Sex' o.jpg
\cp $IMG o.jpg runTest exiv2 -M'add Iptc.Application2.Keywords Drugs' o.jpg
runTest exiv2 -M'add Iptc.Application2.Keywords Sex' o.jpg runTest exiv2 -M"add Iptc.Application2.Keywords Rock'n'roll" o.jpg
runTest exiv2 -M'add Iptc.Application2.Keywords Drugs' o.jpg runTest exiv2 -pi o.jpg
runTest exiv2 -M"add Iptc.Application2.Keywords Rock'n'roll" o.jpg rm -f o.xmp
runTest exiv2 -pi o.jpg runTest exiv2 -eX o.jpg
rm -f o.xmp runTest exiv2 -px o.xmp
runTest exiv2 -eX o.jpg runTest exiv2 -v -PEkycv o.xmp
runTest exiv2 -px o.xmp runTest exiv2 -pi o.xmp
runTest exiv2 -v -PEkycv o.xmp
runTest exiv2 -pi o.xmp # 9) And back to IPTC
echo
# 9) And back to IPTC echo Testcase 9
echo echo ==========
echo Testcase 9 copyTestFile $IMG p.jpg
echo ========== copy o.xmp p.xmp
\cp $IMG p.jpg runTest exiv2 -iX p.jpg
\cp o.xmp p.xmp runTest exiv2 -px p.jpg
runTest exiv2 -iX p.jpg runTest exiv2 -v -PEkycv p.jpg
runTest exiv2 -px p.jpg runTest exiv2 -pi p.jpg
runTest exiv2 -v -PEkycv p.jpg
runTest exiv2 -pi p.jpg # 10) Convert an Exif tag to an XMP text value
echo
# 10) Convert an Exif tag to an XMP text value echo Testcase 10
echo echo ===========
echo Testcase 10 copyTestFile $IMG q.jpg
echo =========== runTest exiv2 -M'set Exif.Image.Software Exiv2' q.jpg
\cp $IMG q.jpg runTest exiv2 -PEkycv q.jpg
runTest exiv2 -M'set Exif.Image.Software Exiv2' q.jpg rm -f q.xmp
runTest exiv2 -PEkycv q.jpg runTest exiv2 -eX q.jpg
rm -f q.xmp runTest exiv2 -px q.xmp
runTest exiv2 -eX q.jpg runTest exiv2 -PEkycv q.xmp
runTest exiv2 -px q.xmp runTest exiv2 -v -pi q.xmp
runTest exiv2 -PEkycv q.xmp
runTest exiv2 -v -pi q.xmp # 11) And back to Exif
echo
# 11) And back to Exif echo Testcase 11
echo echo ===========
echo Testcase 11 copyTestFile $IMG r.jpg
echo =========== copy q.xmp r.xmp
\cp $IMG r.jpg runTest exiv2 -iX r.jpg
\cp q.xmp r.xmp runTest exiv2 -px r.jpg
runTest exiv2 -iX r.jpg runTest exiv2 -PEkycv r.jpg
runTest exiv2 -px r.jpg runTest exiv2 -v -pi r.jpg
runTest exiv2 -PEkycv r.jpg
runTest exiv2 -v -pi r.jpg # 12) Convert an IPTC dataset to an XMP text value
echo
# 12) Convert an IPTC dataset to an XMP text value echo Testcase 12
echo echo ===========
echo Testcase 12 copyTestFile $IMG s.jpg
echo =========== runTest exiv2 -M'set Iptc.Application2.SubLocation Kuala Lumpur' s.jpg
\cp $IMG s.jpg runTest exiv2 -pi s.jpg
runTest exiv2 -M'set Iptc.Application2.SubLocation Kuala Lumpur' s.jpg rm -f s.xmp
runTest exiv2 -pi s.jpg runTest exiv2 -eX s.jpg
rm -f s.xmp runTest exiv2 -px s.xmp
runTest exiv2 -eX s.jpg runTest exiv2 -v -PEkycv s.xmp
runTest exiv2 -px s.xmp runTest exiv2 -pi s.xmp
runTest exiv2 -v -PEkycv s.xmp
runTest exiv2 -pi s.xmp # 13) And back to IPTC
echo
# 13) And back to IPTC echo Testcase 13
echo echo ===========
echo Testcase 13 copyTestFile $IMG t.jpg
echo =========== copy s.xmp t.xmp
\cp $IMG t.jpg runTest exiv2 -iX t.jpg
\cp s.xmp t.xmp runTest exiv2 -px t.jpg
runTest exiv2 -iX t.jpg runTest exiv2 -v -PEkycv t.jpg
runTest exiv2 -px t.jpg runTest exiv2 -pi 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
# 14) Convert a few other tags of interest from Exif/IPTC to XMP echo Testcase 14
echo echo ===========
echo Testcase 14 copyTestFile $IMG u.jpg
echo =========== runTest exiv2 -M'set Exif.Photo.DateTimeOriginal 2003:12:14 12:01:44' u.jpg
\cp $IMG u.jpg runTest exiv2 -M'set Exif.Photo.SubSecTimeOriginal 999999999' u.jpg
runTest exiv2 -M'set Exif.Photo.DateTimeOriginal 2003:12:14 12:01:44' u.jpg runTest exiv2 -M'set Exif.Photo.ExifVersion 48 50 50 49' u.jpg
runTest exiv2 -M'set Exif.Photo.SubSecTimeOriginal 999999999' u.jpg runTest exiv2 -M'set Exif.Photo.ComponentsConfiguration 1 2 3 0' u.jpg
runTest exiv2 -M'set Exif.Photo.ExifVersion 48 50 50 49' u.jpg runTest exiv2 -M'set Exif.Photo.Flash 73' u.jpg
runTest exiv2 -M'set Exif.Photo.ComponentsConfiguration 1 2 3 0' u.jpg runTest exiv2 -M'set Exif.GPSInfo.GPSLatitude 3/1 8/1 29734512/1000000' u.jpg
runTest exiv2 -M'set Exif.Photo.Flash 73' u.jpg runTest exiv2 -M'set Exif.GPSInfo.GPSLatitudeRef N' u.jpg
runTest exiv2 -M'set Exif.GPSInfo.GPSLatitude 3/1 8/1 29734512/1000000' u.jpg runTest exiv2 -M'set Exif.GPSInfo.GPSVersionID 2 2 0 1' u.jpg
runTest exiv2 -M'set Exif.GPSInfo.GPSLatitudeRef N' u.jpg runTest exiv2 -M'set Exif.GPSInfo.GPSTimeStamp 1/1 2/1 999999999/1000000000' u.jpg
runTest exiv2 -M'set Exif.GPSInfo.GPSVersionID 2 2 0 1' u.jpg runTest exiv2 -M'set Iptc.Application2.DateCreated 2007-05-09' 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
runTest exiv2 -PEkycv u.jpg rm -f u.xmp
runTest exiv2 -pi u.jpg runTest exiv2 -eX u.jpg
rm -f u.xmp runTest exiv2 -px u.xmp
runTest exiv2 -eX u.jpg runTest exiv2 -PEkycv u.xmp
runTest exiv2 -px u.xmp runTest exiv2 -pi u.xmp
runTest exiv2 -PEkycv u.xmp
runTest exiv2 -pi u.xmp # 15) And back to Exif/IPTC
echo
# 15) And back to Exif/IPTC echo Testcase 15
echo echo ===========
echo Testcase 15 copyTestFile $IMG v.jpg
echo =========== copy u.xmp v.xmp
\cp $IMG v.jpg runTest exiv2 -M'set Xmp.tiff.DateTime 2003-12-14T12:01:44Z' v.xmp
\cp u.xmp v.xmp TZ=GMT-8 runTest exiv2 -iX v.jpg
runTest exiv2 -M'set Xmp.tiff.DateTime 2003-12-14T12:01:44Z' v.xmp runTest exiv2 -px v.jpg
TZ=GMT-8 runTest exiv2 -iX v.jpg runTest exiv2 -PEkycv v.jpg
runTest exiv2 -px v.jpg runTest exiv2 -pi v.jpg
runTest exiv2 -PEkycv v.jpg
runTest exiv2 -pi v.jpg
) > $results 2>&1 ) > $results 2>&1

@ -1,31 +1,31 @@
#!/bin/bash #!/bin/bash
# Test driver for EPS files # Test driver for EPS files
# ----------------------------------------------------------------------
# Setup
source ./functions.source 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
# ---------------------------------------------------------------------- ( cd "$testdir"
# Tests
( ##
for file in ../data/eps/eps-*.eps; do # 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`" image="`basename "$file" .eps`"
printf "." >&3 printf "." >&3
@ -53,7 +53,7 @@ done
if [ "$exitcode" -eq 0 ] ; then if [ "$exitcode" -eq 0 ] ; then
# using perl instead of sed, because on some systems sed adds a line ending at EOF # 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 if ! diff -q "$image.eps.delxmp" "$image.eps" ; then
continue continue
@ -68,7 +68,7 @@ done
runTest exiv2 -f -ex "$image.eps" runTest exiv2 -f -ex "$image.eps"
echo "Exit code: $?" 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 continue
fi fi
fi fi
@ -82,7 +82,7 @@ done
runTest exiv2 -f -eX "$image.eps" runTest exiv2 -f -eX "$image.eps"
echo "Exit code: $?" 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 # Using "-ix" instead of "-iX" because the latter
# executes writeMetadata() twice, making it hard to debug. # executes writeMetadata() twice, making it hard to debug.
@ -100,7 +100,7 @@ done
fi fi
# using perl instead of sed, because on some systems sed adds a line ending at EOF # 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 if ! diff -q "$image.eps.newxmp" "$image.eps" ; then
continue continue
@ -122,16 +122,17 @@ done
runTest exiv2 -f -ex "$image.eps" runTest exiv2 -f -ex "$image.eps"
echo "Exit code: $?" echo "Exit code: $?"
diff -q "../data/eps/eps-test-newxmp.exv" "$image.exv" diff -q "$datadir/eps/eps-test-newxmp.exv" "$image.exv"
done done
) 3>&1 > "eps-test.out" 2>&1
) 3>&1 > "$testdir/eps-test.out" 2>&1
echo "." echo "."
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Result # Result
if ! diff -q $diffargs "../data/eps/eps-test.out" "eps-test.out" ; then if ! diff -q $diffargs "$testdir/$datadir/eps/eps-test.out" "$testdir/eps-test.out" ; then
diff -u $diffargs "../data/eps/eps-test.out" "eps-test.out" diff -u $diffargs "$testdir/$datadir/eps/eps-test.out" "$testdir/eps-test.out"
exit 1 exit 1
fi fi
echo "All testcases passed." echo "All testcases passed."

@ -2,7 +2,8 @@
# Test driver for exifdata copy construction and assignment unit tests # Test driver for exifdata copy construction and assignment unit tests
source ./functions.source source ./functions.source
( ( cd "$testdir"
copyTestFiles exiv2-gc.jpg exiv2-canon-powershot-s40.jpg 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-gc.jpg

@ -3,7 +3,8 @@
source ./functions.source source ./functions.source
( ( cd "$testdir"
# Add each image to the following three lists. # Add each image to the following three lists.
# The image basename in the second and third lists # The image basename in the second and third lists
# is the Exif timestamp adjusted by -12:01:01. # is the Exif timestamp adjusted by -12:01:01.
@ -58,7 +59,8 @@ source ./functions.source
for i in $images; do copyTestFile $i; done for i in $images; do copyTestFile $i; done
echo "Exiv2 test directory -----------------------------------------------------" echo "Exiv2 test directory -----------------------------------------------------"
cd tmp/ >/dev/null || exit 1; cd "$testdir"
echo tmp/ echo tmp/
echo echo
echo "Exiv2 version ------------------------------------------------------------" echo "Exiv2 version ------------------------------------------------------------"

@ -6,9 +6,11 @@ export LC_ALL=C
## ##
# initialize globals # initialize globals
this=$(basename $0 .sh) this=$(basename $0 .sh)
here=$PWD here=$PWD
datapath="../data"
testdir="$here/tmp"
datadir="../data"
if [ -z "$EXIV2_BINDIR" ] ; then if [ -z "$EXIV2_BINDIR" ] ; then
bin="$here/../bin" bin="$here/../bin"
@ -61,6 +63,13 @@ existsTest()
echo $result echo $result
} }
##
# copy file
copy()
{
\cp "$1" "$2"
}
## ##
# copy file from data to tmp (copyTestFile from to # copy file from data to tmp (copyTestFile from to
copyTestFile() copyTestFile()
@ -123,6 +132,13 @@ reportTest()
## ##
# moved here from write-test.sh # 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() runTestCase()
{ {
rtc_number=$1 rtc_number=$1
@ -234,6 +250,121 @@ diffCheck()
fi 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 # prepare temp files
prepareTest() prepareTest()

@ -5,55 +5,55 @@
# main # main
source ./functions.source source ./functions.source
datapath="../data" ( cd "$testdir"
test_files="table.jpg smiley1.jpg smiley2.jpg" test_files="table.jpg smiley1.jpg smiley2.jpg"
erase_test_files="glider.exv \ erase_test_files="glider.exv \
iptc-noAPP13.jpg \ iptc-noAPP13.jpg \
iptc-psAPP13-noIPTC.jpg \ iptc-psAPP13-noIPTC.jpg \
iptc-psAPP13-noIPTC-psAPP13-wIPTC.jpg \ iptc-psAPP13-noIPTC-psAPP13-wIPTC.jpg \
iptc-psAPP13s-noIPTC-psAPP13s-wIPTC.jpg \ iptc-psAPP13s-noIPTC-psAPP13s-wIPTC.jpg \
iptc-psAPP13s-wIPTC-psAPP13s-noIPTC.jpg \ iptc-psAPP13s-wIPTC-psAPP13s-noIPTC.jpg \
iptc-psAPP13s-wIPTCs-psAPP13s-wIPTCs.jpg \ iptc-psAPP13s-wIPTCs-psAPP13s-wIPTCs.jpg \
iptc-psAPP13-wIPTC1-psAPP13-wIPTC2.jpg \ iptc-psAPP13-wIPTC1-psAPP13-wIPTC2.jpg \
iptc-psAPP13-wIPTCbeg.jpg \ iptc-psAPP13-wIPTCbeg.jpg \
iptc-psAPP13-wIPTCempty.jpg \ iptc-psAPP13-wIPTCempty.jpg \
iptc-psAPP13-wIPTCempty-psAPP13-wIPTC.jpg \ iptc-psAPP13-wIPTCempty-psAPP13-wIPTC.jpg \
iptc-psAPP13-wIPTCend.jpg \ iptc-psAPP13-wIPTCend.jpg \
iptc-psAPP13-wIPTCmid1-wIPTCempty-wIPTCmid2.jpg \ iptc-psAPP13-wIPTCmid1-wIPTCempty-wIPTCmid2.jpg \
iptc-psAPP13-wIPTCmid.jpg \ iptc-psAPP13-wIPTCmid.jpg \
iptc-psAPP13-wIPTC-psAPP13-noIPTC.jpg" iptc-psAPP13-wIPTC-psAPP13-noIPTC.jpg"
errors=0 errors=0
cd ./tmp
echo echo
printf "Erase all tests"
printf "Erase all tests" for i in $test_files $erase_test_files; do eraseTest $i; done
for i in $test_files $erase_test_files; do eraseTest $i; done
echo
echo printf "Copy all tests"
printf "Copy all tests" c=0
c=0 for src in $test_files; do
for src in $test_files; do c=`expr $c + 1`
c=`expr $c + 1` for dst in $test_files; do copyTest $c $src $dst; done
for dst in $test_files; do copyTest $c $src $dst; done done
done
echo
echo printf "Copy iptc tests"
printf "Copy iptc tests" c=0
c=0 for src in $test_files; do
for src in $test_files; do c=`expr $c + 1`
c=`expr $c + 1` for dst in $test_files; do iptcTest $c $src $dst; done
for dst in $test_files; do iptcTest $c $src $dst; done done
done
printf "\n---------------------------------------------------------\n"
printf "\n---------------------------------------------------------\n" if [ $errors -eq 0 ]; then
if [ $errors -eq 0 ]; then echo 'All test cases passed'
echo 'All test cases passed' else
else echo $errors 'test case(s) failed!'
echo $errors 'test case(s) failed!' fi
fi )
# That's all Folks! # That's all Folks!
## ##

@ -1,61 +1,23 @@
#!/bin/bash #!/bin/bash
# Test driver for image file i/o # 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 source ./functions.source
datapath="../data" ( cd "$testdir"
test_files="table.jpg smiley2.jpg ext.dat" errors=0
test_files="table.jpg smiley2.jpg ext.dat"
errors=0 echo
cd ./tmp printf "Io tests"
echo for i in $test_files; do ioTest $i; done
printf "Io tests" printf "\n---------------------------------------------------------\n"
for i in $test_files; do ioTest $i; done if [ $errors -eq 0 ]; then
echo 'All test cases passed'
printf "\n---------------------------------------------------------\n" else
if [ $errors -eq 0 ]; then echo $errors 'test case(s) failed!'
echo 'All test cases passed' fi
else )
echo $errors 'test case(s) failed!'
fi
# That's all Folks! # That's all Folks!
## ##

@ -3,162 +3,52 @@
source ./functions.source source ./functions.source
printTest() ( cd "$testdir"
{
src=$1 errors=0
test=${src}.iptst
good=$datapath/${src}.ipgd test_files="glider.exv \
iptc-noAPP13.jpg \
#run tests iptc-psAPP13-noIPTC.jpg \
runTest iptcprint $datapath/$src > $test iptc-psAPP13-noIPTC-psAPP13-wIPTC.jpg \
iptc-psAPP13s-noIPTC-psAPP13s-wIPTC.jpg \
#check results iptc-psAPP13s-wIPTC-psAPP13s-noIPTC.jpg \
diffCheck $test $good iptc-psAPP13s-wIPTCs-psAPP13s-wIPTCs.jpg \
printf "." iptc-psAPP13-wIPTC1-psAPP13-wIPTC2.jpg \
} iptc-psAPP13-wIPTCbeg.jpg \
iptc-psAPP13-wIPTCempty.jpg \
removeTest() iptc-psAPP13-wIPTCempty-psAPP13-wIPTC.jpg \
{ iptc-psAPP13-wIPTCend.jpg \
src=$1 iptc-psAPP13-wIPTCmid1-wIPTCempty-wIPTCmid2.jpg \
tmp="temp" iptc-psAPP13-wIPTCmid.jpg \
test=${src}.irtst iptc-psAPP13-wIPTC-psAPP13-noIPTC.jpg \
good=$datapath/${src}.irgd smiley1.jpg \
smiley2.jpg \
#setup table.jpg"
cp $datapath/$src $tmp
echo
#run tests printf "Read tests"
runTest iptctest $tmp <<-eoc for i in $test_files; do printTest $i; done
r Iptc.Application2.Byline
r Iptc.Application2.Caption echo
r Iptc.Application2.Keywords printf "Remove tests"
r Iptc.Application2.Keywords for i in $test_files; do removeTest $i; done
r Iptc.Application2.Keywords
r Iptc.Application2.CountryName echo
eoc printf "Add/Mod tests"
runTest iptcprint $tmp > $test for i in $test_files; do addModTest $i; done
#check results echo
diffCheck $test $good printf "Extended tests"
printf "." for i in $test_files; do extendedTest $i; done
rm $tmp
} printf "\n---------------------------------------------------------\n"
if [ $errors -eq 0 ]; then
addModTest() echo 'All test cases passed'
{ else
src=$1 echo $errors 'test case(s) failed!'
tmp="temp" fi
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
# That's all Folks! # That's all Folks!
## ##

@ -2,13 +2,14 @@
# Test driver for write unit tests to build Exif metadata from scratch # Test driver for write unit tests to build Exif metadata from scratch
source ./functions.source source ./functions.source
( ( cd "$testdir"
copyTestFiles exiv2-empty.jpg exiv2-gc.jpg
cd ./tmp copyTestFiles exiv2-empty.jpg exiv2-gc.jpg modifycmd1.txt modifycmd2.txt
runTest exiv2 -v -m ../data/modifycmd1.txt exiv2-empty.jpg runTest exiv2 -v -m modifycmd1.txt exiv2-empty.jpg
runTest exiv2 -v -m ../data/modifycmd2.txt exiv2-gc.jpg runTest exiv2 -v -m modifycmd2.txt exiv2-gc.jpg
runTest exiv2 -v -pi exiv2-empty.jpg runTest exiv2 -v -pi exiv2-empty.jpg
runTest exiv2 -v -pt exiv2-empty.jpg exiv2-gc.jpg runTest exiv2 -v -pt exiv2-empty.jpg exiv2-gc.jpg
) > $results ) > $results
reportTest reportTest

@ -1,13 +1,16 @@
#!/bin/bash #!/bin/bash
# Mini test-driver for path utility functions # Mini test-driver for path utility functions
source ./functions.source source ./functions.source
cd ./tmp
if [ $(existsTest path-test) == 1 ] ; then ( cd "$testdir"
runTest path-test ../data/path-test.txt
else if [ $(existsTest path-test) == 1 ] ; then
echo "$0: path-test executable not found. Skipping path tests." copyTestFile path-test.txt
fi runTest path-test path-test.txt
else
echo "$0: path-test executable not found. Skipping path tests."
fi
)
# That's all Folks! # That's all Folks!
## ##

@ -4,13 +4,10 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Setup # Setup
source ./functions.source source ./functions.source
prepareTest
cd tmp/
( cd "$testdir"
# ---------------------------------------------------------------------- images="eps/eps-flat_coreldraw-x3-lev2.eps \
# Tests
images="eps/eps-flat_coreldraw-x3-lev2.eps \
eps/eps-flat_coreldraw-x5-lev2.eps \ eps/eps-flat_coreldraw-x5-lev2.eps \
eps/eps-flat_inkscape-epsi.eps \ eps/eps-flat_inkscape-epsi.eps \
eps/eps-flat_oodraw_ai-10-lev2.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-wIPTCmid.jpg \
iptc-psAPP13-wIPTCmid1-wIPTCempty-wIPTCmid2.jpg \ iptc-psAPP13-wIPTCmid1-wIPTCempty-wIPTCmid2.jpg \
smiley2.jpg" smiley2.jpg"
(
for filepath in $images; do for filepath in $images; do
filename=`basename "$filepath"` filename=`basename "$filepath"`
image=`echo "$filename" | sed 's,\.[^.]*$,,'` 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."* diff -q "../data/preview/$image-preview$preview."* "$image-preview$preview."*
done done
done done
) 3>&1 > "preview-test.out" 2>&1 ) 3>&1 > "preview-test.out" 2>&1
echo "." echo "."

@ -1,10 +1,11 @@
#!/bin/bash #!/bin/bash
# Test driver for tests of stringToLong/Float/Rational # Test driver for tests of stringToLong/Float/Rational
source ./functions.source source ./functions.source
prepareTest
( ( cd "$testdir"
runTest stringto-test runTest stringto-test
) > $results ) > $results
reportTest reportTest

@ -12,13 +12,13 @@ fi
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Setup # Setup
source ./functions.source source ./functions.source
prepareTest
# ---------------------------------------------------------------------- ( cd "$testdir"
# Main routine
( copyTestFile mini9.tif
runTest mini9.tif runTest mini9.tif
exifprobe $testfile exifprobe $testfile
) > $results ) > $results
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------

@ -10,11 +10,10 @@
# Setup # Setup
source ./functions.source source ./functions.source
cd tmp/
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Tests # Tests
( ( cd "$testdir"
for file in ../data/video/video-*; do for file in ../data/video/video-*; do
video="`basename "$file"`" video="`basename "$file"`"
if [ $video != "video-test.out" ] ; then if [ $video != "video-test.out" ] ; then
@ -37,14 +36,14 @@ cd tmp/
fi fi
fi fi
done done
) 3>&1 > "video-test.out" 2>&1 ) 3>&1 > "$testdir/video-test.out" 2>&1
echo "." echo "."
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Result # Result
if ! diff -q $diffargs "../data/video/video-test.out" "video-test.out" ; then if ! diff -q $diffargs "$testdir/$datadir/video/video-test.out" "$testdir/video-test.out" ; then
diff -u -a $diffargs "../data/video/video-test.out" "video-test.out" diff -u -a $diffargs "$testdir/$datadir/video/video-test.out" "$testdir/video-test.out"
exit 1 exit 1
fi fi
echo "All testcases passed." echo "All testcases passed."

@ -1,19 +1,9 @@
#!/bin/bash #!/bin/bash
# Test driver for the write unit tests # 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 source ./functions.source
( ( cd "$testdir"
cd ./tmp
datapath=.
images="exiv2-canon-powershot-s40.jpg \ images="exiv2-canon-powershot-s40.jpg \
exiv2-kodak-dc210.jpg \ exiv2-kodak-dc210.jpg \
@ -25,19 +15,20 @@ source ./functions.source
copyTestFiles ${images[@]} copyTestFiles ${images[@]}
runTestCase 1 $datapath/exiv2-canon-powershot-s40.jpg runTestCase 1 ./exiv2-canon-powershot-s40.jpg
runTestCase 2 $datapath/exiv2-canon-powershot-s40.jpg runTestCase 2 ./exiv2-canon-powershot-s40.jpg
runTestCase 3 $datapath/exiv2-kodak-dc210.jpg runTestCase 3 ./exiv2-kodak-dc210.jpg
runTestCase 4 $datapath/exiv2-canon-powershot-s40.jpg runTestCase 4 ./exiv2-canon-powershot-s40.jpg
runTestCase 5 $datapath/exiv2-canon-powershot-s40.jpg runTestCase 5 ./exiv2-canon-powershot-s40.jpg
runTestCase 6 $datapath/exiv2-kodak-dc210.jpg runTestCase 6 ./exiv2-kodak-dc210.jpg
runTestCase 7 $datapath/exiv2-fujifilm-finepix-s2pro.jpg runTestCase 7 ./exiv2-fujifilm-finepix-s2pro.jpg
runTestCase 8 $datapath/exiv2-sigma-d10.jpg runTestCase 8 ./exiv2-sigma-d10.jpg
runTestCase 9 $datapath/exiv2-nikon-e990.jpg runTestCase 9 ./exiv2-nikon-e990.jpg
runTestCase 10 $datapath/exiv2-nikon-e950.jpg runTestCase 10 ./exiv2-nikon-e950.jpg
runTestCase 11 $datapath/exiv2-nikon-d70.jpg runTestCase 11 ./exiv2-nikon-d70.jpg
) > tmp/write-test.out 2>&1 ) > $testdir/write-test.out 2>&1
reportTest reportTest
# That's all Folks! # That's all Folks!

@ -3,9 +3,11 @@
source ./functions.source source ./functions.source
( ( cd "$testdir"
copyTestFile exiv2-empty.jpg copyTestFile exiv2-empty.jpg
runTest write2-test exiv2-empty.jpg runTest write2-test exiv2-empty.jpg
) > $results ) > $results
reportTest reportTest

@ -10,8 +10,7 @@ if [ $(existsTest xmpparser-test) != 1 ] ; then
exit 0 exit 0
fi fi
( ( cd "$testdir"
cd ./tmp
files=(BlueSquare.xmp StaffPhotographer-Example.xmp xmpsdk.xmp) files=(BlueSquare.xmp StaffPhotographer-Example.xmp xmpsdk.xmp)
copyTestFiles ${files[@]} copyTestFiles ${files[@]}
@ -32,8 +31,8 @@ fi
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# XMP sample commands # XMP sample commands
copyTestFile exiv2-empty.jpg copyTestFiles exiv2-empty.jpg cmdxmp.txt
runTest exiv2 -v -m ../data/cmdxmp.txt exiv2-empty.jpg runTest exiv2 -v -m cmdxmp.txt exiv2-empty.jpg
runTest exiv2 -v -px exiv2-empty.jpg runTest exiv2 -v -px exiv2-empty.jpg
) > $results 2>&1 ) > $results 2>&1

Loading…
Cancel
Save