From 83cab13ae12f68e01c52205b5136c5e20ae723b2 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sat, 16 May 2020 08:50:42 +0100 Subject: [PATCH] Fixing file test (no remote). Replace bash variable url with exiv2_url. Simplification of iotest.sh --- test/functions.source | 11 +++-------- test/iotest.sh | 35 +++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/test/functions.source b/test/functions.source index d82080e6..ed9b73c4 100644 --- a/test/functions.source +++ b/test/functions.source @@ -450,17 +450,12 @@ startHttpServer() { 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 - url=$http:$port - jobs=$(jobs | wc -l) + exiv2_url=$http:$port 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! + exiv2_httpServer=$! # ask the server to reply - echo $http:$port status = $(python3 -c "import urllib.request;print(urllib.request.urlopen('$http:$port/').status)") - - if [ $(jobs | wc -l) == $jobs ]; then - >&2 printf "*** startHttpServer $http failed to start on port $port ***\n" - fi + echo $exiv2_url status = $(python3 -c "import urllib.request;print(urllib.request.urlopen('$exiv2_url/').status)") } ## diff --git a/test/iotest.sh b/test/iotest.sh index 8bc8a1d3..3f8e3bc8 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Test driver for image file i/o +# Test driver for file i/o source ./functions.source @@ -9,7 +9,8 @@ source ./functions.source test_files="table.jpg smiley2.jpg ext.dat" echo 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" if [ $errors -eq 0 ]; then @@ -19,33 +20,35 @@ source ./functions.source 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 $url/data/$i - for t in s0 s1 s2 $url/data/$i; 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 - # 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 - 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 10 - 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) + runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 1 ; 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" ) | tr -d '\r' | sed 's/[ \t]+$//' > $results reportTest