Merge pull request #2080 from Exiv2/main_revisePythonTest

Revise python test and dependencies to sample applications
main
Luis Díaz Más 3 years ago committed by GitHub
commit 8d2f6ad33d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -110,25 +110,28 @@ if( EXIV2_BUILD_SAMPLES )
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests
) )
add_test(NAME bugfixTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bugfixes
)
add_test(NAME lensTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose lens_tests
)
add_test(NAME tiffTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose tiff_test
)
add_test(NAME versionTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests/version_test.py
)
endif() endif()
endif() endif()
if (Python3_Interpreter_FOUND)
add_test(NAME bugfixTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bugfixes
)
add_test(NAME lensTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose lens_tests
)
add_test(NAME tiffTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose tiff_test
)
add_test(NAME versionTests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests/version_test.py
)
endif()
if( EXIV2_ENABLE_NLS ) if( EXIV2_ENABLE_NLS )
add_subdirectory( po ) add_subdirectory( po )
endif() endif()

@ -12,6 +12,9 @@ else()
endif() endif()
find_package (Python3 COMPONENTS Interpreter) find_package (Python3 COMPONENTS Interpreter)
if (NOT Python3_Interpreter_FOUND)
message(WARNING "Python3 was not found. Python tests under the 'tests' folder will not be executed")
endif()
# don't use Frameworks on the Mac (#966) # don't use Frameworks on the Mac (#966)
if (APPLE) if (APPLE)

