Fixing file test (no remote). Replace bash variable url with exiv2_url. Simplification of iotest.sh

v0.27.3
Robin Mills 5 years ago
parent ef56e5b61e
commit 83cab13ae1

@ -450,17 +450,12 @@ startHttpServer() {
if [ ! -z $EXIV2_PORT ]; then port=$EXIV2_PORT ; else port=$dport ; 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 if [ ! -z $EXIV2_HTTP ]; then http=$EXIV2_HTTP ; else http=http://localhost; fi
url=$http:$port exiv2_url=$http:$port
jobs=$(jobs | wc -l)
python3 -m http.server $port & # start a background local HTTP server in the "real" test directory python3 -m http.server $port & # start a background local HTTP server in the "real" test directory
exiv2_httpServer=$!
sleep 2 # wait for it to init or die! sleep 2 # wait for it to init or die!
exiv2_httpServer=$!
# ask the server to reply # ask the server to reply
echo $http:$port status = $(python3 -c "import urllib.request;print(urllib.request.urlopen('$http:$port/').status)") echo $exiv2_url status = $(python3 -c "import urllib.request;print(urllib.request.urlopen('$exiv2_url/').status)")
if [ $(jobs | wc -l) == $jobs ]; then
>&2 printf "*** startHttpServer $http failed to start on port $port ***\n"
fi
} }
## ##

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Test driver for image file i/o # Test driver for file i/o
source ./functions.source source ./functions.source
@ -9,7 +9,8 @@ source ./functions.source
test_files="table.jpg smiley2.jpg ext.dat" test_files="table.jpg smiley2.jpg ext.dat"
echo echo
printf "file io tests" printf "file io tests"
for i in $test_files; do ioTest $i; done copyTestFiles $test_files
for i in $test_files; do runTest ioTest $i s1 s2; done
printf "\n---------------------------------------------------------\n" printf "\n---------------------------------------------------------\n"
if [ $errors -eq 0 ]; then if [ $errors -eq 0 ]; then
@ -19,33 +20,35 @@ source ./functions.source
fi 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 # Test http I/O
if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then
startHttpServer startHttpServer
if [ ! -z $exiv2_httpServer ]; then if [ ! -z $exiv2_httpServer ]; then
( cd "${testdir}" ( cd "${testdir}"
>&2 printf "*** HTTP tests begin\n" >&2 printf "*** HTTP tests begin\n"
cd "$testdir" cd "$testdir"
test_files="table.jpg Reagan.tiff exiv2-bug922a.jpg" test_files="table.jpg Reagan.tiff exiv2-bug922a.jpg"
for i in $test_files; do for i in $test_files; do
runTest iotest s0 s1 s2 $url/data/$i runTest iotest s0 s1 s2 $exiv2_url/data/$i
for t in s0 s1 s2 $url/data/$i; do for t in s0 s1 s2 $exiv2_url/data/$i; do
runTest exiv2 -g City -g DateTime $t runTest exiv2 -g City -g DateTime $t
done done
done done
# Format spec for stat
F='-c%s'
if [ $PLATFORM == 'Darwin' -o $PLATFORM == 'NetBSD' -o $PLATFORM == 'FreeBSD' ]; then
F='-f%z'
fi
runTest iotest s0 s1 s2 $url/data/table.jpg 1 runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 1 ; sniff
echo $(stat $F s0 s1 s2 ../data/table.jpg) $(checkSum s0) $(checkSum s1) $(checkSum s2) $(checkSum ../data/table.jpg) runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 10 ; sniff
runTest iotest s0 s1 s2 $url/data/table.jpg 10 runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 1000 ; sniff
echo $(stat $F s0 s1 s2 ../data/table.jpg) $(checkSum s0) $(checkSum s1) $(checkSum s2) $(checkSum ../data/table.jpg)
runTest iotest s0 s1 s2 $url/data/table.jpg 1000
echo $(stat $F s0 s1 s2 ../data/table.jpg) $(checkSum s0) $(checkSum s1) $(checkSum s2) $(checkSum ../data/table.jpg)
>&2 printf "*** HTTP tests end\n" >&2 printf "*** HTTP tests end\n"
) | tr -d '\r' | sed 's/[ \t]+$//' > $results ) | tr -d '\r' | sed 's/[ \t]+$//' > $results
reportTest reportTest

Loading…
Cancel
Save