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,16 +12,14 @@ 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 # 1) Convert Exif ImageDescription to XMP x-default langAlt value
echo Testcase 1 echo Testcase 1
echo ========== echo ==========
\cp $IMG h.jpg copyTestFile $IMG h.jpg
runTest 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 rm -f h.xmp
runTest exiv2 -eX h.jpg runTest exiv2 -eX h.jpg
@ -33,8 +31,8 @@ runTest exiv2 -pi h.xmp
echo echo
echo Testcase 2 echo Testcase 2
echo ========== echo ==========
\cp $IMG i.jpg copyTestFile $IMG i.jpg
\cp h.xmp i.xmp copy h.xmp i.xmp
runTest exiv2 -iX i.jpg runTest exiv2 -iX i.jpg
runTest exiv2 -px i.jpg runTest exiv2 -px i.jpg
runTest exiv2 -PEkycv i.jpg runTest exiv2 -PEkycv i.jpg
@ -45,7 +43,7 @@ echo
echo Testcase 3 echo Testcase 3
echo ========== echo ==========
sed s/x-default/de-DE/ i.xmp > j.xmp sed s/x-default/de-DE/ i.xmp > j.xmp
\cp $IMG j.jpg copyTestFile $IMG j.jpg
runTest exiv2 -iX j.jpg runTest exiv2 -iX j.jpg
runTest exiv2 -px j.jpg runTest exiv2 -px j.jpg
runTest exiv2 -PEkycv j.jpg runTest exiv2 -PEkycv j.jpg
@ -56,7 +54,7 @@ echo
echo Testcase 4 echo Testcase 4
echo ========== echo ==========
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 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
\cp $IMG k.jpg copyTestFile $IMG k.jpg
runTest exiv2 -iX k.jpg runTest exiv2 -iX k.jpg
runTest exiv2 -px k.jpg runTest exiv2 -px k.jpg
runTest exiv2 -v -PEkycv k.jpg runTest exiv2 -v -PEkycv k.jpg
@ -66,10 +64,10 @@ runTest exiv2 -v -pi k.jpg
echo echo
echo Testcase 5 echo Testcase 5
echo ========== echo ==========
\cp k.xmp l.xmp copy k.xmp l.xmp
runTest 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 grep x-default l.xmp
\cp $IMG l.jpg copyTestFile $IMG l.jpg
runTest exiv2 -iX l.jpg runTest exiv2 -iX l.jpg
runTest exiv2 -px l.jpg runTest exiv2 -px l.jpg
runTest exiv2 -PEkycv l.jpg runTest exiv2 -PEkycv l.jpg
@ -79,7 +77,7 @@ runTest exiv2 -pi l.jpg
echo echo
echo Testcase 6 echo Testcase 6
echo ========== echo ==========
\cp $IMG m.jpg 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 -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 runTest exiv2 -PEkycv m.jpg
rm -f m.xmp rm -f m.xmp
@ -92,8 +90,8 @@ runTest exiv2 -v -pi m.xmp
echo echo
echo Testcase 7 echo Testcase 7
echo ========== echo ==========
\cp $IMG n.jpg copyTestFile $IMG n.jpg
\cp m.xmp n.xmp copy m.xmp n.xmp
runTest exiv2 -iX n.jpg runTest exiv2 -iX n.jpg
runTest exiv2 -px n.jpg runTest exiv2 -px n.jpg
runTest exiv2 -PEkycv n.jpg runTest exiv2 -PEkycv n.jpg
@ -103,7 +101,7 @@ runTest exiv2 -v -pi n.jpg
echo echo
echo Testcase 8 echo Testcase 8
echo ========== echo ==========
\cp $IMG o.jpg copyTestFile $IMG o.jpg
runTest exiv2 -M'add Iptc.Application2.Keywords Sex' 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 Drugs' o.jpg
runTest exiv2 -M"add Iptc.Application2.Keywords Rock'n'roll" o.jpg runTest exiv2 -M"add Iptc.Application2.Keywords Rock'n'roll" o.jpg
@ -118,8 +116,8 @@ runTest exiv2 -pi o.xmp
echo echo
echo Testcase 9 echo Testcase 9
echo ========== echo ==========
\cp $IMG p.jpg copyTestFile $IMG p.jpg
\cp o.xmp p.xmp copy o.xmp p.xmp
runTest exiv2 -iX p.jpg runTest exiv2 -iX p.jpg
runTest exiv2 -px p.jpg runTest exiv2 -px p.jpg
runTest exiv2 -v -PEkycv p.jpg runTest exiv2 -v -PEkycv p.jpg
@ -129,7 +127,7 @@ runTest exiv2 -pi p.jpg
echo echo
echo Testcase 10 echo Testcase 10
echo =========== echo ===========
\cp $IMG q.jpg copyTestFile $IMG q.jpg
runTest exiv2 -M'set Exif.Image.Software Exiv2' q.jpg runTest exiv2 -M'set Exif.Image.Software Exiv2' q.jpg
runTest exiv2 -PEkycv q.jpg runTest exiv2 -PEkycv q.jpg
rm -f q.xmp rm -f q.xmp
@ -142,8 +140,8 @@ runTest exiv2 -v -pi q.xmp
echo echo
echo Testcase 11 echo Testcase 11
echo =========== echo ===========
\cp $IMG r.jpg copyTestFile $IMG r.jpg
\cp q.xmp r.xmp copy q.xmp r.xmp
runTest exiv2 -iX r.jpg runTest exiv2 -iX r.jpg
runTest exiv2 -px r.jpg runTest exiv2 -px r.jpg
runTest exiv2 -PEkycv r.jpg runTest exiv2 -PEkycv r.jpg
@ -153,7 +151,7 @@ runTest exiv2 -v -pi r.jpg
echo echo
echo Testcase 12 echo Testcase 12
echo =========== echo ===========
\cp $IMG s.jpg copyTestFile $IMG s.jpg
runTest exiv2 -M'set Iptc.Application2.SubLocation Kuala Lumpur' s.jpg runTest exiv2 -M'set Iptc.Application2.SubLocation Kuala Lumpur' s.jpg
runTest exiv2 -pi s.jpg runTest exiv2 -pi s.jpg
rm -f s.xmp rm -f s.xmp
@ -166,8 +164,8 @@ runTest exiv2 -pi s.xmp
echo echo
echo Testcase 13 echo Testcase 13
echo =========== echo ===========
\cp $IMG t.jpg copyTestFile $IMG t.jpg
\cp s.xmp t.xmp copy s.xmp t.xmp
runTest exiv2 -iX t.jpg runTest exiv2 -iX t.jpg
runTest exiv2 -px t.jpg runTest exiv2 -px t.jpg
runTest exiv2 -v -PEkycv t.jpg runTest exiv2 -v -PEkycv t.jpg
@ -177,7 +175,7 @@ runTest exiv2 -pi t.jpg
echo echo
echo Testcase 14 echo Testcase 14
echo =========== echo ===========
\cp $IMG u.jpg 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.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.SubSecTimeOriginal 999999999' u.jpg
runTest exiv2 -M'set Exif.Photo.ExifVersion 48 50 50 49' u.jpg runTest exiv2 -M'set Exif.Photo.ExifVersion 48 50 50 49' u.jpg
@ -201,8 +199,8 @@ runTest exiv2 -pi u.xmp
echo echo
echo Testcase 15 echo Testcase 15
echo =========== echo ===========
\cp $IMG v.jpg copyTestFile $IMG v.jpg
\cp u.xmp v.xmp copy u.xmp v.xmp
runTest exiv2 -M'set Xmp.tiff.DateTime 2003-12-14T12:01:44Z' v.xmp runTest exiv2 -M'set Xmp.tiff.DateTime 2003-12-14T12:01:44Z' v.xmp
TZ=GMT-8 runTest exiv2 -iX v.jpg TZ=GMT-8 runTest exiv2 -iX v.jpg
runTest exiv2 -px v.jpg runTest exiv2 -px v.jpg