@ -1,170 +0,0 @@
# ************************************************************* -*- Makefile -*-
#
# Copyright (C) 2004-2015 Andreas Huggel <ahuggel@gmx.net>
#
# This Makefile is part of the Exiv2 distribution.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# 3. The name of the author may not be used to endorse or promote
# products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# File: Makefile
# Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
# History: 26-Dec-04, ahu: created
#
# Description:
# Simple makefile to run the Exiv2 unit tests
#
# Restrictions:
# Only tested with GNU make.
#
# Default make target
all: test
top_srcdir = ..
# Initialisations
SHELL = /bin/bash
.SUFFIXES:
# ******************************************************************************
# Targets
.PHONY: all test mostlyclean clean distclean maintainer-clean
##
# to save download time for simple build/test, we download video and eps data on demand
SVN = svn://dev.exiv2.org/svn/testdata/trunk
# ## Sadly on SunOS make terminates saying "unexpected end of line"
# # determine the test platform
# UNAME := $(shell uname)
# UNIX=FALSE
# ifeq ($(UNAME),SunOS)
# UNIX=TRUE
# endif
# ifeq ($(UNAME),FreeBSD)
# UNIX=TRUE
# endif
##
# Add test drivers to this list
TESTS = addmoddel.sh \
conversions.sh \
crw-test.sh \
exifdata-test.sh \
exiv2-test.sh \
geotag-test.sh \
icc-test.sh \
imagetest.sh \
iotest.sh \
iptctest.sh \
iso65k-test.sh \
nls-test.sh \
modify-test.sh \
path-test.sh \
png-test.sh \
preview-test.sh \
stdin-test.sh \
stringto-test.sh \
tiff-test.sh \
webp-test.sh \
write-test.sh \
write2-test.sh \
xmpparser-test.sh
addmoddel \
conversions \
crw-test \
geotag-test \
icc-test \
iso65k-test \
modify-test \
path-test \
png-test \
stringto-test \
webp-test \
write2-test \
exifdata-test \
exiv2-test \
imagetest \
iotest \
iptctest \
nls-test \
preview-test \
tiff-test \
write-test \
xmpparser-test:
@echo
@echo ---- Running test: $@.sh ----
@echo
./$@.sh
version_test \
unit_test :
@echo
@echo ---- Running $@ ----
@echo
-@./$@.sh
tests:
make unit_test bash_tests python_tests version_test
bash_tests:
@echo
@echo ---- Running bash_tests ----
@echo
@mkdir -p tmp
@rm -rf tmp/test-failed
@list='$(TESTS)'; for p in $$list; do \
echo Running $$p ...; \
./$$p; \
rc=$$?; \
if [ $$rc -ne 0 ]; then echo '***' ; echo '***' $$p result = $$rc ; echo '***' ; fi ; \
if [ $$rc -ne 0 ]; then echo '***' $$p result = $$rc >> tmp/test-failed ; fi ; \
done
@if [ -e tmp/test-failed ]; then echo ; echo '***' FAILED ; cat tmp/test-failed ; echo '***' ; fi
python_tests:
@echo
@echo ---- Running python_tests ----
@echo
@echo bash -c 'cd ../tests; python3 runner.py'
@bash -c 'cd ../tests; python3 runner.py'
mostlyclean clean:
rm -rf $(top_srcdir)/test/tmp/*
distclean: clean
$(RM) *~ *.bak $(top_srcdir)/data/tmp
# This command is intended for maintainers
maintainer-clean: distclean
rm -rf $(top_srcdir)/data/tmp
# That's all Folks!
##

@ -1,2 +0,0 @@
The test scripts in this directory are not longer in service and will be removed in Exiv2 v0.28
The functionality of the scripts in this directory is implemented in tests/bash_tests

@ -1,16 +0,0 @@
#!/usr/bin/env bash
# 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
# That's all Folks!
##

@ -1,6 +0,0 @@
#!/usr/bin/env bash
( source ./functions.source ; cd "$bin/.." ; make bash_tests )
# That's all Folks!
##

@ -1,229 +0,0 @@
#!/usr/bin/env bash
# XMP parser test driver
# ----------------------------------------------------------------------
# Setup
source ./functions.source
# ----------------------------------------------------------------------
# Check if xmpparser-test exists
if [ $(existsTest xmpparser-test) == 0 ] ; then
echo "xmpparser-test not found. Assuming XMP support is not enabled."
exit 0
fi
( 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,<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
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 -b 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 -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.xmp.ModifyDate 2015-04-17T18:10:22Z' v.xmp
TZ=GMT-8 runTest exiv2 -iX v.jpg
runTest exiv2 -px v.jpg
# evade this test on MSVC builds (Issue #485)
platform=$(runTest exiv2 -vV 2>/dev/null | grep platform=)
if [ "$platform" == "platform=windows" -o "$platform" == "platform=mingw64" -o "$platform" == "platform=msys" ]; then
runTest exiv2 -PEkycv v.jpg | sed -E -e 's#1. 1.:10:22#18 02:10:22#g'
else
runTest exiv2 -PEkycv v.jpg
fi
runTest exiv2 -pi v.jpg
# 16) https://github.com/Exiv2/exiv2/issues/521
echo
echo Testcase 16
echo ===========
copyTestFile DSC_3079.jpg
runTest exiv2 -px DSC_3079.jpg
runTest exiv2 -M"del Xmp.mwg-rs.Regions" DSC_3079.jpg
runTest exiv2 -px DSC_3079.jpg
) > $results 2>&1
reportTest
# That's all Folks!
##

@ -1,39 +0,0 @@
#!/usr/bin/env bash
# Test driver for CRW file operations
source ./functions.source
(
cd "$testdir"
crwfile=exiv2-canon-powershot-s40.crw
# ----------------------------------------------------------------------
# Testcases: Add and modify tags
cmdfile=cmdfile1
( echo set Exif.Photo.ColorSpace 65535
echo set Exif.Canon.OwnerName Different owner
echo set Exif.Canon.FirmwareVersion Whatever version
echo set Exif.Canon.SerialNumber 1
echo add Exif.Canon.SerialNumber 2
echo set Exif.Photo.ISOSpeedRatings 155
echo set Exif.Photo.DateTimeOriginal 2007:11:11 09:10:11
echo set Exif.Image.DateTime 2020:05:26 07:31:41
echo set Exif.Photo.DateTimeDigitized 2020:05:26 07:31:42
) > $cmdfile
copyTestFile $crwfile
runTest exiv2 -v -pt $crwfile
runTest exiv2 -v -m$cmdfile $crwfile
runTest exiv2 -v -pt $crwfile
# ----------------------------------------------------------------------
# Testcases: Delete tags
copyTestFile $crwfile
runTest exiv2 -v -pt $crwfile
runTest exiv2 -v -M'del Exif.Canon.OwnerName' $crwfile
runTest exiv2 -v -pt $crwfile
) 2>&1 | sed -e 's#19:54#18:54#g' > $results # sed evades TZ issue on MSVC builds #1221
reportTest
# That's all Folks!
##

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# 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
runTest exifdata-test exiv2-canon-powershot-s40.jpg
runTest exifdata-test exiv2-nikon-d70.jpg
) > $results 2>&1
reportTest
# That's all Folks!
##

@ -1,122 +0,0 @@
#!/usr/bin/env bash
# Test driver for exiv2 utility tests
source ./functions.source
if [ "$PLATFORM" == SunOS -o "$PLATFORM" == FreeBSD -o "$PLATFORM" == NetBSD ] ; then
diffargs="-w $diffargs"
else
diffargs="-w --text $diffargs"
fi
( 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.
images="exiv2-empty.jpg \
exiv2-canon-powershot-s40.jpg \
exiv2-nikon-e990.jpg \
exiv2-nikon-d70.jpg \
exiv2-nikon-e950.jpg \
exiv2-canon-eos-300d.jpg \
exiv2-kodak-dc210.jpg \
exiv2-fujifilm-finepix-s2pro.jpg \
exiv2-sigma-d10.jpg \
exiv2-olympus-c8080wz.jpg \
exiv2-panasonic-dmc-fz5.jpg \
exiv2-sony-dsc-w7.jpg \
exiv2-canon-eos-20d.jpg \
exiv2-canon-eos-d30.jpg \
exiv2-canon-powershot-a520.jpg \
exiv2-photoshop.psd"
image2="exiv2-empty.jpg \
20031214_000043.jpg \
20000506_020544.jpg \
20040329_224245.jpg \
20010405_235039.jpg \
20030925_201850.jpg \
20001026_044550.jpg \
20030926_111535.jpg \
20040316_075137.jpg \
20040208_093744.jpg \
20050218_212016.jpg \
20050527_051833.jpg \
20060802_095200.jpg \
20001004_015404.jpg \
20060127_225027.jpg \
20110626_213900.psd"
image3="exiv2-empty.exv \
20031214_000043.exv \
20000506_020544.exv \
20040329_224245.exv \
20010405_235039.exv \
20030925_201850.exv \
20001026_044550.exv \
20030926_111535.exv \
20040316_075137.exv \
20040208_093744.exv \
20050218_212016.exv \
20050527_051833.exv \
20060802_095200.exv \
20001004_015404.exv \
20060127_225027.exv \
20110626_213900.exv"
for i in $images; do copyTestFile $i; done ; copyTestFile 20110626_213900.psd
echo "Exiv2 test directory -----------------------------------------------------"
cd "$testdir"
echo tmp/
echo
echo "Exiv2 version ------------------------------------------------------------"
# Tweak this to avoid a maintenance headache with test/data/exiv2-test.out
runTest exiv2 -u -V | sed -e 's#^exiv2.*$#exiv2 0.27.0.0 (__ bit build)#'
echo
echo "Exiv2 help ---------------------------------------------------------------"
runTest exiv2 -u -h
echo
echo "Adjust -------------------------------------------------------------------"
runTest exiv2 -u -v -a-12:01:01 adjust $images
echo
echo "Rename -------------------------------------------------------------------"
runTest exiv2 -u -vf rename $images
echo
echo "Print --------------------------------------------------------------------"
runTest exiv2 -u -v print $image2
runTest exiv2 -u -v -b -pt print $image2
runTest exiv2 -u -v -b -pt print $image2 > iii
echo
echo "Extract Exif data --------------------------------------------------------"
runTest exiv2 -u -vf extract $image2
echo
echo "Extract Thumbnail --------------------------------------------------------"
runTest exiv2 -u -vf -et extract $image2
runTest exiv2 -u -v -b -pt print $image3 > jjj
echo
echo "Compare image data and extracted data ------------------------------------"
diff $diffargs iii jjj
echo
echo "Delete Thumbnail ---------------------------------------------------------"
runTest exiv2 -u -v -dt delete $image2
runTest exiv2 -u -vf -et extract $image2
echo
echo "Delete Exif data ---------------------------------------------------------"
runTest exiv2 -u -v delete $image2
runTest exiv2 -u -v print $image2
echo
echo "Insert Exif data ---------------------------------------------------------"
runTest exiv2 -u -v insert $image2
runTest exiv2 -u -v -b -pt print $image3 > kkk
echo
echo "Compare original and inserted image data ---------------------------------"
diff $diffargs iii kkk
) > $results 2>&1
reportTest
# That's all Folks!
##

@ -1,507 +0,0 @@
#!/bin/bash
# Library of bash functions use by test/*.sh
# The scripts begin "source functions.source"
# Don't detab this file! removeTest() addModTest() need them!
##
# run a test
runTest()
{
local prog=$1
shift
(
mkdir -p $here/tmp
cd $here/tmp
if [ ! -z $EXIV2_ECHO ]; then
echoTest $VALGRIND $bin$prog$exe "$@"
fi
$VALGRIND $bin$prog$exe "$@"
)
}
##
# echo commands and arguments
echoTest()
{
local count=1
for i in $@ ; do
echo $((count++)): $i
done
echo -----------------------
}
##
# predictate
existsTest()
{
local prog=$1
result=0
if [ -z "$bin" ]; then
if [ ! -z $(which $prog) ]; then
result=1
fi
else
if [ -e $bin$prog -o -e $bin$prog$exe ]; then
result=1
fi
fi
echo $result
}
##
# copy file (used by conversions.sh)
copy()
{
\cp "$1" "$2"
}
##
# copy file from data to tmp (copyTestFile from to)
copyTestFile()
{
if [ $# == 2 ]; then
cp -f "$here/data/$1" "$here/tmp/$2"
elif [ $# == 1 ]; then
stub=$(basename $1)
cp -f "$here/data/$1" "$here/tmp/$stub"
else
echo "*** error copyTestFile: illegal number of inputs = $# ***"
fi
}
##
# copy 1 or more files from data to tmp
copyTestFiles()
{
for i in "$@" ; do
copyTestFile "$i" "$i"
done
}
##
# result analysis
reportTest()
{
cat $results | tr '\\' '/' > ${results}-new
mv -f ${results}-new $results
if [ $# -eq 0 ]; then
lhs=$results
rhs=$good
else
if [ $# -eq 3 ] ; then
diffargs=$1
lhs=$2
rhs=$3
else
lhs=$1
rhs=$2
fi
fi
diff $diffargs $lhs $rhs
rc=$?
if [ $rc -eq 0 ] ; then
echo "all testcases passed."
fi
}
##
# 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
rtc_infile=$2
rtc_outfile=test${rtc_number}.jpg
rtc_jpgthumb=thumb${rtc_number}.jpg
rtc_tifthumb=thumb${rtc_number}.tif
rm -f $rtc_outfile $rtc_jpgthumb $rtc_tifthumb
rm -f iii ttt;
echo "------------------------------------------------------------"
runTest exifprint $rtc_infile > iii;
cp $rtc_infile $rtc_outfile;
runTest write-test $rtc_infile $rtc_number > ttt;
diff $diffargs iii ttt
}
##
# moved here from imagetest.sh
eraseTest()
{
src=$1
test=${src}.etst
good=$datapath/${src}.egd
#setup
cp $datapath/$src $test
#run tests
${bin}metacopy $test $test
#check results
diffCheck $test $good
printf "."
}
copyTest()
{
num=$1 # case number
src=$2 # input file
dst=$3 # copy to hear
test=${dst}.c${num}tst
good=$datapath/${dst}.c${num}gd
#setup
cp $datapath/$dst $test
#run tests
${bin}metacopy -a $datapath/$src $test
#check results
diffCheck $test $good
printf "."
}
iptcTest()
{
num=$1 # case number
src=$2 # input file
dst=$3 # copy to hear
test=${dst}.i${num}tst
good=$datapath/${dst}.i${num}gd
#setup
cp $datapath/$dst $test
#run tests
runTest metacopy -ip $datapath/$src $test
#check results
diffCheck $test $good
printf "."
}
##
# Make sure to pass the test file first and the known good file second
diffCheck()
{
test=$(real_path $1)
good=$(real_path $2)
if [ -z "$errors" ]; then let -a errors=0; fi
#run diff and check results
if [ $PLATFORM == SunOS ]; then
bdiff $diffargs "$test" "$good"
elif [ $PLATFORM == FreeBSD -o $PLATFORM == NetBSD ]; then
diff $diffargs "$test" "$good"
else
diff --binary $diffargs "$test" "$good"
fi
if [ $? -ne 0 ]; then
errors=$(expr $errors + 1)
else
rm $test
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
}
##
#
hardLinkFiles()
{
target="$1"
shift
for var; do
if [ -e $var ]; then rm -rf $var ; fi
ln $target $var
done
}
##
# real_path - report the absolute path to a file
real_path ()
{
if [ "$PLATFORM" == "Darwin" -o "$PLATFORM" == "mingw" ]; then
if [ -d "$1" ]; then
cd "$1"
echo $PWD
else
cd $(dirname $1)
echo "$PWD"/$(basename "$1")
fi
else
which realpath 2>/dev/null >/dev/null
if [ $? == 0 ]; then
realpath "$1"
else
readlink -f "$1"
fi
fi
}
##
# print checksum for one file
checkSum()
{
if [ "$PLATFORM" == 'NetBSD' -o "$PLATFORM" == 'FreeBSD' -o "$PLATFORM" == 'Darwin' ]; then
md5 -q $1
else
md5sum $1 | cut -d' ' -f 1
fi
}
##
# startServer - power up the python web server
startHttpServer() {
cd "${testdir}/.." # testdir is the tmp output directory
if [ "$platform" == "platform=cygwin" ]; then dport=12762
elif [ "$platform" == "platform=mingw64" ]; then dport=12761
else dport=12760
fi
if [ ! -z "$EXIV2_PORT" ]; then port=$EXIV2_PORT ; else port=$dport ; fi
if [ ! -z "$EXIV2_HTTP" ]; then http=$EXIV2_HTTP ; else http=http://localhost; fi
exiv2_url=$http:$port
python3 -m http.server $port & # start a background local HTTP server in the "real" test directory
sleep 2 # wait for it to init or die!
exiv2_httpServer=$!
# ask the server to reply
echo $exiv2_url status = $(python3 -c "import urllib.request;print(urllib.request.urlopen('$exiv2_url/').status)")
}
##
# closeHttpServer - power down the python web server
closeHttpServer() {
if [ ! -z $exiv2_httpServer ]; then
echo kill exiv2_httpServer $exiv2_httpServer
kill $exiv2_httpServer # kill the server
fi
}
##
# prepare tmp directory and variables
prepareTest()
{
##
# locale and timezone setting
export LC_ALL=C
export TZ=BST-1
os=$(uname)
export PLATFORM=$os
if [ $os != FreeBSD -a $os != NetBSD -a $os != SunOS -a $os != Darwin -a $os != Linux ]; then
os=$(uname -o)
if [ $os == Cygwin ]; then
PLATFORM=cygwin
elif [ $os == Msys ]; then
PLATFORM=mingw
fi
fi
if [ "$PLATFORM" == cygwin -o "$PLATFORM" == mingw ]; then
exe=.exe
fi
##
# initialize globals
this=$(basename $0 .sh)
here=$PWD
datapath="../data"
testdir="$here/tmp"
datadir="../data"
if [ -z "$EXIV2_BINDIR" ] ; then
bin="$here/../build/bin/"
else
bin="$EXIV2_BINDIR/"
fi
# update PATHs to ensure we load the correct dynamic library
if [ $PLATFORM == 'mingw' -a $PLATFORM == 'cygwin' ]; then
export PATH="$bin:$PATH"
elif [ 'PLATFORM' == 'Darwin' ]; then
export DYLD_LIBRARY_PATH="$bin/../lib:$DYLD_LIBRARY_PATH"
else
export LD_LIBRARY_PATH="$bin/../lib:$LD_LIBRARY_PATH"
fi
##
# figure out arguments for diff
good="$here/data/${this}.out"
results="$here/tmp/${this}.out"
mkdir -p $here/tmp
tmpfile=$here/tmp/$this
echo '' >> $tmpfile
if [ "$PLATFORM" == SunOS -o "$PLATFORM" == FreeBSD -o "$PLATFORM" == NetBSD ] ; then
da1=""
da2=""
else
diffargs="--strip-trailing-cr"
diff -q $diffargs $tmpfile $tmpfile 2>/dev/null
if [ $? -ne 0 ]; then
diffargs=""
fi
tmpfile=tmp/ttt
echo '' >> $tmpfile
da1="--strip-trailing-cr"
diff -q $da1 $tmpfile $tmpfile 2>/dev/null
if [ $? -ne 0 ] ; then
da1=""
fi
da2="--ignore-matching-lines=^Usage:.*exiv2"
diff -q $da2 $tmpfile $tmpfile 2>/dev/null
fi
diffargs="$da1 $da2"
##
# test that exiv2 and some sample apps are in the bin!
for e in exiv2 exifprint easyaccess-test metacopy ; do
e="${bin}${e}${exe}"
if [ ! -e "$e" ]; then
echo '******************************************'
echo '***' $(real_path "$e") does not exist
echo '******************************************'
exit 42
fi
done
# set platform for msvc builds
platform=$PLATFORM
if [ $PLATFORM == mingw -o $PLATFORM == cygwin ]; then
platform=$(runTest exiv2 -vV 2>/dev/null | grep platform=)
if [ "$platform" == "platform=windows" ]; then
platform="windows"
fi
fi
}
prepareTest
# That's all Folks!
##

@ -1,25 +0,0 @@
#!/usr/bin/env bash
# Test driver for geotag
source ./functions.source
( jpg=FurnaceCreekInn.jpg
gpx=FurnaceCreekInn.gpx
copyTestFiles $jpg $gpx
echo --- show GPSInfo tags ---
runTest exiv2 -pa --grep GPSInfo $jpg
tags=$(runTest exiv2 -Pk --grep GPSInfo $jpg | tr -d '\r') # MSVC puts out cr-lf lines
echo --- deleting the GPSInfo tags
for tag in $tags; do runTest exiv2 -M"del $tag" $jpg; done
runTest exiv2 -pa --grep GPS $jpg
echo --- run geotag ---
runTest geotag -ascii -tz -8:00 $jpg $gpx | cut -d' ' -f 2-
echo --- show GPSInfo tags ---
runTest exiv2 -pa --grep GPSInfo $jpg
) > $results 2>&1
reportTest
# That's all Folks!
##

@ -1,65 +0,0 @@
#!/usr/bin/env bash
# Test driver for exiv2.exe ICC support (-pS, -pC, -eC, -iC)
source ./functions.source
test1120() # --comment and -dc clobbered by writing ICC/JPG
{
if [ "$filename" != "Reagan2.jp2" ]; then
runTest exiv2 --comment abcdefg $filename
runTest exiv2 -pS $filename
runTest exiv2 -pc $filename
runTest exiv2 -dc $filename
runTest exiv2 -pS $filename
fi
}
( cd "$testdir"
num=1074 # ICC Profile Support
printf "ICC " >&3
for filename in Reagan.jpg exiv2-bug1199.webp ReaganLargePng.png ReaganLargeJpg.jpg Reagan2.jp2 # 1272 ReaganLargeTiff.tiff
do
format=$(echo $filename|cut -d. -f 2)
stub=$( echo $filename|cut -d. -f 1)
printf $format >&3
iccname_=$stub.icc
copyTestFiles large.icc small.icc $filename
runTest exiv2 -pS $filename
runTest exiv2 -pC $filename > ${stub}_1.icc
runTest exiv2 -eC --force $filename
mv $iccname_ ${stub}_2.icc
test1120
copyTestFile large.icc $iccname_
runTest exiv2 -iC $filename
runTest exiv2 -pC $filename > ${stub}_large_1.icc
runTest exiv2 -pS $filename
runTest exiv2 -eC --force $filename
mv $iccname_ ${stub}_large_2.icc
test1120
copyTestFile small.icc $iccname_
runTest exiv2 -iC $filename
runTest exiv2 -pC $filename > ${stub}_small_1.icc
runTest exiv2 -pS $filename
runTest exiv2 -eC --force $filename
mv $iccname_ ${stub}_small_2.icc
test1120
printf " md5 " >&3
for f in ${stub} ${stub}_small ${stub}_large; do
for i in 1 2; do
checkSum ${f}_${i}.icc
done
done
done
) 3>&1 > $results 2>&1
reportTest
# That's all Folks!
##

@ -1,59 +0,0 @@
#!/usr/bin/env bash
# Test driver for image file i/o
# **********************************************************************
# main
source ./functions.source
( 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!
##

@ -1,60 +0,0 @@
#!/usr/bin/env bash
# Test driver for file i/o
source ./functions.source
( cd "$testdir"
errors=0
test_files="table.jpg smiley2.jpg ext.dat"
echo
printf "file io tests"
copyTestFiles $test_files
for i in $test_files; do runTest iotest $i s1 s2; done
printf "\n---------------------------------------------------------\n"
if [ $errors -eq 0 ]; then
echo 'All test cases passed'
else
echo $errors 'test case(s) failed!'
fi
)
sniff() {
# Format spec for stat
F='-c%s'
if [ $PLATFORM == 'Darwin' -o $PLATFORM == 'NetBSD' -o $PLATFORM == 'FreeBSD' ]; then
F='-f%z'
fi
echo $(stat $F s0 s1 s2 ../data/table.jpg) $(checkSum s0) $(checkSum s1) $(checkSum s2) $(checkSum ../data/table.jpg)
}
# Test http I/O
if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then
startHttpServer
if [ ! -z $exiv2_httpServer ]; then
( cd "${testdir}"
>&2 printf "*** HTTP tests begin\n"
cd "$testdir"
test_files="table.jpg Reagan.tiff exiv2-bug922a.jpg"
for i in $test_files; do
runTest iotest s0 s1 s2 $exiv2_url/data/$i
for t in s0 s1 s2 $exiv2_url/data/$i; do
runTest exiv2 -g City -g DateTime $t
done
done
runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 0 ; sniff
runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 10 ; sniff
runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 1000 ; sniff
>&2 printf "*** HTTP tests end\n"
) > $results
reportTest
fi
closeHttpServer
fi
# That's all Folks!
##

@ -1,54 +0,0 @@
#!/usr/bin/env bash
# Test driver for Iptc metadata
source ./functions.source
( 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!
##

@ -1,181 +0,0 @@
#!/usr/bin/env bash
# test for ISOs which follow Annex G of EXIF 2.3 spec, i.e. ISOs,
# which cannot be represented by Exif.Photo.ISOSpeedRatings due to
# being larger than 65k
# All tests use the summary view as a result-check, because it uses
# the isoSpeed() "easyaccess" function, which handles the higher ISO
# readout.
#
# Tests getting executed:
#
source ./functions.source
( cd "$testdir"
num=0001
# Checks for old way of ISO readout based on the 16bit value
# input:
# - Exif.Photo.ISOSpeedRatings being set to something <65k
# output:
# - value of Exif.Photo.ISOSpeedRatings
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.ISOSpeedRatings 60001' $filename
runTest exiv2 -ps $filename
num=0002
# Old ISO is read out first, so if it doesn't indicate that
# some higher ISO is used, the 16bit value should be returned,
# ignoring the other tags (for now)
# input:
# - Exif.Photo.ISOSpeedRatings being set to something <65k
# - Exif.Photo.SensitivityType being set to "REI"
# - Exif.Photo.RecommendedExposureIndex being set to != ISOSpeedRatings
# output:
# - value of Exif.Photo.ISOSpeedRatings
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.ISOSpeedRatings 60002' $filename
runTest exiv2 -M'set Exif.Photo.SensitivityType 2' $filename
runTest exiv2 -M'set Exif.Photo.RecommendedExposureIndex 444444' $filename
runTest exiv2 -ps $filename
num=0003
# Corner case check (highest ISO value not indicating possible
# 16bit overflow in ISO)
# input:
# - Exif.Photo.ISOSpeedRatings being set to 65534
# output:
# - value of Exif.Photo.ISOSpeedRatings
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.ISOSpeedRatings 65534' $filename
runTest exiv2 -ps $filename
num=0004
# Corner case check (ISO value indicating possible overflow,
# but no additional informations available)
# input:
# - Exif.Photo.ISOSpeedRatings being set to 65535
# - Exif.Photo.SensitivityType NOT SET
# output:
# - value of Exif.Photo.ISOSpeedRatings
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.ISOSpeedRatings 65535' $filename
runTest exiv2 -ps $filename
num=0005
# possible ISO value overflow, but additional information not valid
# input:
# - Exif.Photo.ISOSpeedRatings being set to 65535
# - Exif.Photo.SensitivityType being set to 0
# output:
# - value of Exif.Photo.ISOSpeedRatings
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.ISOSpeedRatings 65535' $filename
runTest exiv2 -M'set Exif.Photo.SensitivityType 0' $filename
runTest exiv2 -ps $filename
num=0006
# possible ISO value overflow, but additional information not valid
# input:
# - Exif.Photo.ISOSpeedRatings being set to 65535
# - Exif.Photo.SensitivityType being set to 8
# output:
# - value of Exif.Photo.ISOSpeedRatings
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.ISOSpeedRatings 65535' $filename
runTest exiv2 -M'set Exif.Photo.SensitivityType 8' $filename
runTest exiv2 -ps $filename
num=0007
# possible ISO value overflow, but additional information partially valid
# input:
# - Exif.Photo.ISOSpeedRatings being set to 65535
# - Exif.Photo.SensitivityType being set to 2 ("REI")
# - Exif.Photo.RecommendedExposureIndex NOT SET
# output:
# - value of Exif.Photo.ISOSpeedRatings
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.ISOSpeedRatings 65535' $filename
runTest exiv2 -M'set Exif.Photo.SensitivityType 2' $filename
runTest exiv2 -ps $filename
num=0008
# ISO value overflow, REI contains same value as 16bit ISO, though
# input:
# - Exif.Photo.ISOSpeedRatings being set to 65535
# - Exif.Photo.SensitivityType being set to 2 ("REI")
# - Exif.Photo.RecommendedExposureIndex set to 65530
# output:
# - value of Exif.Photo.RecommendedExposureIndex
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.ISOSpeedRatings 65535' $filename
runTest exiv2 -M'set Exif.Photo.SensitivityType 2' $filename
runTest exiv2 -M'set Exif.Photo.RecommendedExposureIndex 65530' $filename
runTest exiv2 -ps $filename
num=0009
# ISO value overflow, REI contains 16bit ISO value +1
# input:
# - Exif.Photo.ISOSpeedRatings being set to 65535
# - Exif.Photo.SensitivityType being set to 2 ("REI")
# - Exif.Photo.RecommendedExposureIndex set to 65536
# output:
# - value of Exif.Photo.RecommendedExposureIndex
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.ISOSpeedRatings 65535' $filename
runTest exiv2 -M'set Exif.Photo.SensitivityType 2' $filename
runTest exiv2 -M'set Exif.Photo.RecommendedExposureIndex 65536' $filename
runTest exiv2 -ps $filename
num=0010
# old ISO not set
# input:
# - Exif.Photo.ISOSpeedRatings is NOT SET
# - Exif.Photo.SensitivityType being set to 2 ("REI")
# - Exif.Photo.RecommendedExposureIndex set to <65k
# output:
# - value of Exif.Photo.RecommendedExposureIndex
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.SensitivityType 2' $filename
runTest exiv2 -M'set Exif.Photo.RecommendedExposureIndex 60010' $filename
runTest exiv2 -ps $filename
num=0011
# old ISO not set
# input:
# - Exif.Photo.ISOSpeedRatings is NOT SET
# - Exif.Photo.SensitivityType being set to 2 ("REI")
# - Exif.Photo.RecommendedExposureIndex set to >65k
# output:
# - value of Exif.Photo.RecommendedExposureIndex
echo '------>' iso65k test $num '<-------' >&2
filename=exiv2-iso65k-$num.jpg
copyTestFile exiv2-empty.jpg $filename
runTest exiv2 -M'set Exif.Photo.SensitivityType 2' $filename
runTest exiv2 -M'set Exif.Photo.RecommendedExposureIndex 100011' $filename
runTest exiv2 -ps $filename
) > $testdir/iso65k-test.out 2>&1
reportTest

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# Test driver for write unit tests to build Exif metadata from scratch
source ./functions.source
( 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
# That's all Folks!
##

@ -1,49 +0,0 @@
#!/usr/bin/env bash
# Test driver for exiv2.exe nls support
source ./functions.source
( cd "$testdir"
nls=$(runTest exiv2 -vVg nls|tail -1)
platform=$(${bin}exiv2${exe} -vVg platform|tail -1)
if [ "$nls" != "enable_nls=1" ]; then
echo "exiv2 not build with nls"
exit 0
fi
if [ "$platform" == "platform=windows" ]; then
echo "nls_test cannot be run msvc builds" >2
exit 0
fi
if [ "$platform" == "platform=linux" ]; then
LANG=LANGUAGE
else
LANG=LANG
fi
##
# if necessary ditto /usr/local/share/locale -> build/share/locale
share=${bin}../share
if [ ! -e $share ]; then
mkdir -p $share
fi
usr=/usr/local/share/locale
if [ -e "$usr" -a -e "$share" ]; then
cp -r "$usr" "$share"
else
echo "localisation files are not installed in $usr"
exit 0
fi
##
# test a couple of languages
for l in fr_FR es_ES; do
export LC_ALL=$l
export $LANG=$l
runTest exiv2 2>&1 | head -n 1
done
) 3>&1 > $results 2>&1
reportTest
# That's all Folks!
##

@ -1,16 +0,0 @@
#!/usr/bin/env bash
# Mini test-driver for path utility functions
source ./functions.source
( 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!
##

@ -1,23 +0,0 @@
#!/usr/bin/env bash
# Test PNG support (-pS, -pc, -pa -c )
source ./functions.source
( cd "$testdir"
files="1343_empty.png 1343_comment.png 1343_exif.png"
copyTestFiles $files
for file in $files ; do
for i in 1 2 ; do
runTest exiv2 -pS $file
runTest exiv2 -pc $file
runTest exiv2 -pa $file
runTest exiv2 -c 'changed comment' $file
done
done
) > $results 2>&1
reportTest
# That's all Folks!
##

@ -1,84 +0,0 @@
#!/usr/bin/env bash
# Test driver for previews
source ./functions.source
( cd "$testdir"
images="exiv2-bug443.jpg \
exiv2-bug444.jpg \
exiv2-bug445.jpg \
exiv2-bug447.jpg \
exiv2-bug501.jpg \
exiv2-bug528.jpg \
exiv2-canon-eos-20d.jpg \
exiv2-canon-eos-300d.jpg \
exiv2-canon-eos-d30.jpg \
exiv2-canon-powershot-a520.jpg \
exiv2-canon-powershot-s40.crw \
exiv2-fujifilm-finepix-s2pro.jpg \
exiv2-gc.jpg \
exiv2-kodak-dc210.jpg \
exiv2-nikon-d70.jpg \
exiv2-nikon-e950.jpg \
exiv2-nikon-e990.jpg \
exiv2-olympus-c8080wz.jpg \
exiv2-panasonic-dmc-fz5.jpg \
exiv2-photoshop.psd \
exiv2-pre-in-xmp.xmp \
exiv2-sigma-d10.jpg \
exiv2-sony-dsc-w7.jpg \
glider.exv \
imagemagick.pgf \
iptc-psAPP13-noIPTC-psAPP13-wIPTC.jpg \
iptc-psAPP13-noIPTC.jpg \
iptc-psAPP13-wIPTC-psAPP13-noIPTC.jpg \
iptc-psAPP13-wIPTC1-psAPP13-wIPTC2.jpg \
iptc-psAPP13-wIPTCbeg.jpg \
iptc-psAPP13-wIPTCempty-psAPP13-wIPTC.jpg \
iptc-psAPP13-wIPTCempty.jpg \
iptc-psAPP13-wIPTCend.jpg \
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,\.[^.]*$,,'`
printf "." >&3
echo
echo "-----> $filename <-----"
cp "../data/$filepath" ./
echo
echo "Command: exiv2 -pp $filename"
runTest exiv2 -pp "$filename" 2>/dev/null
exitcode=$?
echo "Exit code: $exitcode"
rm -f "$image-preview"*
echo
echo "Command: exiv2 -f -ep $filename"
runTest exiv2 -f -ep "$filename" 2>/dev/null
echo "Exit code: $?"
runTest exiv2 -pp "$filename" 2>/dev/null | sed -n 's,^Preview \([0-9]\+\):.*,\1,p' | while read preview; do
if [ $(uname) == SunOS ]; then
bdiff "../data/preview/$image-preview$preview."* "$image-preview$preview."*
else
diff $diffargs -q "../data/preview/$image-preview$preview."* "$image-preview$preview."*
fi
done
done
) 3>&1 > "$testdir/preview-test.out" 2>&1
echo "."
reportTest
# That's all Folks!
##

@ -1,55 +0,0 @@
#!/usr/bin/env bash
# Test driver for stdin
source ./functions.source
( cd "$testdir"
printf "stdin XMP " >&3
copyTestFile exiv2-bug1229.jpg # jpg with 2 APP1/xap segments
copyTestFile exiv2-bug1229.jpg girl.jpg
runTest exiv2 -pS girl.jpg
runTest exiv2 -dX girl.jpg # remove first
runTest exiv2 -pS girl.jpg
runTest exiv2 -pX exiv2-bug1229.jpg | runTest exiv2 -iXX- girl.jpg
runTest exiv2 -pS girl.jpg
copyTestFile exiv2-bug1229.jpg girl.jpg
runTest exiv2 -dX girl.jpg
runTest exiv2 -dX girl.jpg
runTest exiv2 -pS girl.jpg
runTest exiv2 -pX exiv2-bug1229.jpg | runTest exiv2 -iXX- girl.jpg
runTest exiv2 -pS girl.jpg
for f in Reagan.jpg Reagan.tiff ReaganSmallPng.png; do
copyTestFile $f
runTest exiv2 -pX exiv2-bug1229.jpg | runTest exiv2 -iXX- $f
runTest exiv2 -pX $f | xmllint --format -
done
printf "a (exiv2, xmp, iptc) " >&3
for f in Reagan.jpg ReaganSmallPng.png; do
copyTestFile $f
copyTestFile exiv2-bug1229.jpg girl.jpg
runTest exiv2 -pS girl.jpg
runTest exiv2 -ea- $f | runTest exiv2 -ia- girl.jpg
runTest exiv2 -pS girl.jpg
done
printf "ICC " >&3
copyTestFile Reagan.tiff # 1272 ReaganLargeTiff.tiff
for f in Reagan.jpg ReaganSmallPng.png exiv2-bug1199.webp ; do
copyTestFile $f
runTest exiv2 -eC- Reagan.tiff | runTest exiv2 -iC- $f
runTest exiv2 -pS $f
done
) 3>&1 > $results 2>&1
printf "\n"
reportTest
# That's all Folks!
##

@ -1,14 +0,0 @@
#!/usr/bin/env bash
# Test driver for tests of stringToLong/Float/Rational
source ./functions.source
( cd "$testdir"
runTest stringto-test
) > $results
reportTest
# That's all Folks!
##

@ -1,6 +0,0 @@
#!/usr/bin/env bash
( source ./functions.source ; cd "$bin/.." ; make tests )
# That's all Folks!
##

@ -1,119 +0,0 @@
#!/usr/bin/env bash
# TIFF parser test driver
if [ "${BASH_VERSION:0:1}" -lt "4" ]; then
echo "$0 requires bash v4 or greater. Running $BASH_VERSION. $0 skipped."
exit 0
fi
exifprobe()
{
f=$1
# References
# process pipe : http://stackoverflow.com/questions/7612320/bash-weird-variable-scope-when-populating-array-with-results
# to uppercase : http://unix.stackexchange.com/questions/51983/bash-how-to-uppercase-the-command-line-argument
# ---------------------------------------
# Parse -pa output
# Exif.Image.ImageDescription Ascii 18 Created with GIMP
tags=()
typs=()
lens=()
vals=()
while read line; do
tag=$(echo $line|cut -f 3 -d. | cut -f 1 -d' ' ) ; tags+=($tag)
typ=$(echo $line|cut -f 2- -d' ' | sed -e 's/ +/ /g' -e 's/^ //' | cut -f 1 -d' ' ); typs+=($typ)
len=$(echo $line|cut -f 2- -d' ' | sed -e 's/ +/ /g' -e 's/^ //' | cut -f 2 -d' ' ); lens+=($len)
val=$(echo $line|cut -f 2- -d' ' | sed -e 's/ +/ /g' -e 's/^ //' | cut -f 3- -d' ' ); vals+=("$val")
done < <( runTest exiv2 -pa $f 2>/dev/null ) # process pipe
count=${#tags[@]}
echo exiv2 -pa output
index=0
while [ $index -lt $count ]; do
tag=${tags[$index]}
typ=${typs[$index]}
len=${lens[$index]}
val=${vals[$index]}
echo ${tag} $'\t' ${typ} $'\t' ${len} $'\t' '"'${val}'"'
index=$((index+1))
done
# Parse -pS output
# address | tag | type | count | offset | value
# 254 | 0x00fe NewSubfileType | LONG | 1 | 0 | 0
TAGS=()
TYPS=()
LENS=()
OFFS=()
VALS=()
k=0
while read line; do
k=$((k+1)) # skip the first couple of lines
if [ $k -gt 2 ]; then
TAG=$(echo $line| cut -f 2 -d'|' | cut -f 3 -d' ' ); TAGS+=($TAG);
TYP=$(echo $line| cut -f 3 -d'|' | sed -e's/ +//g' ); TYPS+=($TYP)
LEN=$(echo $line| cut -f 4 -d'|' | sed -e's/ +//g' ); LENS+=($LEN)
OFF=$(echo $line| cut -f 5 -d'|' | sed -e's/ +//g' ); OFFS+=($OFF)
VAL=$(echo $line| cut -f 6- -d'|' | sed -e's/^ //' ); VALS+=($"$VAL")
fi
done < <( runTest exiv2 -pS $f | grep -v '^END' 2>/dev/null )
COUNT=${#TAGS[@]}
echo ''
echo exiv2 -pS output
INDEX=0
while [ $INDEX -lt $COUNT ]; do
TAG=${TAGS[$INDEX]}
TYP=${TYPS[$INDEX]}
LEN=${LENS[$INDEX]}
OFF=${OFFS[$INDEX]}
VAL=${VALS[$INDEX]}
echo ${TAG} $'\t' ${TYP} $'\t' ${LEN} $'\t' '"'${VAL}'"'
INDEX=$((INDEX+1))
done
# ---------------------------------------
# Compare
echo ''
echo "Analysis"
echo "count = " $count "COUNT = " $COUNT
index=0
while [ $index -lt $count ]; do
TAG=${TAGS[$index]}
tag=${tags[$index]}
if [ "$TAG" != "$tag" ]; then echo TAG $TAG $tag mismatch ; fi
TYP=${TYPS[$index]^^} # to uppercase
typ=${typs[$index]^^}
if [ "$TYP" != "$typ" ]; then echo TYPE $TYP $typ mismatch ; fi
LEN=${LENS[$index]}
len=${lens[$index]}
if [ "$LEN" != "$len" ]; then echo Length $LEN $len mismatch ; fi
VAL=${VALS[$index]}
val=${vals[$index]}
if [[ "${typ}" == "ASCII" && "$VAL" != "$val" ]]; then echo Value $VAL $val mismatch ; fi
index=$((index+1))
done
}
# ----------------------------------------------------------------------
# Setup
source ./functions.source
( testfile=mini9.tif
copyTestFile ${testfile}
exifprobe ${testfile}
runTest tiff-test ${testfile}
exifprobe ${testfile}
) > $results 2>&1
reportTest
# That's all Folks!
##

@ -1,7 +0,0 @@
#!/usr/bin/env bash
# driver for $ make unit_test
( source ./functions.source ; runTest unit_tests --gtest_color=no 2>&1 | grep -v "Warning: Unsupported .... format" )
# That's all Folks!
##

@ -1,17 +0,0 @@
#!/usr/bin/env bash
# Test driver for exiv2.exe --verbose --version
source ./functions.source
( cd "$testdir"
# Curiously the pipe into grep causes FreeBSD to core dump!
if [ $(uname) != "FreeBSD" ]; then
runTest exiv2 --verbose --version | grep -v ^xmlns
echo xmlns entry count: $(runTest exiv2 --verbose --version | grep ^xmlns | wc -l)
else
runTest exiv2 --verbose --version
fi
)
# That's all Folks!
##

@ -1,86 +0,0 @@
#!/usr/bin/env bash
# Test driver for webp
source ./functions.source
( cd "$testdir"
num=1199 # WebPImage
printf "WebP " >&3
filename=exiv2-bug$num.webp # http://dev.exiv2.org/attachments/download/1033/Stonehenge-with-icc.webp
icc_name=exiv2-bug$num.icc
exv_name=exiv2-bug$num.exv
xmp_name=exiv2-bug$num.xmp
copyTestFile $filename
runTest exiv2 -pS $filename
runTest exiv2 -pX $filename | xmllint --format -
printf "delete " >&3
# test deleting metadata
for option in -dC -de -dx -dCe -dCx -dCxe; do
copyTestFile $filename
runTest exiv2 -pS $filename
runTest exiv2 $option $filename
runTest exiv2 -pS $filename
done
printf "insert " >&3
printf "ICC " >&3
copyTestFile $filename
runTest exiv2 -pS $filename
copyTestFile Reagan.tiff
runTest exiv2 -pC Reagan.tiff > $icc_name
runTest exiv2 -iC $filename
runTest exiv2 -pS $filename
printf "XMP " >&3
# copy the XMP from the test file
copyTestFile $filename
runTest exiv2 -pX $filename > $xmp_name;
runTest exiv2 -ea --force $filename
copyTestFile $filename
runTest exiv2 -pS $filename
runTest exiv2 -iXX $filename
runTest exiv2 -pS $filename
runTest exiv2 -ix $filename
# copy the XMP from Reagan.tiff to test file
copyTestFile Reagan.tiff
runTest exiv2 -pX Reagan.tiff > $xmp_name;
runTest exiv2 -ea --force Reagan.tiff
mv Reagan.exv $exv_name
copyTestFile $filename
runTest exiv2 -pS $filename
runTest exiv2 -iXX $filename
runTest exiv2 -pS $filename
runTest exiv2 -ix $filename
# copy the XMP from exiv2-bug922.jpg to test file
copyTestFile exiv2-bug922.jpg
runTest exiv2 -pX exiv2-bug922.jpg > $xmp_name
runTest exiv2 -ea --force exiv2-bug922.jpg 2>/dev/null
mv exiv2-bug922.exv $exv_name
copyTestFile $filename
runTest exiv2 -pS $filename
runTest exiv2 -ix $filename
runTest exiv2 -pS $filename
runTest exiv2 -iXX $filename
runTest exiv2 -pS $filename
printf "EXIF " >&3
copyTestFile exiv2-bug922.jpg $filename
runTest exiv2 --force -ea $filename
copyTestFile $filename
runTest exiv2 -pS $filename
runTest exiv2 -ie $filename
runTest exiv2 -pS $filename
) 3>&1 > $results 2>&1
reportTest
# That's all Folks!
##

@ -1,35 +0,0 @@
#!/usr/bin/env bash
# Test driver for the write unit tests
source ./functions.source
( cd "$testdir"
images="exiv2-canon-powershot-s40.jpg \
exiv2-kodak-dc210.jpg \
exiv2-fujifilm-finepix-s2pro.jpg \
exiv2-sigma-d10.jpg \
exiv2-nikon-e990.jpg \
exiv2-nikon-d70.jpg \
exiv2-nikon-e950.jpg"
copyTestFiles ${images[@]}
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!
##

@ -1,16 +0,0 @@
#!/usr/bin/env bash
# Test driver for write unit tests to build Exif metadata from scratch
source ./functions.source
( cd "$testdir"
copyTestFile exiv2-empty.jpg
runTest write2-test exiv2-empty.jpg
) > $results
reportTest
# That's all Folks!
##

@ -1,47 +0,0 @@
#!/usr/bin/env bash
# XMP parser test driver
source ./functions.source
if [ "$PLATFORM" == "SunOS" ]; then
echo "platform $PLATFORM Skip $0"
exit 0 # SunOS diff complains about newline stuff
fi
##
# Check if xmpparser-test exists
if [ $(existsTest xmpparser-test) != 1 ] ; then
echo "xmpparser-test not found. Assuming XMP support is not enabled."
exit 0
fi
( cd "$testdir"
files=(BlueSquare.xmp StaffPhotographer-Example.xmp xmpsdk.xmp)
copyTestFiles ${files[@]}
for f in ${files[@]} ; do
runTest xmpparser-test $f
diff $diffargs $f ${f}-new
done
testfile=xmpsdk.xmp
runTest xmpparse ${testfile} > t1 2>&1
runTest xmpparse ${testfile}-new > t2 2>&1
diff $diffargs t1 t2
# ----------------------------------------------------------------------
# xmpsample
runTest xmpsample
# ----------------------------------------------------------------------
# XMP sample commands
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
reportTest
# That's all Folks!
##

@ -6,6 +6,8 @@ import system_tests
@system_tests.CopyFiles("$data_path/exiv2-empty.jpg") @system_tests.CopyFiles("$data_path/exiv2-empty.jpg")
class EasyaccessTest(metaclass=system_tests.CaseMeta): class EasyaccessTest(metaclass=system_tests.CaseMeta):
url = "https://github.com/Exiv2/exiv2/pull/287"
filename = "$data_path/exiv2-empty_copy.jpg" filename = "$data_path/exiv2-empty_copy.jpg"
commands = [ commands = [

@ -6,6 +6,7 @@ class TestExifTagsInTaglist(metaclass=CaseMeta):
# The taglist program outputs lots of data on all Exif tags. # The taglist program outputs lots of data on all Exif tags.
# Extract only the keys and compare # Extract only the keys and compare
url = "https://github.com/Exiv2/exiv2/pull/1905/files"
filename = "$tmp_path/TestExifTagsInTaglist.txt" filename = "$tmp_path/TestExifTagsInTaglist.txt"
commands = ["$taglist Exif > $filename", commands = ["$taglist Exif > $filename",
"cut -d, -f5 $filename"] "cut -d, -f5 $filename"]

@ -15,40 +15,17 @@ Error: Offset of directory Image, entry 0x0117 is out of bounds: Offset = 0x3030
filename = "$data_path/cve_2017_18005_reproducer.tiff" filename = "$data_path/cve_2017_18005_reproducer.tiff"
commands = [ commands = [
"$exiv2 -vPEIXxgklnycsvth -b " + filename, "$exiv2 -vPEIXxgklnycsvth -b " + filename
"$exiv2json " + filename
] ]
stdout = ["""File 1/1: """ + filename + """ stdout = ["""File 1/1: """ + filename + """
0x0117 Image Exif.Image.StripByteCounts StripByteCounts Strip Byte Count SByte 0 0 0x0117 Image Exif.Image.StripByteCounts StripByteCounts Strip Byte Count SByte 0 0
""",
"""{
"Exif": {
"Image": {
"StripByteCounts": 0,
"0x3030": 0,
"0x3030": "",
"0x3030": 0,
"0x3030": 0,
"0x3030": 0,
"0x3030": 0,
"0x3030": 0,
"0x3030": 0,
"0x3030": 0,
"0x3030": 0,
"0x3030": 0,
"0x3030": 0,
"0x3030": 0
}
}
}
""" """
] ]
stderr = [ stderr = [
stderr_common + filename + """: No IPTC data found in the file stderr_common + filename + """: No IPTC data found in the file
""" + filename + """: No XMP data found in the file """ + filename + """: No XMP data found in the file
""", """
stderr_common
] ]
retval = [0, 0] retval = [0]

Loading…
Cancel
Save