Polishing iotest.sh by moving functions start/closeHttpServer to functions.source. Updated documentation.

v0.27.3
clanmills 5 years ago
parent 52205c4acc
commit c0ec4cf6a4

@ -753,12 +753,15 @@ Environment Variables used by test suite
| Variable | Default | Platforms | Purpose | | Variable | Default | Platforms | Purpose |
|:-- |:-- |:-- |:-- | |:-- |:-- |:-- |:-- |
| EXIV2_BINDIR | **\<exiv2dir\>/build/bin** | All Platforms | Location of built binary objects (exiv2.exe) | | EXIV2_BINDIR | **\<exiv2dir\>/build/bin** | All Platforms | Location of built binary objects (exiv2.exe) |
| EXIV2_PORT | **1276** | All Platforms | Test TCP/IP Port | | EXIV2_PORT | **1277**<br>**1278**<br>**1276** | Cygwin<br>MinGW/msys2<br>Other Platforms | Test TCP/IP Port |
| EXIV2_HTTP | **http://0.0.0.0** | All Platforms | Test http server |
| EXIV2_EXT | **.exe** | msvc<br>Cygwin<br>MinGW/msys2 | Extension used by executable binaries | | EXIV2_EXT | **.exe** | msvc<br>Cygwin<br>MinGW/msys2 | Extension used by executable binaries |
| EXIV2_EXT | _**not set**_ | Linux<br>macOS<br>Unix| | | EXIV2_EXT | _**not set**_ | Linux<br>macOS<br>Unix| |
| EXIV2_ECHO | _**not set**_ | All Platforms | For debugging Bash scripts | | EXIV2_ECHO | _**not set**_ | All Platforms | For debugging Bash scripts |
| VALGRIND | _**not set**_ | All Platforms | For debugging Bash scripts | | VALGRIND | _**not set**_ | All Platforms | For debugging Bash scripts |
The Variables EXIV2\_PORT or EXIV2\_HTTP can be set to None to skip http tests. The http server is started with the command `python3 -m http.server $port`. On Windows, you will need to run this manually _**One**_ to authorise the firewall to permit python to use the port.
<div id="4-1"> <div id="4-1">
### 4.1 Running tests on a UNIX-like system ### 4.1 Running tests on a UNIX-like system
@ -1168,4 +1171,4 @@ $ sudo pkg install developer/gcc-7
[TOC](#TOC) [TOC](#TOC)
Written by Robin Mills<br>robin@clanmills.com<br>Updated: 2020-04-23 Written by Robin Mills<br>robin@clanmills.com<br>Updated: 2020-05-14

@ -80,7 +80,6 @@ int main(int argc, char* const argv[])
if ( !l ) { if ( !l ) {
Error(Exiv2::kerFileOpenFailed, fr, "w+b", strError()); Error(Exiv2::kerFileOpenFailed, fr, "w+b", strError());
} }
std::cout << argv[4] << " length = " << l << std::endl;
} }
FileIo fileIn(f0); FileIo fileIn(f0);

