You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.0 KiB
Bash

#! /bin/sh
# Test driver for EPS files
# ----------------------------------------------------------------------
# Setup
export LC_ALL=C
cd tmp/
if [ -z "$EXIV2_BINDIR" ] ; then
bin="$VALGRIND ../../src"
samples="$VALGRIND ../../samples"
else
bin="$VALGRIND $EXIV2_BINDIR"
samples="$VALGRIND $EXIV2_BINDIR"
fi
gsed=`gsed --help >/dev/null 2>&1 && echo g`sed
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.newxmp; do
if ! grep "@Exiv2Version@" "$file" >/dev/null ; then
echo "Error: data/eps/$file contains hard-coded Exiv2 version"
exit 1
fi
done
# ----------------------------------------------------------------------
# Tests
(
for file in ../data/eps/eps-*.eps; do
image="`basename "$file" .eps`"
printf "." >&3
echo
echo "-----> $image.eps <-----"
cp "../data/eps/$image.eps" ./
echo
echo "Command: exiv2 -u -pa $image.eps"
$bin/exiv2 -u -pa "$image.eps"
exitcode="$?"
echo "Exit code: $exitcode"
if [ "$exitcode" -ne 0 -a "$exitcode" -ne 253 ] ; then
continue
fi
echo
echo "Command: exiv2 -f -eX $image.eps"
$bin/exiv2 -f -eX "$image.eps"
echo "Exit code: $?"
diff -q "../data/eps/$image.xmp" "$image.xmp"
# Using "-ix" instead of "-iX" because the latter
# executes writeMetadata() twice, making it hard to debug.
cp "../data/eps/eps-test-newxmp.xmp" "$image.exv"
echo
echo "Command: exiv2 -ix $image.eps"
$bin/exiv2 -ix "$image.eps"
exitcode="$?"
echo "Exit code: $exitcode"
if [ "$exitcode" -ne 0 ] ; then
continue
fi
$gsed "s,@Exiv2Version@,$exiv2version," < "../data/eps/$image.eps.newxmp" > "$image.eps.newxmp"
if ! diff -q "$image.eps.newxmp" "$image.eps" ; then
continue
fi
echo
echo "Command: (2) exiv2 -ix $image.eps"
$bin/exiv2 -ix "$image.eps"
echo "Exit code: $?"
diff -q "$image.eps.newxmp" "$image.eps"
# Ensure that "exiv2 -ex" won't merge metadata into the
# *.exv file generated by a previous run of the test suite.
rm -f "$image.exv"
echo
echo "Command: exiv2 -f -ex $image.eps"
$bin/exiv2 -f -ex "$image.eps"
echo "Exit code: $?"
diff -q "../data/eps/eps-test-newxmp.exv" "$image.exv"
done
) 3>&1 > "eps-test.out" 2>&1
echo "."
# ----------------------------------------------------------------------
# Result
if ! diff -q $diffargs "../data/eps/eps-test.out" "eps-test.out" ; then
diff -u $diffargs "../data/eps/eps-test.out" "eps-test.out"
exit 1
fi
echo "All testcases passed."