Get Darwin to use md5 (and not the locally compiled coreutils/md5sum).

v0.27.3
clanmills 5 years ago
parent 1085e0b58f
commit b2be8e7c0c

@ -4,66 +4,66 @@
# run a test # run a test
runTest() runTest()
{ {
local prog=$1 local prog=$1
shift shift
( (
mkdir -p $here/tmp mkdir -p $here/tmp
cd $here/tmp cd $here/tmp
if [ ! -z $EXIV2_ECHO ]; then if [ ! -z $EXIV2_ECHO ]; then
echoTest $VALGRIND $bin$prog$exe "$@" echoTest $VALGRIND $bin$prog$exe "$@"
fi fi
$VALGRIND $bin$prog$exe "$@" $VALGRIND $bin$prog$exe "$@"
) )
} }
## ##
# echo commands and arguments # echo commands and arguments
echoTest() echoTest()
{ {
local count=1 local count=1
for i in $@ ; do for i in $@ ; do
echo $((count++)): $i echo $((count++)): $i
done done
echo ----------------------- echo -----------------------
} }
## ##
# predictate # predictate
existsTest() existsTest()
{ {
local prog=$1 local prog=$1
result=0 result=0
if [ -z "$bin" ]; then if [ -z "$bin" ]; then
if [ ! -z $(which $prog) ]; then if [ ! -z $(which $prog) ]; then
result=1 result=1
fi fi
else else
if [ -e $bin$prog -o -e $bin$prog$exe ]; then if [ -e $bin$prog -o -e $bin$prog$exe ]; then
result=1 result=1
fi fi
fi fi
echo $result echo $result
} }
## ##
# copy file # copy file
copy() copy()
{ {
\cp "$1" "$2" \cp "$1" "$2"
} }
## ##
# copy file from data to tmp (copyTestFile from to) # copy file from data to tmp (copyTestFile from to)
copyTestFile() copyTestFile()
{ {
if [ $# == 2 ]; then if [ $# == 2 ]; then
cp -f "$here/data/$1" "$here/tmp/$2" cp -f "$here/data/$1" "$here/tmp/$2"
elif [ $# == 1 ]; then elif [ $# == 1 ]; then
stub=$(basename $1) stub=$(basename $1)
cp -f "$here/data/$1" "$here/tmp/$stub" cp -f "$here/data/$1" "$here/tmp/$stub"
else else
echo "*** error copyTestFile: illegal number of inputs = $# ***" echo "*** error copyTestFile: illegal number of inputs = $# ***"
fi fi
} }
@ -71,9 +71,9 @@ copyTestFile()
# copy 1 or more files from data to tmp # copy 1 or more files from data to tmp
copyTestFiles() copyTestFiles()
{ {
for i in "$@" ; do for i in "$@" ; do
copyTestFile "$i" "$i" copyTestFile "$i" "$i"
done done
} }
## ##
@ -81,7 +81,7 @@ copyTestFiles()
reportTest() reportTest()
{ {
cat $results | tr '\\' '/' > ${results}-new cat $results | tr '\\' '/' > ${results}-new
mv -f ${results}-new $results mv -f ${results}-new $results
if [ ! -z `which dos2unix` ]; then if [ ! -z `which dos2unix` ]; then
dos2unix $results >/dev/null 2>&1 dos2unix $results >/dev/null 2>&1
fi fi
@ -110,7 +110,7 @@ reportTest()
echo "all testcases passed." echo "all testcases passed."
else else
diff $diffargs $lhs $rhs diff $diffargs $lhs $rhs
exit 3 exit 3
fi fi
} }
@ -292,12 +292,12 @@ removeTest()
#run tests #run tests
runTest iptctest $tmp <<-eoc runTest iptctest $tmp <<-eoc
r Iptc.Application2.Byline r Iptc.Application2.Byline
r Iptc.Application2.Caption r Iptc.Application2.Caption
r Iptc.Application2.Keywords r Iptc.Application2.Keywords
r Iptc.Application2.Keywords r Iptc.Application2.Keywords
r Iptc.Application2.Keywords r Iptc.Application2.Keywords
r Iptc.Application2.CountryName r Iptc.Application2.CountryName
eoc eoc
runTest iptcprint $tmp > $test runTest iptcprint $tmp > $test
@ -319,14 +319,14 @@ addModTest()
#run tests #run tests
runTest iptctest $tmp <<-eoc runTest iptctest $tmp <<-eoc
a Iptc.Application2.Headline The headline I am a Iptc.Application2.Headline The headline I am
a Iptc.Application2.Keywords Yet another keyword a Iptc.Application2.Keywords Yet another keyword
m Iptc.Application2.DateCreated 2004-8-3 m Iptc.Application2.DateCreated 2004-8-3
a Iptc.Application2.Urgency 3 a Iptc.Application2.Urgency 3
m Iptc.Application2.SuppCategory "bla bla ba" m Iptc.Application2.SuppCategory "bla bla ba"
a Iptc.Envelope.ModelVersion 2 a Iptc.Envelope.ModelVersion 2
a Iptc.Envelope.TimeSent 14:41:0-05:00 a Iptc.Envelope.TimeSent 14:41:0-05:00
a Iptc.Application2.RasterizedCaption 230 42 34 2 90 84 23 146 a Iptc.Application2.RasterizedCaption 230 42 34 2 90 84 23 146
eoc eoc
runTest iptcprint $tmp > $test runTest iptcprint $tmp > $test
@ -360,77 +360,76 @@ extendedTest()
# #
hardLinkFiles() hardLinkFiles()
{ {
target="$1" target="$1"
shift shift
for var; do for var; do
if [ -e $var ]; then rm -rf $var ; fi if [ -e $var ]; then rm -rf $var ; fi
ln $target $var ln $target $var
done done
} }
## ##
# real_path - report the absolute path to a file # real_path - report the absolute path to a file
real_path () real_path ()
{ {
if [ "$PLATFORM" == "Darwin" -o "$PLATFORM" == "mingw" ]; then if [ "$PLATFORM" == "Darwin" -o "$PLATFORM" == "mingw" ]; then
if [ -d "$1" ]; then if [ -d "$1" ]; then
cd "$1" cd "$1"
echo $PWD echo $PWD
else else
cd $(dirname $1) cd $(dirname $1)
echo "$PWD"/$(basename "$1") echo "$PWD"/$(basename "$1")
fi fi
else else
which realpath 2>/dev/null >/dev/null which realpath 2>/dev/null >/dev/null
if [ $? == 0 ]; then if [ $? == 0 ]; then
realpath "$1" realpath "$1"
else else
readlink -f "$1" readlink -f "$1"
fi fi
fi fi
} }
copyVideoFiles () copyVideoFiles ()
{ {
pushd "$testdir" 2>/dev/null >/dev/null pushd "$testdir" 2>/dev/null >/dev/null
## ##
# find video files data/video and copy them for testing # find video files data/video and copy them for testing
declare -a videos declare -a videos
for video in $datadir/video/* ; do for video in $datadir/video/* ; do
# http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash # http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash
ext="${video##*.}" ext="${video##*.}"
if [ $ext != out ]; then if [ $ext != out ]; then
copyTestFile "$video" copyTestFile "$video"
videos+=($(basename "$video")) videos+=($(basename "$video"))
fi fi
done done
## ##
# TODO: remove debugging code # TODO: remove debugging code
if [ "$FACTORY" == "rmills-mbp.localXX" ]; then if [ "$FACTORY" == "rmills-mbp.localXX" ]; then
for v in write-video-test.out video-test.out; do for v in write-video-test.out video-test.out; do
cp ~/gnu/exiv2/testdata/trunk/video/$v ~/gnu/exiv2/video13/test/data/video/ cp ~/gnu/exiv2/testdata/trunk/video/$v ~/gnu/exiv2/video13/test/data/video/
done done
fi fi
# http://stackoverflow.com/questions/7442417/how-to-sort-an-array-in-bash # http://stackoverflow.com/questions/7442417/how-to-sort-an-array-in-bash
# readarray -t sorted < <(printf '%s\0' "${videos[@]}" | sort -z | xargs -0n1) # readarray -t sorted < <(printf '%s\0' "${videos[@]}" | sort -z | xargs -0n1)
# echo ${videos[*]} # echo ${videos[*]}
# unset videos # unset videos
popd 2>/dev/null >/dev/null popd 2>/dev/null >/dev/null
} }
## ##
# print checksum for one file # print checksum for one file
checkSum() checkSum()
{ {
platform=$(uname) if [ "$PLATFORM" == 'NetBSD' -o "$PLATFORM" == 'FreeBSD' -o "$PLATFORM" == 'Darwin' ]; then
if [ "$platform" == 'NetBSD' -o "$platform" == 'FreeBSD' -o "$platform" == 'Darwin' ]; then md5 -q $1
md5 -q $1
else else
md5sum $1 | cut -d' ' -f 1 md5sum $1 | cut -d' ' -f 1
fi fi
} }
@ -460,7 +459,7 @@ startHttpServer() {
} }
## ##
# closeHttpServer - power down the python web server # cloaseHttpServer - power down the python web server
closeHttpServer() { closeHttpServer() {
if [ ! -z $exiv2_httpServer ]; then if [ ! -z $exiv2_httpServer ]; then
echo kill exiv2_httpServer $exiv2_httpServer echo kill exiv2_httpServer $exiv2_httpServer
@ -472,97 +471,97 @@ closeHttpServer() {
# prepare temp files and other variables # prepare temp files and other variables
prepareTest() prepareTest()
{ {
## ##
# locale and timezone setting # locale and timezone setting
export LC_ALL=C export LC_ALL=C
export TZ=BST-1 export TZ=BST-1
## ##
# initialize globals # initialize globals
this=$(basename $0 .sh) this=$(basename $0 .sh)
here=$PWD here=$PWD
datapath="../data" datapath="../data"
testdir="$here/tmp" testdir="$here/tmp"
datadir="../data" datadir="../data"
if [ -z "$EXIV2_BINDIR" ] ; then if [ -z "$EXIV2_BINDIR" ] ; then
bin="$here/../build/bin/" bin="$here/../build/bin/"
else else
bin="$EXIV2_BINDIR/" bin="$EXIV2_BINDIR/"
fi fi
os=$(uname) os=$(uname)
if [ "${os:0:4}" == "CYGW" ]; then if [ "${os:0:4}" == "CYGW" ]; then
export PLATFORM=cygwin export PLATFORM=cygwin
elif [ "${os:0:4}" == "MING" -o "${os:0:4}" == "MSYS" ]; then elif [ "${os:0:4}" == "MING" -o "${os:0:4}" == "MSYS" ]; then
export PLATFORM=mingw export PLATFORM=mingw
else else
export PLATFORM=$os export PLATFORM=$os
fi fi
if [ "$PLATFORM" == cygwin -o "$PLATFORM" == mingw ]; then if [ "$PLATFORM" == cygwin -o "$PLATFORM" == mingw ]; then
exe=.exe exe=.exe
fi fi
if [ ! -z $EXIV2_EXT ]; then if [ ! -z $EXIV2_EXT ]; then
exe=$EXIV2_EXT exe=$EXIV2_EXT
fi fi
if [ "$PLATFORM" == cygwin ]; then if [ "$PLATFORM" == cygwin ]; then
# We need a private version of diff for linux compatibility # We need a private version of diff for linux compatibility
diff() diff()
{ {
args=() args=()
for i in "$@"; do for i in "$@"; do
if [ ${i:0:1} != '-' ]; then if [ ${i:0:1} != '-' ]; then
i="$(cygpath -aw $i)" i="$(cygpath -aw $i)"
fi fi
args+=($i) args+=($i)
done done
DIFF=$(which diff) DIFF=$(which diff)
"$DIFF" ${args[@]} "$DIFF" ${args[@]}
} }
fi fi
## ##
# figure out arguments for diff # figure out arguments for diff
good="$here/data/${this}.out" good="$here/data/${this}.out"
results="$here/tmp/${this}.out" results="$here/tmp/${this}.out"
tmpfile=$here/tmp/$this tmpfile=$here/tmp/$this
echo '' >> $tmpfile echo '' >> $tmpfile
if [ "$PLATFORM" == SunOS -o "$PLATFORM" == FreeBSD -o "$PLATFORM" == NetBSD ] ; then if [ "$PLATFORM" == SunOS -o "$PLATFORM" == FreeBSD -o "$PLATFORM" == NetBSD ] ; then
da1="" da1=""
da2="" da2=""
else else
diffargs="--strip-trailing-cr" diffargs="--strip-trailing-cr"
diff -q $diffargs $tmpfile $tmpfile 2>/dev/null diff -q $diffargs $tmpfile $tmpfile 2>/dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
diffargs="" diffargs=""
fi fi
tmpfile=tmp/ttt tmpfile=tmp/ttt
echo '' >> $tmpfile echo '' >> $tmpfile
da1="--strip-trailing-cr" da1="--strip-trailing-cr"
diff -q $da1 $tmpfile $tmpfile 2>/dev/null diff -q $da1 $tmpfile $tmpfile 2>/dev/null
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
da1="" da1=""
fi fi
da2="--ignore-matching-lines=^Usage:.*exiv2" da2="--ignore-matching-lines=^Usage:.*exiv2"
diff -q $da2 $tmpfile $tmpfile 2>/dev/null diff -q $da2 $tmpfile $tmpfile 2>/dev/null
fi fi
diffargs="$da1 $da2" diffargs="$da1 $da2"
## ##
# test that exiv2 and some sample apps are in the bin! # test that exiv2 and some sample apps are in the bin!
for e in exiv2 exifprint easyaccess-test metacopy ; do for e in exiv2 exifprint easyaccess-test metacopy ; do
e="${bin}${e}${exe}" e="${bin}${e}${exe}"
if [ ! -e "$e" ]; then if [ ! -e "$e" ]; then
echo '******************************************' echo '******************************************'
echo '***' $(real_path "$e") does not exist echo '***' $(real_path "$e") does not exist
echo '******************************************' echo '******************************************'
exit 42 exit 42
fi fi
done done
} }

Loading…
Cancel
Save