@ -1,43 +1,40 @@
http://0.0.0.0:1276/data/table.jpg length = 568 Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z
s0 Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z Iptc.Application2.City String 7 Seattle
s0 Iptc.Application2.City String 7 Seattle Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z
s1 Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z Iptc.Application2.City String 7 Seattle
s1 Iptc.Application2.City String 7 Seattle Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z
s2 Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z Iptc.Application2.City String 7 Seattle
s2 Iptc.Application2.City String 7 Seattle Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z
http://0.0.0.0:1276/data/table.jpg Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z Iptc.Application2.City String 7 Seattle
http://0.0.0.0:1276/data/table.jpg Iptc.Application2.City String 7 Seattle Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27
http://0.0.0.0:1276/data/Reagan.tiff length = 114466 Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53
s0 Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53
s0 Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 Iptc.Application2.City String 19 Straits of Magellan
s0 Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 Xmp.photoshop.City XmpText 19 Straits of Magellan
s0 Iptc.Application2.City String 19 Straits of Magellan Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27
s0 Xmp.photoshop.City XmpText 19 Straits of Magellan Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53
s1 Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53
s1 Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 Iptc.Application2.City String 19 Straits of Magellan
s1 Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 Xmp.photoshop.City XmpText 19 Straits of Magellan
s1 Iptc.Application2.City String 19 Straits of Magellan Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27
s1 Xmp.photoshop.City XmpText 19 Straits of Magellan Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53
s2 Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53
s2 Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 Iptc.Application2.City String 19 Straits of Magellan
s2 Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 Xmp.photoshop.City XmpText 19 Straits of Magellan
s2 Iptc.Application2.City String 19 Straits of Magellan Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27
s2 Xmp.photoshop.City XmpText 19 Straits of Magellan Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53
http://0.0.0.0:1276/data/Reagan.tiff Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53
http://0.0.0.0:1276/data/Reagan.tiff Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 Iptc.Application2.City String 19 Straits of Magellan
http://0.0.0.0:1276/data/Reagan.tiff Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 Xmp.photoshop.City XmpText 19 Straits of Magellan
http://0.0.0.0:1276/data/Reagan.tiff Iptc.Application2.City String 19 Straits of Magellan Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51
http://0.0.0.0:1276/data/Reagan.tiff Xmp.photoshop.City XmpText 19 Straits of Magellan Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35
http://0.0.0.0:1276/data/exiv2-bug922a.jpg length = 7169623 Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35
s0 Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51 Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51
s0 Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35 Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35
s0 Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35 Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35
s1 Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51 Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51
s1 Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35 Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35
s1 Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35 Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35
s2 Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51 Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51
s2 Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35 Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35
s2 Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35 Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35
http://0.0.0.0:1276/data/exiv2-bug922a.jpg Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51
http://0.0.0.0:1276/data/exiv2-bug922a.jpg Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35
http://0.0.0.0:1276/data/exiv2-bug922a.jpg Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35

@ -434,6 +434,40 @@ checkSum()
fi fi
} }
##
# startHttpServer - power up the python web server
startHttpServer() {
cd "${testdir}/.." # testdir is the tmp output directory
if [ "$PLATFORM" == "cygwin" ]; then dport=1277
elif [ "$PLATFORM" == "mingw" ]; then dport=1278
else dport=1276
fi
if [ ! -z $EXIV2_PORT ]; then port=$EXIV2_PORT ; else port=$dport ; fi
if [ ! -z $EXIV2_HTTP ]; then http=$EXIV2_HTTP ; else http=http://0.0.0.0; fi
url=$http:$port
jobs=$(jobs | wc -l)
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!
# ask the server to reply
echo $http:$port status = $(python3 -c "import requests;print(requests.get('$http:$port/').status_code)")
if [ $(jobs | wc -l) == $jobs ]; then
>&2 printf "*** startHttpServer $http failed to start on port $port ***\n"
fi
}
##
# cloaseHttpServer - 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 temp files and other variables # prepare temp files and other variables
prepareTest() prepareTest()

@ -19,32 +19,8 @@ source ./functions.source
fi fi
) )
# these function will be added to functions_source
startHttpServer() {
cd "${testdir}/.." # testdir is the tmp output directory
if [ ! -z $EXIV2_PORT ]; then port=$EXIV2_PORT ; else port=1276; fi
url=http://0.0.0.0:$port
jobs=$(jobs | wc -l)
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!
if [ $(jobs | wc -l) == $jobs ]; then
>&2 printf "*** startHttpServer failed to start on port $port ***\n"
fi
}
closeHttpServer() {
if [ ! -z $exiv2_httpServer ]; then
echo kill exiv2_httpServer $exiv2_httpServer
kill $exiv2_httpServer # kill the server
else
echo kill $!
kill $!
fi
}
# Test http I/O # Test http I/O
if [ $PLATFORM != mingw -a $PLATFORM != NetBSD -a $PLATFORM != SunOS -a $PLATFORM != cygwin ]; 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}"
@ -54,15 +30,15 @@ if [ $PLATFORM != mingw -a $PLATFORM != NetBSD -a $PLATFORM != SunOS -a $PLATFOR
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 $url/data/$i
runTest exiv2 -g City -g DateTime s0 s1 s2 $url/data/$i for t in s0 s1 s2 $url/data/$i; do
runTest exiv2 -g City -g DateTime $t
done
done done
>&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
fi fi
closeHttpServer closeHttpServer
else
echo "*** Http test skipped on PLATFORM $PLATFORM ***"
fi fi
# That's all Folks! # That's all Folks!

Loading…
Cancel
Save