@ -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/
( cd "$testdir"
##
# what version of exiv2 are we using?
exiv2version="`$bin/exiv2 -V | sed -n '1 s,^exiv2 [^ ]* \([^ ]*\).*,\1,p'`" exiv2version="`$bin/exiv2 -V | sed -n '1 s,^exiv2 [^ ]* \([^ ]*\).*,\1,p'`"
if [ -z "$exiv2version" ]; then if [ -z "$exiv2version" ]; then
echo "Error: Unable to determine Exiv2 version" echo "Error: Unable to determine Exiv2 version"
exit 1 exit 1
fi fi
diffargs="--strip-trailing-cr"
if ! diff -q $diffargs /dev/null /dev/null 2>/dev/null ; then ##
diffargs="" # ensure that no data file is already stamped with the current version
fi for file in $datadir/eps/eps-*.eps.*; do
for file in ../data/eps/eps-*.eps.*; do
if ! grep "_Exiv2Version_" "$file" >/dev/null ; then if ! grep "_Exiv2Version_" "$file" >/dev/null ; then
echo "Error: $file contains hard-coded Exiv2 version" echo "Error: $file contains hard-coded Exiv2 version"
exit 1 exit 1
fi fi
done done
# ---------------------------------------------------------------------- ##
# Tests # get down to work!
( for file in $datadir/eps/eps-*.eps; do
for file in ../data/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,7 +5,7 @@
# 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"
@ -26,9 +26,8 @@ erase_test_files="glider.exv \
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
@ -54,6 +53,7 @@ if [ $errors -eq 0 ]; then
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,52 +1,13 @@
#!/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 errors=0
cd ./tmp test_files="table.jpg smiley2.jpg ext.dat"
echo echo
printf "Io tests" printf "Io tests"
for i in $test_files; do ioTest $i; done for i in $test_files; do ioTest $i; done
@ -56,6 +17,7 @@ if [ $errors -eq 0 ]; then
else else
echo $errors 'test case(s) failed!' echo $errors 'test case(s) failed!'
fi fi
)
# That's all Folks! # That's all Folks!
## ##

@ -3,117 +3,9 @@
source ./functions.source source ./functions.source
printTest() ( cd "$testdir"
{
src=$1
test=${src}.iptst
good=$datapath/${src}.ipgd
#run tests errors=0
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 \ test_files="glider.exv \
iptc-noAPP13.jpg \ iptc-noAPP13.jpg \
@ -134,10 +26,7 @@ test_files="glider.exv \
smiley2.jpg \ smiley2.jpg \
table.jpg" table.jpg"
errors=0
cd ./tmp
echo echo
printf "Read tests" printf "Read tests"
for i in $test_files; do printTest $i; done for i in $test_files; do printTest $i; done
@ -159,6 +48,7 @@ if [ $errors -eq 0 ]; then
else else
echo $errors 'test case(s) failed!' echo $errors 'test case(s) failed!'
fi 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
( cd "$testdir"
if [ $(existsTest path-test) == 1 ] ; then if [ $(existsTest path-test) == 1 ] ; then
runTest path-test ../data/path-test.txt copyTestFile path-test.txt
runTest path-test path-test.txt
else else
echo "$0: path-test executable not found. Skipping path tests." echo "$0: path-test executable not found. Skipping path tests."
fi fi
)
# That's all Folks! # That's all Folks!
## ##

@ -4,12 +4,9 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Setup # Setup
source ./functions.source 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_coreldraw-x5-lev2.eps \
eps/eps-flat_inkscape-epsi.eps \ eps/eps-flat_inkscape-epsi.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