diff --git a/README.md b/README.md index 2ce850e0..1b657a0f 100644 --- a/README.md +++ b/README.md @@ -753,12 +753,15 @@ Environment Variables used by test suite | Variable | Default | Platforms | Purpose | |:-- |:-- |:-- |:-- | | EXIV2_BINDIR | **\/build/bin** | All Platforms | Location of built binary objects (exiv2.exe) | -| EXIV2_PORT | **1276** | All Platforms | Test TCP/IP Port | +| EXIV2_PORT | **1277**
**1278**
**1276** | Cygwin
MinGW/msys2
Other Platforms | Test TCP/IP Port | +| EXIV2_HTTP | **http://0.0.0.0** | All Platforms | Test http server | | EXIV2_EXT | **.exe** | msvc
Cygwin
MinGW/msys2 | Extension used by executable binaries | | EXIV2_EXT | _**not set**_ | Linux
macOS
Unix| | | EXIV2_ECHO | _**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. +
### 4.1 Running tests on a UNIX-like system @@ -1168,4 +1171,4 @@ $ sudo pkg install developer/gcc-7 [TOC](#TOC) -Written by Robin Mills
robin@clanmills.com
Updated: 2020-04-23 +Written by Robin Mills
robin@clanmills.com
Updated: 2020-05-14 diff --git a/samples/iotest.cpp b/samples/iotest.cpp index 93eab545..6ef8d787 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -80,7 +80,6 @@ int main(int argc, char* const argv[]) if ( !l ) { Error(Exiv2::kerFileOpenFailed, fr, "w+b", strError()); } - std::cout << argv[4] << " length = " << l << std::endl; } FileIo fileIn(f0); diff --git a/test/data/iotest.out b/test/data/iotest.out index 8dea41da..570fbc9d 100644 --- a/test/data/iotest.out +++ b/test/data/iotest.out @@ -1,43 +1,40 @@ -http://0.0.0.0:1276/data/table.jpg length = 568 -s0 Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z -s0 Iptc.Application2.City String 7 Seattle -s1 Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z -s1 Iptc.Application2.City String 7 Seattle -s2 Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z -s2 Iptc.Application2.City String 7 Seattle -http://0.0.0.0:1276/data/table.jpg Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z -http://0.0.0.0:1276/data/table.jpg Iptc.Application2.City String 7 Seattle -http://0.0.0.0:1276/data/Reagan.tiff length = 114466 -s0 Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 -s0 Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 -s0 Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 -s0 Iptc.Application2.City String 19 Straits of Magellan -s0 Xmp.photoshop.City XmpText 19 Straits of Magellan -s1 Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 -s1 Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 -s1 Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 -s1 Iptc.Application2.City String 19 Straits of Magellan -s1 Xmp.photoshop.City XmpText 19 Straits of Magellan -s2 Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 -s2 Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 -s2 Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 -s2 Iptc.Application2.City String 19 Straits of Magellan -s2 Xmp.photoshop.City XmpText 19 Straits of Magellan -http://0.0.0.0:1276/data/Reagan.tiff Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 -http://0.0.0.0:1276/data/Reagan.tiff Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 -http://0.0.0.0:1276/data/Reagan.tiff Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 -http://0.0.0.0:1276/data/Reagan.tiff Iptc.Application2.City String 19 Straits of Magellan -http://0.0.0.0:1276/data/Reagan.tiff Xmp.photoshop.City XmpText 19 Straits of Magellan -http://0.0.0.0:1276/data/exiv2-bug922a.jpg length = 7169623 -s0 Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51 -s0 Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35 -s0 Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35 -s1 Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51 -s1 Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35 -s1 Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35 -s2 Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51 -s2 Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35 -s2 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 +Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z +Iptc.Application2.City String 7 Seattle +Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z +Iptc.Application2.City String 7 Seattle +Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z +Iptc.Application2.City String 7 Seattle +Exif.Image.DateTime Ascii 21 2004-07-13T21:23:44Z +Iptc.Application2.City String 7 Seattle +Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 +Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 +Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 +Iptc.Application2.City String 19 Straits of Magellan +Xmp.photoshop.City XmpText 19 Straits of Magellan +Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 +Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 +Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 +Iptc.Application2.City String 19 Straits of Magellan +Xmp.photoshop.City XmpText 19 Straits of Magellan +Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 +Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 +Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 +Iptc.Application2.City String 19 Straits of Magellan +Xmp.photoshop.City XmpText 19 Straits of Magellan +Exif.Image.DateTime Ascii 20 2012:04:07 16:11:27 +Exif.Photo.DateTimeOriginal Ascii 20 2004:06:21 23:37:53 +Exif.Photo.DateTimeDigitized Ascii 20 2004:06:21 23:37:53 +Iptc.Application2.City String 19 Straits of Magellan +Xmp.photoshop.City XmpText 19 Straits of Magellan +Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51 +Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35 +Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35 +Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51 +Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35 +Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35 +Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51 +Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35 +Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35 +Exif.Image.DateTime Ascii 20 2015:02:13 20:46:51 +Exif.Photo.DateTimeOriginal Ascii 20 2015:02:13 13:51:35 +Exif.Photo.DateTimeDigitized Ascii 20 2015:02:13 13:51:35 diff --git a/test/functions.source b/test/functions.source index 0f1f993e..4478eb7d 100644 --- a/test/functions.source +++ b/test/functions.source @@ -434,6 +434,40 @@ checkSum() 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 prepareTest() diff --git a/test/iotest.sh b/test/iotest.sh index ca1d4d51..a47d9ceb 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -19,32 +19,8 @@ source ./functions.source 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 -if [ $PLATFORM != mingw -a $PLATFORM != NetBSD -a $PLATFORM != SunOS -a $PLATFORM != cygwin ]; then +if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then startHttpServer if [ ! -z $exiv2_httpServer ]; then ( 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" for i in $test_files; do 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 >&2 printf "*** HTTP tests end\n" ) | tr -d '\r' | sed 's/[ \t]+$//' > $results reportTest fi closeHttpServer -else - echo "*** Http test skipped on PLATFORM $PLATFORM ***" fi # That's all Folks!