From d7652d5ae3f816662b06bd7eadf1044d2787226d Mon Sep 17 00:00:00 2001 From: clanmills Date: Wed, 22 Apr 2020 20:28:41 +0100 Subject: [PATCH 01/35] add http test to iotest.sh --- test/iotest.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/iotest.sh b/test/iotest.sh index daba5584..aab63809 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -8,7 +8,7 @@ source ./functions.source errors=0 test_files="table.jpg smiley2.jpg ext.dat" echo - printf "Io tests" + printf "file io tests" for i in $test_files; do ioTest $i; done printf "\n---------------------------------------------------------\n" @@ -19,5 +19,24 @@ source ./functions.source fi ) +# Test http I/O +( cd "${testdir}/.." # testdir is the tmp output directory + >&2 printf "*** HTTP tests begin\n" + port=9999 + url=http://0.0.0.0:$port + python3 -m http.server $port 2>&1 > /dev/null & # start a background local HTTP server in the "real" test directory + sleep 2 # wait for it to init + cd "$testdir" + test_files="table.jpg Reagan.tiff exiv2-bug922a.jpg" + for i in $test_files; do + runTest exiv2 -pa -g City -g DateTime $url/data/$i + done + >&2 printf "*** HTTP tests end\n" + kill $! # kill the server + +) | tr -d '\r' | sed 's/[ \t]+$//' > $results +reportTest + + # That's all Folks! ## \ No newline at end of file From daff2a153694ab7568c817c50b6a784371fca0f1 Mon Sep 17 00:00:00 2001 From: clanmills Date: Wed, 22 Apr 2020 21:13:39 +0100 Subject: [PATCH 02/35] Adding data/iotest.out reference file. --- test/data/iotest.out | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 test/data/iotest.out diff --git a/test/data/iotest.out b/test/data/iotest.out new file mode 100644 index 00000000..487b3abe --- /dev/null +++ b/test/data/iotest.out @@ -0,0 +1,10 @@ +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 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 From 1146031be60e60428900441ecc714d45703e3ef5 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 23 Apr 2020 08:50:24 +0100 Subject: [PATCH 03/35] Use and document EXIV2_PORT --- README.md | 7 ++++--- test/iotest.sh | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c9676ac8..2ce850e0 100644 --- a/README.md +++ b/README.md @@ -752,8 +752,9 @@ Environment Variables used by test suite | Variable | Default | Platforms | Purpose | |:-- |:-- |:-- |:-- | -| EXIV2_BINDIR | **\/build/bin** | All Platforms | Locatation of built binary object (exiv2.exe) | -| EXIV2_EXT | **.exe** | msvc
Cygwin
Msys
MinGW | Extension used by executable binaries | +| EXIV2_BINDIR | **\/build/bin** | All Platforms | Location of built binary objects (exiv2.exe) | +| EXIV2_PORT | **1276** | All Platforms | Test TCP/IP Port | +| 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 | @@ -1167,4 +1168,4 @@ $ sudo pkg install developer/gcc-7 [TOC](#TOC) -Written by Robin Mills
robin@clanmills.com
Updated: 2020-04-21 +Written by Robin Mills
robin@clanmills.com
Updated: 2020-04-23 diff --git a/test/iotest.sh b/test/iotest.sh index aab63809..a25c8534 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -21,18 +21,20 @@ source ./functions.source # Test http I/O ( cd "${testdir}/.." # testdir is the tmp output directory + >&2 printf "*** HTTP tests begin\n" - port=9999 + if [ ! -z $EXIV2_PORT ]; then port=EXIV2_PORT ; else port=1276; fi url=http://0.0.0.0:$port python3 -m http.server $port 2>&1 > /dev/null & # start a background local HTTP server in the "real" test directory sleep 2 # wait for it to init + cd "$testdir" test_files="table.jpg Reagan.tiff exiv2-bug922a.jpg" for i in $test_files; do runTest exiv2 -pa -g City -g DateTime $url/data/$i done - >&2 printf "*** HTTP tests end\n" kill $! # kill the server + >&2 printf "*** HTTP tests end\n" ) | tr -d '\r' | sed 's/[ \t]+$//' > $results reportTest From 845f0fd6c9bf61b20d1bf873a5613c8c65cc9c43 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 23 Apr 2020 12:45:52 +0100 Subject: [PATCH 04/35] added functions startHttpServer() and closeHttpServer() --- test/iotest.sh | 55 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/test/iotest.sh b/test/iotest.sh index a25c8534..991aaa08 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -19,26 +19,43 @@ source ./functions.source fi ) -# Test http I/O -( cd "${testdir}/.." # testdir is the tmp output directory - - >&2 printf "*** HTTP tests begin\n" - if [ ! -z $EXIV2_PORT ]; then port=EXIV2_PORT ; else port=1276; fi - url=http://0.0.0.0:$port - python3 -m http.server $port 2>&1 > /dev/null & # start a background local HTTP server in the "real" test directory - sleep 2 # wait for it to init - - cd "$testdir" - test_files="table.jpg Reagan.tiff exiv2-bug922a.jpg" - for i in $test_files; do - runTest exiv2 -pa -g City -g DateTime $url/data/$i - done - kill $! # kill the server - >&2 printf "*** HTTP tests end\n" - -) | tr -d '\r' | sed 's/[ \t]+$//' > $results -reportTest +# 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 + sleep 2 # wait for it to init or die! + + if [ $(jobs | wc -l) != $jobs ]; then + exiv2_httpServer=$! + else + >&2 printf "*** startHttpServer failed to start on port $port ***\n" + fi +} +closeHttpServer() { + if [ ! -z $exiv2_httpServer ]; then + kill $exiv2_httpServer # kill the server + fi +} +# Test http I/O +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 exiv2 -pa -g City -g DateTime $url/data/$i + done + >&2 printf "*** HTTP tests end\n" + ) | tr -d '\r' | sed 's/[ \t]+$//' > $results + reportTest +fi +closeHttpServer # That's all Folks! ## \ No newline at end of file From 8237569820d619b53cae72d410d22fe6e703a780 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 23 Apr 2020 16:00:26 +0100 Subject: [PATCH 05/35] Don't run http tests on test PLATFORM==mingw --- test/iotest.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/test/iotest.sh b/test/iotest.sh index 991aaa08..12eb1f8f 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -41,21 +41,25 @@ closeHttpServer() { } # Test http I/O -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 exiv2 -pa -g City -g DateTime $url/data/$i - done - >&2 printf "*** HTTP tests end\n" - ) | tr -d '\r' | sed 's/[ \t]+$//' > $results - reportTest +if [ $PLATFORM != mingw ]; 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 exiv2 -pa -g City -g DateTime $url/data/$i + 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 -closeHttpServer # That's all Folks! ## \ No newline at end of file From 60d40d0d17272d2a1a13e92ba3bb8f808d4c0995 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 23 Apr 2020 16:14:46 +0100 Subject: [PATCH 06/35] Don't run http tests on SunOS, NetBSD, Cygwin, MinGW --- test/iotest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/iotest.sh b/test/iotest.sh index 12eb1f8f..937d9a94 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -41,7 +41,7 @@ closeHttpServer() { } # Test http I/O -if [ $PLATFORM != mingw ]; then +if [ $PLATFORM != mingw -a $PLATFORM != NetBSD -a $PLATFORM != SunOS -a $PLATFORM != cygwin ]; then startHttpServer if [ ! -z $exiv2_httpServer ]; then ( cd "${testdir}" From 037849ea9ebea51cd910268f228b75952e43e6a7 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 10:31:13 +0100 Subject: [PATCH 07/35] Add optional parameter to iotest.cpp to create the input file by copying from a remote location. --- samples/iotest.cpp | 154 ++++++++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 64 deletions(-) diff --git a/samples/iotest.cpp b/samples/iotest.cpp index 774c0c43..93eab545 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -31,6 +31,7 @@ #include // for EOF #include #include +#include using Exiv2::byte; using Exiv2::BasicIo; @@ -50,81 +51,106 @@ int main(int argc, char* const argv[]) ::atexit(Exiv2::XmpParser::terminate); try { - if (argc != 4) { - std::cout << "Usage: " << argv[0] << " filein fileout1 fileout2\n"; - std::cout << "fileouts are overwritten and should match filein exactly\n"; - return 1; - } - - FileIo fileIn(argv[1]); - if (fileIn.open() != 0) { - throw Error(Exiv2::kerDataSourceOpenFailed, fileIn.path(), strError()); - } + if (argc < 4 || argc > 5 ) { + std::cout << "Usage: " << argv[0] << " filein fileout1 fileout2 [remote]\n"; + std::cout << "fileouts are overwritten and should match filein exactly\n"; + return 1; + } + const char* f0 = argv[1]; + const char* f1 = argv[2]; + const char* f2 = argv[3]; + const char* fr = argv[4]; + + if ( argc == 5 ) { + // copy fileIn from a remote location. + FILE* f = fopen(f0,"wb"); + if ( !f ) { + Error(Exiv2::kerFileOpenFailed, f0, "w+b", strError()); + } + BasicIo::AutoPtr io = Exiv2::ImageFactory::createIo(fr); + io->open(); + int l = 0 ; + Exiv2::byte b[10000]; + int r ; + while ( (r=io->read(b,sizeof(b))) > 0 ) { + l += r; + fwrite(b,r,1,f) ; + } + fclose(f); + if ( !l ) { + Error(Exiv2::kerFileOpenFailed, fr, "w+b", strError()); + } + std::cout << argv[4] << " length = " << l << std::endl; + } + + FileIo fileIn(f0); + if (fileIn.open() != 0) { + throw Error(Exiv2::kerDataSourceOpenFailed, fileIn.path(), strError()); + } - FileIo fileOut1(argv[2]); - if (fileOut1.open("w+b") != 0) { - throw Error(Exiv2::kerFileOpenFailed, argv[2], "w+b", strError()); - } + FileIo fileOut1(f1); + if (fileOut1.open("w+b") != 0) { + throw Error(Exiv2::kerFileOpenFailed, f1, "w+b", strError()); + } - MemIo memIo1; + MemIo memIo1; - // Copy to output file through memIo - memIo1.write(fileIn); - memIo1.seek(0, BasicIo::beg); - fileOut1.write(memIo1); + // Copy to output file through memIo + memIo1.write(fileIn); + memIo1.seek(0, BasicIo::beg); + fileOut1.write(memIo1); - // Make sure they are all the same size - if(fileIn.size() != memIo1.size() || memIo1.size() != fileOut1.size()) { - std::cerr << argv[0] << - ": Sizes do not match\n"; - return 1; - } + // Make sure they are all the same size + if(fileIn.size() != memIo1.size() || memIo1.size() != fileOut1.size()) { + std::cerr << argv[0] << + ": Sizes do not match\n"; + return 1; + } - // Read writereadseek test on MemIo - MemIo memIo2; - int rc = WriteReadSeek(memIo2); - if (rc != 0) return rc; + // Read writereadseek test on MemIo + MemIo memIo2; + int rc = WriteReadSeek(memIo2); + if (rc != 0) return rc; - // Read writereadseek test on FileIo - // Create or overwrite the file, then close it - FileIo fileTest("iotest.txt"); - if (fileTest.open("w+b") != 0) { - throw Error(Exiv2::kerFileOpenFailed, "iotest.txt", "w+b", strError()); - } - - fileTest.close(); - rc = WriteReadSeek(fileTest); - if (rc != 0) return rc; + // Read writereadseek test on FileIo + // Create or overwrite the file, then close it + FileIo fileTest("iotest.txt"); + if (fileTest.open("w+b") != 0) { + throw Error(Exiv2::kerFileOpenFailed, "iotest.txt", "w+b", strError()); + } - // Another test of reading and writing - fileOut1.seek(0, BasicIo::beg); - memIo2.seek(0, BasicIo::beg); - FileIo fileOut2(argv[3]); - if (fileOut2.open("w+b") != 0) { - throw Error(Exiv2::kerFileOpenFailed, argv[3], "w+b", strError()); - } + fileTest.close(); + rc = WriteReadSeek(fileTest); + if (rc != 0) return rc; - long readCount = 0; - byte buf[32]; - while ((readCount=fileOut1.read(buf, sizeof(buf)))) { - if (memIo2.write(buf, readCount) != readCount) { - std::cerr << argv[0] << - ": MemIo bad write 2\n"; - return 13; + // Another test of reading and writing + fileOut1.seek(0, BasicIo::beg); + memIo2.seek(0, BasicIo::beg); + FileIo fileOut2(f2); + if (fileOut2.open("w+b") != 0) { + throw Error(Exiv2::kerFileOpenFailed, f2, "w+b", strError()); } - if (fileOut2.write(buf, readCount) != readCount) { - std::cerr << argv[0] << - ": FileIo bad write 2\n"; - return 14; + + long readCount = 0; + byte buf[32]; + while ((readCount=fileOut1.read(buf, sizeof(buf)))) { + if (memIo2.write(buf, readCount) != readCount) { + std::cerr << argv[0] << + ": MemIo bad write 2\n"; + return 13; + } + if (fileOut2.write(buf, readCount) != readCount) { + std::cerr << argv[0] << + ": FileIo bad write 2\n"; + return 14; + } } - } - return 0; -} -catch (Exiv2::AnyError& e) { - std::cerr << "Caught Exiv2 exception '" << e << "'\n"; - return 20; -} + return 0; + } catch (Exiv2::AnyError& e) { + std::cerr << "Caught Exiv2 exception '" << e << "'\n"; + return 20; + } } From 52205c4acc35a92485c596fdd0bd08575b674b10 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 10:32:26 +0100 Subject: [PATCH 08/35] Modified iotest.sh to use iotest.cpp remote copy argument. --- test/data/iotest.out | 53 +++++++++++++++++++++++++++++++++++--------- test/iotest.sh | 14 +++++++----- 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/test/data/iotest.out b/test/data/iotest.out index 487b3abe..8dea41da 100644 --- a/test/data/iotest.out +++ b/test/data/iotest.out @@ -1,10 +1,43 @@ -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 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 +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 diff --git a/test/iotest.sh b/test/iotest.sh index 937d9a94..ca1d4d51 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -26,17 +26,20 @@ startHttpServer() { 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 - exiv2_httpServer=$! - else + if [ $(jobs | wc -l) == $jobs ]; then >&2 printf "*** startHttpServer failed to start on port $port ***\n" fi } closeHttpServer() { if [ ! -z $exiv2_httpServer ]; then - kill $exiv2_httpServer # kill the server + echo kill exiv2_httpServer $exiv2_httpServer + kill $exiv2_httpServer # kill the server + else + echo kill $! + kill $! fi } @@ -50,7 +53,8 @@ if [ $PLATFORM != mingw -a $PLATFORM != NetBSD -a $PLATFORM != SunOS -a $PLATFOR cd "$testdir" test_files="table.jpg Reagan.tiff exiv2-bug922a.jpg" for i in $test_files; do - runTest exiv2 -pa -g City -g DateTime $url/data/$i + runTest iotest s0 s1 s2 $url/data/$i + runTest exiv2 -g City -g DateTime s0 s1 s2 $url/data/$i done >&2 printf "*** HTTP tests end\n" ) | tr -d '\r' | sed 's/[ \t]+$//' > $results From c0ec4cf6a461b90f53bc2df31e3d38db2de042e2 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 12:51:48 +0100 Subject: [PATCH 09/35] Polishing iotest.sh by moving functions start/closeHttpServer to functions.source. Updated documentation. --- README.md | 7 ++-- samples/iotest.cpp | 1 - test/data/iotest.out | 83 +++++++++++++++++++++---------------------- test/functions.source | 34 ++++++++++++++++++ test/iotest.sh | 32 +++-------------- 5 files changed, 83 insertions(+), 74 deletions(-) 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! From ff8f5d076a243bd236c6c40c0ff7ffcf10643650 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 13:56:19 +0100 Subject: [PATCH 10/35] use import urllib.request to get server status (import requests is not always installed). --- test/functions.source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functions.source b/test/functions.source index b9ebb168..b0c65f00 100644 --- a/test/functions.source +++ b/test/functions.source @@ -452,7 +452,7 @@ startHttpServer() { 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)") + 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" From cd726c0c1b989a4f76c3cb9ce7976ab673939a80 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 14:09:11 +0100 Subject: [PATCH 11/35] Fix diffCheck() on netbsd and freebsd --- test/functions.source | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/functions.source b/test/functions.source index b0c65f00..292d9b43 100644 --- a/test/functions.source +++ b/test/functions.source @@ -227,10 +227,12 @@ diffCheck() if [ -z "$errors" ]; then let -a errors=0; fi #run diff and check results - if [ $(uname) == FreeBSD -o $(uname) == NetBSD -o $(uname) == SunOS ]; then - bdiff $diffargs "$test" "$good" + if [ $PLATFORM == SunOS ]; then + bdiff $diffargs "$test" "$good" + elif [ $PLATFORM == freebsd -o $PLATFORM == netbsd ]; then + diff $diffargs "$test" "$good" else - diff --binary $diffargs "$test" "$good" + diff --binary $diffargs "$test" "$good" fi if [ $? -ne 0 ]; then errors=$(expr $errors + 1) From 7ceb1c5a0fb343e6634aa22ebf5a0582c37f2bab Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 14:13:10 +0100 Subject: [PATCH 12/35] Fix diffCheck() on NetBSD and FreeBSD (again) --- test/functions.source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functions.source b/test/functions.source index 292d9b43..975bce4b 100644 --- a/test/functions.source +++ b/test/functions.source @@ -229,7 +229,7 @@ diffCheck() #run diff and check results if [ $PLATFORM == SunOS ]; then bdiff $diffargs "$test" "$good" - elif [ $PLATFORM == freebsd -o $PLATFORM == netbsd ]; then + elif [ $PLATFORM == FreeBSD -o $PLATFORM == NetBSD ]; then diff $diffargs "$test" "$good" else diff --binary $diffargs "$test" "$good" From 7956aa0ad9ea95a17512ae23f7a22b48114ca3ae Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 14:55:59 +0100 Subject: [PATCH 13/35] See #1029 Added option to samples/iotest.cpp to specify blocksize for remote copy. --- samples/iotest.cpp | 44 +++++++++++++++++++++++++++++--------------- test/data/iotest.out | 3 +++ test/iotest.sh | 6 ++++++ 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/samples/iotest.cpp b/samples/iotest.cpp index 6ef8d787..8c951088 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -51,17 +51,24 @@ int main(int argc, char* const argv[]) ::atexit(Exiv2::XmpParser::terminate); try { - if (argc < 4 || argc > 5 ) { - std::cout << "Usage: " << argv[0] << " filein fileout1 fileout2 [remote]\n"; + if (argc < 4 || argc > 6 ) { + std::cout << "Usage: " << argv[0] << " filein fileout1 fileout2 [remote [blocksize]]\n"; std::cout << "fileouts are overwritten and should match filein exactly\n"; return 1; } - const char* f0 = argv[1]; - const char* f1 = argv[2]; - const char* f2 = argv[3]; - const char* fr = argv[4]; - - if ( argc == 5 ) { + const char* f0 = argv[1]; // fileIn + const char* f1 = argv[2]; // fileOut1 + const char* f2 = argv[3]; // fileOut2 + const char* fr = argv[4]; // remote file + const char* ba = argv[5]; // block argument + + if ( argc >= 5 ) { + int bs = argc==6 ? atoi(ba) : 10000; + // ensure bs is sane + if (bs<1) bs=1 ; + if (bs>1024*1024) bs=10000; + Exiv2::byte b[bs]; + // copy fileIn from a remote location. FILE* f = fopen(f0,"wb"); if ( !f ) { @@ -69,16 +76,23 @@ int main(int argc, char* const argv[]) } BasicIo::AutoPtr io = Exiv2::ImageFactory::createIo(fr); io->open(); - int l = 0 ; - Exiv2::byte b[10000]; - int r ; - while ( (r=io->read(b,sizeof(b))) > 0 ) { - l += r; - fwrite(b,r,1,f) ; + size_t l = 0; + if ( bs > 1 ) { + int r ; + while ( (r=io->read(b,sizeof(bs))) > 0 ) { + l += r; + fwrite(b,r,1,f) ; + } + } else { + // bs ==1, read/write byte-wise (#1029) + while ( l++ < io->size() ) { + b[0] = io->getb(); + fwrite(b,1,1,f) ; + } } fclose(f); if ( !l ) { - Error(Exiv2::kerFileOpenFailed, fr, "w+b", strError()); + Error(Exiv2::kerFileOpenFailed, fr, "rb", strError()); } } diff --git a/test/data/iotest.out b/test/data/iotest.out index 570fbc9d..d1b569ef 100644 --- a/test/data/iotest.out +++ b/test/data/iotest.out @@ -38,3 +38,6 @@ 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 +568 568 568 568 +568 568 568 568 +568 568 568 568 diff --git a/test/iotest.sh b/test/iotest.sh index a47d9ceb..ff3a9c3f 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -34,6 +34,12 @@ if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then runTest exiv2 -g City -g DateTime $t done done + runTest iotest s0 s1 s2 $url/data/table.jpg 1 + echo $(stat -c%s s0 s1 s2 ../data/table.jpg) + runTest iotest s0 s1 s2 $url/data/table.jpg 10 + echo $(stat -c%s s0 s1 s2 ../data/table.jpg) + runTest iotest s0 s1 s2 $url/data/table.jpg 1000 + echo $(stat -c%s s0 s1 s2 ../data/table.jpg) >&2 printf "*** HTTP tests end\n" ) | tr -d '\r' | sed 's/[ \t]+$//' > $results reportTest From 6527ce1bdb1d8abb15abaad6a072a11868675766 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 15:38:26 +0100 Subject: [PATCH 14/35] Fix stat argment on Darwin/FreeBSD/NetBSD --- test/iotest.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/iotest.sh b/test/iotest.sh index ff3a9c3f..5e3e30af 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -34,12 +34,18 @@ if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then 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 -c%s s0 s1 s2 ../data/table.jpg) + echo $(stat $F s0 s1 s2 ../data/table.jpg) runTest iotest s0 s1 s2 $url/data/table.jpg 10 - echo $(stat -c%s s0 s1 s2 ../data/table.jpg) + echo $(stat $F s0 s1 s2 ../data/table.jpg) runTest iotest s0 s1 s2 $url/data/table.jpg 1000 - echo $(stat -c%s s0 s1 s2 ../data/table.jpg) + echo $(stat $F s0 s1 s2 ../data/table.jpg) >&2 printf "*** HTTP tests end\n" ) | tr -d '\r' | sed 's/[ \t]+$//' > $results reportTest From 5aa09915eaa67b1d813679fda5651787cc39156e Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 16:42:55 +0100 Subject: [PATCH 15/35] Documentation update. Fixed typo in comment in functions.source --- README-SAMPLES.md | 5 ++++- samples/iotest.cpp | 10 +++++++--- test/functions.source | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README-SAMPLES.md b/README-SAMPLES.md index 99391f42..02a5bb85 100644 --- a/README-SAMPLES.md +++ b/README-SAMPLES.md @@ -372,8 +372,11 @@ This program is used to test reading the file ini-test. This program was added #### iotest ``` -Usage: iotest filein fileout1 fileout2 +Usage: iotest filein fileout1 fileout2 [remote [blocksize]] fileouts are overwritten and should match filein exactly + +You may optionally provide the URL of a remote file to be copied to filein. +If you use `remote`, you may optionally provide a blocksize for the copy buffer (default 10k) ``` Test programs for BasicIo functions. diff --git a/samples/iotest.cpp b/samples/iotest.cpp index 8c951088..3b4f0c2a 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -52,9 +52,13 @@ int main(int argc, char* const argv[]) try { if (argc < 4 || argc > 6 ) { - std::cout << "Usage: " << argv[0] << " filein fileout1 fileout2 [remote [blocksize]]\n"; - std::cout << "fileouts are overwritten and should match filein exactly\n"; - return 1; + std::cout << "Usage: " << argv[0] << " filein fileout1 fileout2 [remote [blocksize]]\n" + "fileouts are overwritten and should match filein exactly\n" + "\n" + "You may optionally provide the URL of a remote file to be copied to filein\n" + "If you use `remote`, you may optionally provide a blocksize for the copy buffer (default 10k)\n" + ; + return 1; } const char* f0 = argv[1]; // fileIn const char* f1 = argv[2]; // fileOut1 diff --git a/test/functions.source b/test/functions.source index 975bce4b..b4e88865 100644 --- a/test/functions.source +++ b/test/functions.source @@ -462,7 +462,7 @@ startHttpServer() { } ## -# cloaseHttpServer - power down the python web server +# closeHttpServer - power down the python web server closeHttpServer() { if [ ! -z $exiv2_httpServer ]; then echo kill exiv2_httpServer $exiv2_httpServer From 1085e0b58f8fb91153b8a05d205c08471f45470c Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 20:29:18 +0100 Subject: [PATCH 16/35] Use md5 on Darwin (previously, using locally compiled coreutils md5sum) --- test/functions.source | 378 +++++++++++++++++++++--------------------- 1 file changed, 188 insertions(+), 190 deletions(-) diff --git a/test/functions.source b/test/functions.source index b4e88865..bf9ce0d1 100644 --- a/test/functions.source +++ b/test/functions.source @@ -4,66 +4,66 @@ # run a test runTest() { - local prog=$1 - shift - ( - mkdir -p $here/tmp - cd $here/tmp - if [ ! -z $EXIV2_ECHO ]; then - echoTest $VALGRIND $bin$prog$exe "$@" - fi - $VALGRIND $bin$prog$exe "$@" - ) + local prog=$1 + shift + ( + mkdir -p $here/tmp + cd $here/tmp + if [ ! -z $EXIV2_ECHO ]; then + echoTest $VALGRIND $bin$prog$exe "$@" + fi + $VALGRIND $bin$prog$exe "$@" + ) } ## # echo commands and arguments echoTest() { - local count=1 - for i in $@ ; do - echo $((count++)): $i - done - echo ----------------------- + local count=1 + for i in $@ ; do + echo $((count++)): $i + done + echo ----------------------- } ## # predictate existsTest() { - local prog=$1 - result=0 - if [ -z "$bin" ]; then - if [ ! -z $(which $prog) ]; then - result=1 - fi - else - if [ -e $bin$prog -o -e $bin$prog$exe ]; then - result=1 - fi - fi - echo $result + local prog=$1 + result=0 + if [ -z "$bin" ]; then + if [ ! -z $(which $prog) ]; then + result=1 + fi + else + if [ -e $bin$prog -o -e $bin$prog$exe ]; then + result=1 + fi + fi + echo $result } ## # copy file copy() { - \cp "$1" "$2" + \cp "$1" "$2" } ## # copy file from data to tmp (copyTestFile from to) copyTestFile() { - if [ $# == 2 ]; then - cp -f "$here/data/$1" "$here/tmp/$2" - elif [ $# == 1 ]; then - stub=$(basename $1) - cp -f "$here/data/$1" "$here/tmp/$stub" - else - echo "*** error copyTestFile: illegal number of inputs = $# ***" - fi + if [ $# == 2 ]; then + cp -f "$here/data/$1" "$here/tmp/$2" + elif [ $# == 1 ]; then + stub=$(basename $1) + cp -f "$here/data/$1" "$here/tmp/$stub" + else + echo "*** error copyTestFile: illegal number of inputs = $# ***" + fi } @@ -71,9 +71,9 @@ copyTestFile() # copy 1 or more files from data to tmp copyTestFiles() { - for i in "$@" ; do - copyTestFile "$i" "$i" - done + for i in "$@" ; do + copyTestFile "$i" "$i" + done } ## @@ -81,7 +81,7 @@ copyTestFiles() reportTest() { cat $results | tr '\\' '/' > ${results}-new - mv -f ${results}-new $results + mv -f ${results}-new $results if [ ! -z `which dos2unix` ]; then dos2unix $results >/dev/null 2>&1 fi @@ -110,7 +110,7 @@ reportTest() echo "all testcases passed." else diff $diffargs $lhs $rhs - exit 3 + exit 3 fi } @@ -292,12 +292,12 @@ removeTest() #run tests runTest iptctest $tmp <<-eoc - r Iptc.Application2.Byline - r Iptc.Application2.Caption - r Iptc.Application2.Keywords - r Iptc.Application2.Keywords - r Iptc.Application2.Keywords - r Iptc.Application2.CountryName + r Iptc.Application2.Byline + r Iptc.Application2.Caption + r Iptc.Application2.Keywords + r Iptc.Application2.Keywords + r Iptc.Application2.Keywords + r Iptc.Application2.CountryName eoc runTest iptcprint $tmp > $test @@ -319,14 +319,14 @@ addModTest() #run tests runTest iptctest $tmp <<-eoc - a Iptc.Application2.Headline The headline I am - a Iptc.Application2.Keywords Yet another keyword - m Iptc.Application2.DateCreated 2004-8-3 - a Iptc.Application2.Urgency 3 - m Iptc.Application2.SuppCategory "bla bla ba" - a Iptc.Envelope.ModelVersion 2 - a Iptc.Envelope.TimeSent 14:41:0-05:00 - a Iptc.Application2.RasterizedCaption 230 42 34 2 90 84 23 146 + a Iptc.Application2.Headline The headline I am + a Iptc.Application2.Keywords Yet another keyword + m Iptc.Application2.DateCreated 2004-8-3 + a Iptc.Application2.Urgency 3 + m Iptc.Application2.SuppCategory "bla bla ba" + a Iptc.Envelope.ModelVersion 2 + a Iptc.Envelope.TimeSent 14:41:0-05:00 + a Iptc.Application2.RasterizedCaption 230 42 34 2 90 84 23 146 eoc runTest iptcprint $tmp > $test @@ -360,76 +360,74 @@ extendedTest() # hardLinkFiles() { - target="$1" - shift - for var; do - if [ -e $var ]; then rm -rf $var ; fi - ln $target $var - done + target="$1" + shift + for var; do + if [ -e $var ]; then rm -rf $var ; fi + ln $target $var + done } ## # real_path - report the absolute path to a file real_path () { - if [ "$PLATFORM" == "Darwin" -o "$PLATFORM" == "mingw" ]; then - if [ -d "$1" ]; then - cd "$1" - echo $PWD - else - cd $(dirname $1) - echo "$PWD"/$(basename "$1") - fi - else - which realpath 2>/dev/null >/dev/null - if [ $? == 0 ]; then - realpath "$1" - else - readlink -f "$1" - fi + if [ "$PLATFORM" == "Darwin" -o "$PLATFORM" == "mingw" ]; then + if [ -d "$1" ]; then + cd "$1" + echo $PWD + else + cd $(dirname $1) + echo "$PWD"/$(basename "$1") + fi + else + which realpath 2>/dev/null >/dev/null + if [ $? == 0 ]; then + realpath "$1" + else + readlink -f "$1" + fi fi } copyVideoFiles () { - pushd "$testdir" 2>/dev/null >/dev/null - - ## - # find video files data/video and copy them for testing - declare -a videos - for video in $datadir/video/* ; do - # http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash - ext="${video##*.}" - if [ $ext != out ]; then - copyTestFile "$video" - videos+=($(basename "$video")) - fi - done - - ## - # TODO: remove debugging code - if [ "$FACTORY" == "rmills-mbp.localXX" ]; then - for v in write-video-test.out video-test.out; do - cp ~/gnu/exiv2/testdata/trunk/video/$v ~/gnu/exiv2/video13/test/data/video/ - done - fi - - # http://stackoverflow.com/questions/7442417/how-to-sort-an-array-in-bash - # readarray -t sorted < <(printf '%s\0' "${videos[@]}" | sort -z | xargs -0n1) - # echo ${videos[*]} - # unset videos - - popd 2>/dev/null >/dev/null + pushd "$testdir" 2>/dev/null >/dev/null + + ## + # find video files data/video and copy them for testing + declare -a videos + for video in $datadir/video/* ; do + # http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash + ext="${video##*.}" + if [ $ext != out ]; then + copyTestFile "$video" + videos+=($(basename "$video")) + fi + done + + ## + # TODO: remove debugging code + if [ "$FACTORY" == "rmills-mbp.localXX" ]; then + for v in write-video-test.out video-test.out; do + cp ~/gnu/exiv2/testdata/trunk/video/$v ~/gnu/exiv2/video13/test/data/video/ + done + fi + + # http://stackoverflow.com/questions/7442417/how-to-sort-an-array-in-bash + # readarray -t sorted < <(printf '%s\0' "${videos[@]}" | sort -z | xargs -0n1) + # echo ${videos[*]} + # unset videos + + popd 2>/dev/null >/dev/null } ## # print checksum for one file checkSum() { - # cygwin checksum: http://esrg.sourceforge.net/utils_win_up/md5sum/ - # macos - built/installed coreutils 8.25 http://ftp.gnu.org/gnu/coreutils/ platform=$(uname) - if [ "$platform" == 'NetBSD' -o "$platform" == 'FreeBSD' ]; then + if [ "$platform" == 'NetBSD' -o "$platform" == 'FreeBSD' -o "$platform" == 'Darwin' ]; then md5 -q $1 else md5sum $1 | cut -d' ' -f 1 @@ -474,97 +472,97 @@ closeHttpServer() { # prepare temp files and other variables prepareTest() { - ## - # locale and timezone setting - export LC_ALL=C - export TZ=BST-1 - - ## - # initialize globals - this=$(basename $0 .sh) - here=$PWD - datapath="../data" - testdir="$here/tmp" - datadir="../data" - - if [ -z "$EXIV2_BINDIR" ] ; then + ## + # locale and timezone setting + export LC_ALL=C + export TZ=BST-1 + + ## + # initialize globals + this=$(basename $0 .sh) + here=$PWD + datapath="../data" + testdir="$here/tmp" + datadir="../data" + + if [ -z "$EXIV2_BINDIR" ] ; then bin="$here/../build/bin/" - else - bin="$EXIV2_BINDIR/" - fi - - os=$(uname) - if [ "${os:0:4}" == "CYGW" ]; then - export PLATFORM=cygwin - elif [ "${os:0:4}" == "MING" -o "${os:0:4}" == "MSYS" ]; then - export PLATFORM=mingw - else - export PLATFORM=$os - fi - - if [ "$PLATFORM" == cygwin -o "$PLATFORM" == mingw ]; then - exe=.exe - fi - - if [ ! -z $EXIV2_EXT ]; then - exe=$EXIV2_EXT - fi - - if [ "$PLATFORM" == cygwin ]; then - # We need a private version of diff for linux compatibility - diff() - { - args=() - for i in "$@"; do - if [ ${i:0:1} != '-' ]; then - i="$(cygpath -aw $i)" - fi - args+=($i) - done - DIFF=$(which diff) - "$DIFF" ${args[@]} - } - fi + else + bin="$EXIV2_BINDIR/" + fi + + os=$(uname) + if [ "${os:0:4}" == "CYGW" ]; then + export PLATFORM=cygwin + elif [ "${os:0:4}" == "MING" -o "${os:0:4}" == "MSYS" ]; then + export PLATFORM=mingw + else + export PLATFORM=$os + fi + + if [ "$PLATFORM" == cygwin -o "$PLATFORM" == mingw ]; then + exe=.exe + fi + + if [ ! -z $EXIV2_EXT ]; then + exe=$EXIV2_EXT + fi + + if [ "$PLATFORM" == cygwin ]; then + # We need a private version of diff for linux compatibility + diff() + { + args=() + for i in "$@"; do + if [ ${i:0:1} != '-' ]; then + i="$(cygpath -aw $i)" + fi + args+=($i) + done + DIFF=$(which diff) + "$DIFF" ${args[@]} + } + fi ## # figure out arguments for diff - good="$here/data/${this}.out" - results="$here/tmp/${this}.out" - tmpfile=$here/tmp/$this - echo '' >> $tmpfile - - if [ "$PLATFORM" == SunOS -o "$PLATFORM" == FreeBSD -o "$PLATFORM" == NetBSD ] ; then - da1="" - da2="" - else - diffargs="--strip-trailing-cr" - diff -q $diffargs $tmpfile $tmpfile 2>/dev/null - if [ $? -ne 0 ]; then - diffargs="" - fi - - tmpfile=tmp/ttt - echo '' >> $tmpfile - da1="--strip-trailing-cr" - diff -q $da1 $tmpfile $tmpfile 2>/dev/null - if [ $? -ne 0 ] ; then - da1="" - fi - da2="--ignore-matching-lines=^Usage:.*exiv2" - diff -q $da2 $tmpfile $tmpfile 2>/dev/null - fi - diffargs="$da1 $da2" + good="$here/data/${this}.out" + results="$here/tmp/${this}.out" + tmpfile=$here/tmp/$this + echo '' >> $tmpfile + + if [ "$PLATFORM" == SunOS -o "$PLATFORM" == FreeBSD -o "$PLATFORM" == NetBSD ] ; then + da1="" + da2="" + else + diffargs="--strip-trailing-cr" + diff -q $diffargs $tmpfile $tmpfile 2>/dev/null + if [ $? -ne 0 ]; then + diffargs="" + fi + + tmpfile=tmp/ttt + echo '' >> $tmpfile + da1="--strip-trailing-cr" + diff -q $da1 $tmpfile $tmpfile 2>/dev/null + if [ $? -ne 0 ] ; then + da1="" + fi + da2="--ignore-matching-lines=^Usage:.*exiv2" + diff -q $da2 $tmpfile $tmpfile 2>/dev/null + fi + diffargs="$da1 $da2" ## # test that exiv2 and some sample apps are in the bin! for e in exiv2 exifprint easyaccess-test metacopy ; do - e="${bin}${e}${exe}" - if [ ! -e "$e" ]; then - echo '******************************************' - echo '***' $(real_path "$e") does not exist - echo '******************************************' - exit 42 - fi + e="${bin}${e}${exe}" + if [ ! -e "$e" ]; then + echo '******************************************' + echo '***' $(real_path "$e") does not exist + echo '******************************************' + exit 42 + fi done } From b2be8e7c0cc6415cee0785b4507f9d23bd7b48fb Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 20:49:58 +0100 Subject: [PATCH 17/35] Get Darwin to use md5 (and not the locally compiled coreutils/md5sum). --- test/functions.source | 383 +++++++++++++++++++++--------------------- 1 file changed, 191 insertions(+), 192 deletions(-) diff --git a/test/functions.source b/test/functions.source index bf9ce0d1..aa9f61c0 100644 --- a/test/functions.source +++ b/test/functions.source @@ -4,66 +4,66 @@ # run a test runTest() { - local prog=$1 - shift - ( - mkdir -p $here/tmp - cd $here/tmp - if [ ! -z $EXIV2_ECHO ]; then - echoTest $VALGRIND $bin$prog$exe "$@" - fi - $VALGRIND $bin$prog$exe "$@" - ) + local prog=$1 + shift + ( + mkdir -p $here/tmp + cd $here/tmp + if [ ! -z $EXIV2_ECHO ]; then + echoTest $VALGRIND $bin$prog$exe "$@" + fi + $VALGRIND $bin$prog$exe "$@" + ) } ## # echo commands and arguments echoTest() { - local count=1 - for i in $@ ; do - echo $((count++)): $i - done - echo ----------------------- + local count=1 + for i in $@ ; do + echo $((count++)): $i + done + echo ----------------------- } ## # predictate existsTest() { - local prog=$1 - result=0 - if [ -z "$bin" ]; then - if [ ! -z $(which $prog) ]; then - result=1 - fi - else - if [ -e $bin$prog -o -e $bin$prog$exe ]; then - result=1 - fi - fi - echo $result + local prog=$1 + result=0 + if [ -z "$bin" ]; then + if [ ! -z $(which $prog) ]; then + result=1 + fi + else + if [ -e $bin$prog -o -e $bin$prog$exe ]; then + result=1 + fi + fi + echo $result } ## # copy file copy() { - \cp "$1" "$2" + \cp "$1" "$2" } ## # copy file from data to tmp (copyTestFile from to) copyTestFile() { - if [ $# == 2 ]; then - cp -f "$here/data/$1" "$here/tmp/$2" - elif [ $# == 1 ]; then - stub=$(basename $1) - cp -f "$here/data/$1" "$here/tmp/$stub" - else - echo "*** error copyTestFile: illegal number of inputs = $# ***" - fi + if [ $# == 2 ]; then + cp -f "$here/data/$1" "$here/tmp/$2" + elif [ $# == 1 ]; then + stub=$(basename $1) + cp -f "$here/data/$1" "$here/tmp/$stub" + else + echo "*** error copyTestFile: illegal number of inputs = $# ***" + fi } @@ -71,9 +71,9 @@ copyTestFile() # copy 1 or more files from data to tmp copyTestFiles() { - for i in "$@" ; do - copyTestFile "$i" "$i" - done + for i in "$@" ; do + copyTestFile "$i" "$i" + done } ## @@ -81,7 +81,7 @@ copyTestFiles() reportTest() { cat $results | tr '\\' '/' > ${results}-new - mv -f ${results}-new $results + mv -f ${results}-new $results if [ ! -z `which dos2unix` ]; then dos2unix $results >/dev/null 2>&1 fi @@ -110,7 +110,7 @@ reportTest() echo "all testcases passed." else diff $diffargs $lhs $rhs - exit 3 + exit 3 fi } @@ -292,12 +292,12 @@ removeTest() #run tests runTest iptctest $tmp <<-eoc - r Iptc.Application2.Byline - r Iptc.Application2.Caption - r Iptc.Application2.Keywords - r Iptc.Application2.Keywords - r Iptc.Application2.Keywords - r Iptc.Application2.CountryName + r Iptc.Application2.Byline + r Iptc.Application2.Caption + r Iptc.Application2.Keywords + r Iptc.Application2.Keywords + r Iptc.Application2.Keywords + r Iptc.Application2.CountryName eoc runTest iptcprint $tmp > $test @@ -319,14 +319,14 @@ addModTest() #run tests runTest iptctest $tmp <<-eoc - a Iptc.Application2.Headline The headline I am - a Iptc.Application2.Keywords Yet another keyword - m Iptc.Application2.DateCreated 2004-8-3 - a Iptc.Application2.Urgency 3 - m Iptc.Application2.SuppCategory "bla bla ba" - a Iptc.Envelope.ModelVersion 2 - a Iptc.Envelope.TimeSent 14:41:0-05:00 - a Iptc.Application2.RasterizedCaption 230 42 34 2 90 84 23 146 + a Iptc.Application2.Headline The headline I am + a Iptc.Application2.Keywords Yet another keyword + m Iptc.Application2.DateCreated 2004-8-3 + a Iptc.Application2.Urgency 3 + m Iptc.Application2.SuppCategory "bla bla ba" + a Iptc.Envelope.ModelVersion 2 + a Iptc.Envelope.TimeSent 14:41:0-05:00 + a Iptc.Application2.RasterizedCaption 230 42 34 2 90 84 23 146 eoc runTest iptcprint $tmp > $test @@ -360,77 +360,76 @@ extendedTest() # hardLinkFiles() { - target="$1" - shift - for var; do - if [ -e $var ]; then rm -rf $var ; fi - ln $target $var - done + target="$1" + shift + for var; do + if [ -e $var ]; then rm -rf $var ; fi + ln $target $var + done } ## # real_path - report the absolute path to a file real_path () { - if [ "$PLATFORM" == "Darwin" -o "$PLATFORM" == "mingw" ]; then - if [ -d "$1" ]; then - cd "$1" - echo $PWD - else - cd $(dirname $1) - echo "$PWD"/$(basename "$1") - fi - else - which realpath 2>/dev/null >/dev/null - if [ $? == 0 ]; then - realpath "$1" - else - readlink -f "$1" - fi + if [ "$PLATFORM" == "Darwin" -o "$PLATFORM" == "mingw" ]; then + if [ -d "$1" ]; then + cd "$1" + echo $PWD + else + cd $(dirname $1) + echo "$PWD"/$(basename "$1") + fi + else + which realpath 2>/dev/null >/dev/null + if [ $? == 0 ]; then + realpath "$1" + else + readlink -f "$1" + fi fi } copyVideoFiles () { - pushd "$testdir" 2>/dev/null >/dev/null - - ## - # find video files data/video and copy them for testing - declare -a videos - for video in $datadir/video/* ; do - # http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash - ext="${video##*.}" - if [ $ext != out ]; then - copyTestFile "$video" - videos+=($(basename "$video")) - fi - done - - ## - # TODO: remove debugging code - if [ "$FACTORY" == "rmills-mbp.localXX" ]; then - for v in write-video-test.out video-test.out; do - cp ~/gnu/exiv2/testdata/trunk/video/$v ~/gnu/exiv2/video13/test/data/video/ - done - fi - - # http://stackoverflow.com/questions/7442417/how-to-sort-an-array-in-bash - # readarray -t sorted < <(printf '%s\0' "${videos[@]}" | sort -z | xargs -0n1) - # echo ${videos[*]} - # unset videos - - popd 2>/dev/null >/dev/null + pushd "$testdir" 2>/dev/null >/dev/null + + ## + # find video files data/video and copy them for testing + declare -a videos + for video in $datadir/video/* ; do + # http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash + ext="${video##*.}" + if [ $ext != out ]; then + copyTestFile "$video" + videos+=($(basename "$video")) + fi + done + + ## + # TODO: remove debugging code + if [ "$FACTORY" == "rmills-mbp.localXX" ]; then + for v in write-video-test.out video-test.out; do + cp ~/gnu/exiv2/testdata/trunk/video/$v ~/gnu/exiv2/video13/test/data/video/ + done + fi + + # http://stackoverflow.com/questions/7442417/how-to-sort-an-array-in-bash + # readarray -t sorted < <(printf '%s\0' "${videos[@]}" | sort -z | xargs -0n1) + # echo ${videos[*]} + # unset videos + + popd 2>/dev/null >/dev/null } ## # print checksum for one file checkSum() { - platform=$(uname) - if [ "$platform" == 'NetBSD' -o "$platform" == 'FreeBSD' -o "$platform" == 'Darwin' ]; then - md5 -q $1 + if [ "$PLATFORM" == 'NetBSD' -o "$PLATFORM" == 'FreeBSD' -o "$PLATFORM" == 'Darwin' ]; then + md5 -q $1 else - md5sum $1 | cut -d' ' -f 1 + md5sum $1 | cut -d' ' -f 1 fi } @@ -460,7 +459,7 @@ startHttpServer() { } ## -# closeHttpServer - power down the python web server +# cloaseHttpServer - power down the python web server closeHttpServer() { if [ ! -z $exiv2_httpServer ]; then echo kill exiv2_httpServer $exiv2_httpServer @@ -472,97 +471,97 @@ closeHttpServer() { # prepare temp files and other variables prepareTest() { - ## - # locale and timezone setting - export LC_ALL=C - export TZ=BST-1 - - ## - # initialize globals - this=$(basename $0 .sh) - here=$PWD - datapath="../data" - testdir="$here/tmp" - datadir="../data" - - if [ -z "$EXIV2_BINDIR" ] ; then + ## + # locale and timezone setting + export LC_ALL=C + export TZ=BST-1 + + ## + # initialize globals + this=$(basename $0 .sh) + here=$PWD + datapath="../data" + testdir="$here/tmp" + datadir="../data" + + if [ -z "$EXIV2_BINDIR" ] ; then bin="$here/../build/bin/" - else - bin="$EXIV2_BINDIR/" - fi - - os=$(uname) - if [ "${os:0:4}" == "CYGW" ]; then - export PLATFORM=cygwin - elif [ "${os:0:4}" == "MING" -o "${os:0:4}" == "MSYS" ]; then - export PLATFORM=mingw - else - export PLATFORM=$os - fi - - if [ "$PLATFORM" == cygwin -o "$PLATFORM" == mingw ]; then - exe=.exe - fi - - if [ ! -z $EXIV2_EXT ]; then - exe=$EXIV2_EXT - fi - - if [ "$PLATFORM" == cygwin ]; then - # We need a private version of diff for linux compatibility - diff() - { - args=() - for i in "$@"; do - if [ ${i:0:1} != '-' ]; then - i="$(cygpath -aw $i)" - fi - args+=($i) - done - DIFF=$(which diff) - "$DIFF" ${args[@]} - } - fi + else + bin="$EXIV2_BINDIR/" + fi + + os=$(uname) + if [ "${os:0:4}" == "CYGW" ]; then + export PLATFORM=cygwin + elif [ "${os:0:4}" == "MING" -o "${os:0:4}" == "MSYS" ]; then + export PLATFORM=mingw + else + export PLATFORM=$os + fi + + if [ "$PLATFORM" == cygwin -o "$PLATFORM" == mingw ]; then + exe=.exe + fi + + if [ ! -z $EXIV2_EXT ]; then + exe=$EXIV2_EXT + fi + + if [ "$PLATFORM" == cygwin ]; then + # We need a private version of diff for linux compatibility + diff() + { + args=() + for i in "$@"; do + if [ ${i:0:1} != '-' ]; then + i="$(cygpath -aw $i)" + fi + args+=($i) + done + DIFF=$(which diff) + "$DIFF" ${args[@]} + } + fi ## # figure out arguments for diff - good="$here/data/${this}.out" - results="$here/tmp/${this}.out" - tmpfile=$here/tmp/$this - echo '' >> $tmpfile - - if [ "$PLATFORM" == SunOS -o "$PLATFORM" == FreeBSD -o "$PLATFORM" == NetBSD ] ; then - da1="" - da2="" - else - diffargs="--strip-trailing-cr" - diff -q $diffargs $tmpfile $tmpfile 2>/dev/null - if [ $? -ne 0 ]; then - diffargs="" - fi - - tmpfile=tmp/ttt - echo '' >> $tmpfile - da1="--strip-trailing-cr" - diff -q $da1 $tmpfile $tmpfile 2>/dev/null - if [ $? -ne 0 ] ; then - da1="" - fi - da2="--ignore-matching-lines=^Usage:.*exiv2" - diff -q $da2 $tmpfile $tmpfile 2>/dev/null - fi - diffargs="$da1 $da2" + good="$here/data/${this}.out" + results="$here/tmp/${this}.out" + tmpfile=$here/tmp/$this + echo '' >> $tmpfile + + if [ "$PLATFORM" == SunOS -o "$PLATFORM" == FreeBSD -o "$PLATFORM" == NetBSD ] ; then + da1="" + da2="" + else + diffargs="--strip-trailing-cr" + diff -q $diffargs $tmpfile $tmpfile 2>/dev/null + if [ $? -ne 0 ]; then + diffargs="" + fi + + tmpfile=tmp/ttt + echo '' >> $tmpfile + da1="--strip-trailing-cr" + diff -q $da1 $tmpfile $tmpfile 2>/dev/null + if [ $? -ne 0 ] ; then + da1="" + fi + da2="--ignore-matching-lines=^Usage:.*exiv2" + diff -q $da2 $tmpfile $tmpfile 2>/dev/null + fi + diffargs="$da1 $da2" ## # test that exiv2 and some sample apps are in the bin! for e in exiv2 exifprint easyaccess-test metacopy ; do - e="${bin}${e}${exe}" - if [ ! -e "$e" ]; then - echo '******************************************' - echo '***' $(real_path "$e") does not exist - echo '******************************************' - exit 42 - fi + e="${bin}${e}${exe}" + if [ ! -e "$e" ]; then + echo '******************************************' + echo '***' $(real_path "$e") does not exist + echo '******************************************' + exit 42 + fi done } From cc4d56dec1f8dba1fd38c331567dfee22d85e6bb Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 14 May 2020 21:04:38 +0100 Subject: [PATCH 18/35] Change defaults for HTTP_PORT (1277 is use by another service). --- README.md | 2 +- test/functions.source | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 247c9230..bb476d8e 100644 --- a/README.md +++ b/README.md @@ -775,7 +775,7 @@ Environment Variables used by the test suite: | Variable | Default | Platforms | Purpose | |:-- |:-- |:-- |:-- | | EXIV2_BINDIR | **\/build/bin** | All Platforms | Location of built binary objects (exiv2.exe) | -| EXIV2_PORT | **1277**
**1278**
**1276** | Cygwin
MinGW/msys2
Other Platforms | Test TCP/IP Port | +| EXIV2_PORT | **12762**
**12671**
**12760** | 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| | diff --git a/test/functions.source b/test/functions.source index aa9f61c0..94bbfb8b 100644 --- a/test/functions.source +++ b/test/functions.source @@ -438,9 +438,9 @@ checkSum() startHttpServer() { cd "${testdir}/.." # testdir is the tmp output directory - if [ "$PLATFORM" == "cygwin" ]; then dport=1277 - elif [ "$PLATFORM" == "mingw" ]; then dport=1278 - else dport=1276 + if [ "$PLATFORM" == "cygwin" ]; then dport=12762 + elif [ "$PLATFORM" == "mingw" ]; then dport=12761 + else dport=12760 fi if [ ! -z $EXIV2_PORT ]; then port=$EXIV2_PORT ; else port=$dport ; fi From 32b9a2dfa1c14fdcfa6296ab76f8a5a87b586e72 Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 15 May 2020 09:15:24 +0100 Subject: [PATCH 19/35] Change EXIV2_HTTP default to http://localhost to keep msvc build happy. iotest.cpp modified to compile with msvc. --- README-SAMPLES.md | 5 +++-- README.md | 2 +- samples/iotest.cpp | 14 ++++++++------ test/data/iotest.out | 6 +++--- test/functions.source | 4 ++-- test/iotest.sh | 6 +++--- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/README-SAMPLES.md b/README-SAMPLES.md index 02a5bb85..22505ace4 100644 --- a/README-SAMPLES.md +++ b/README-SAMPLES.md @@ -373,9 +373,10 @@ This program is used to test reading the file ini-test. This program was added ``` Usage: iotest filein fileout1 fileout2 [remote [blocksize]] -fileouts are overwritten and should match filein exactly +copy filein to fileout1 and copy filein to fileout2 +fileout1 and fileout2 are overwritten and should match filein exactly -You may optionally provide the URL of a remote file to be copied to filein. +You may optionally provide the URL of a remote file to be copied to filein If you use `remote`, you may optionally provide a blocksize for the copy buffer (default 10k) ``` diff --git a/README.md b/README.md index aa6b1361..f026775b 100644 --- a/README.md +++ b/README.md @@ -778,7 +778,7 @@ Environment Variables used by the test suite: |:-- |:-- |:-- |:-- | | EXIV2_BINDIR | **\/build/bin** | All Platforms | Location of built binary objects (exiv2.exe) | | EXIV2_PORT | **12762**
**12671**
**12760** | Cygwin
MinGW/msys2
Other Platforms | Test TCP/IP Port | -| EXIV2_HTTP | **http://0.0.0.0** | All Platforms | Test http server | +| EXIV2_HTTP | **http://localhost** | 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 | diff --git a/samples/iotest.cpp b/samples/iotest.cpp index 3b4f0c2a..f7847b3f 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -53,12 +53,13 @@ int main(int argc, char* const argv[]) try { if (argc < 4 || argc > 6 ) { std::cout << "Usage: " << argv[0] << " filein fileout1 fileout2 [remote [blocksize]]\n" - "fileouts are overwritten and should match filein exactly\n" + "copy filein to fileout1 and copy filein to fileout2\n" + "fileout1 and fileout2 are overwritten and should match filein exactly\n" "\n" "You may optionally provide the URL of a remote file to be copied to filein\n" "If you use `remote`, you may optionally provide a blocksize for the copy buffer (default 10k)\n" - ; - return 1; + ; + return 1; } const char* f0 = argv[1]; // fileIn const char* f1 = argv[2]; // fileOut1 @@ -71,8 +72,8 @@ int main(int argc, char* const argv[]) // ensure bs is sane if (bs<1) bs=1 ; if (bs>1024*1024) bs=10000; - Exiv2::byte b[bs]; - + Exiv2::byte* b = new Exiv2::byte[bs]; + // copy fileIn from a remote location. FILE* f = fopen(f0,"wb"); if ( !f ) { @@ -94,12 +95,13 @@ int main(int argc, char* const argv[]) fwrite(b,1,1,f) ; } } + delete [] b; fclose(f); if ( !l ) { Error(Exiv2::kerFileOpenFailed, fr, "rb", strError()); } } - + FileIo fileIn(f0); if (fileIn.open() != 0) { throw Error(Exiv2::kerDataSourceOpenFailed, fileIn.path(), strError()); diff --git a/test/data/iotest.out b/test/data/iotest.out index d1b569ef..b2dd58cd 100644 --- a/test/data/iotest.out +++ b/test/data/iotest.out @@ -38,6 +38,6 @@ 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 -568 568 568 568 -568 568 568 568 -568 568 568 568 +568 568 568 568 c245b8764e4cf1104374787e21b6ef63 c245b8764e4cf1104374787e21b6ef63 c245b8764e4cf1104374787e21b6ef63 c245b8764e4cf1104374787e21b6ef63 +568 568 568 568 c245b8764e4cf1104374787e21b6ef63 c245b8764e4cf1104374787e21b6ef63 c245b8764e4cf1104374787e21b6ef63 c245b8764e4cf1104374787e21b6ef63 +568 568 568 568 c245b8764e4cf1104374787e21b6ef63 c245b8764e4cf1104374787e21b6ef63 c245b8764e4cf1104374787e21b6ef63 c245b8764e4cf1104374787e21b6ef63 diff --git a/test/functions.source b/test/functions.source index 2798afa6..69f0bb83 100644 --- a/test/functions.source +++ b/test/functions.source @@ -443,8 +443,8 @@ startHttpServer() { else dport=12760 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 + 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) python3 -m http.server $port & # start a background local HTTP server in the "real" test directory diff --git a/test/iotest.sh b/test/iotest.sh index 5e3e30af..8bc8a1d3 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -41,11 +41,11 @@ if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then fi runTest iotest s0 s1 s2 $url/data/table.jpg 1 - echo $(stat $F s0 s1 s2 ../data/table.jpg) + 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) + 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) + 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" ) | tr -d '\r' | sed 's/[ \t]+$//' > $results reportTest From f768fc0a4281cad0c268ef142911eea4cc3ead00 Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 15 May 2020 11:05:03 +0100 Subject: [PATCH 20/35] RemoteIo/http object to throw kerFileOpenFailed and not kerTiffDirectoryTooLarge --- src/basicio.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/basicio.cpp b/src/basicio.cpp index bd6dba00..283246da 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -30,6 +30,7 @@ #include "error.hpp" #include "http.hpp" #include "properties.hpp" +#include "image_int.hpp" // + standard includes #include @@ -2099,7 +2100,7 @@ namespace Exiv2 { request["verb"] = "HEAD"; long serverCode = (long)http(request, response, errors); if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) { - throw Error(kerTiffDirectoryTooLarge, "Server", serverCode); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",serverCode), hostInfo_.Path); } Exiv2::Dictionary_i lengthIter = response.find("Content-Length"); @@ -2123,7 +2124,7 @@ namespace Exiv2 { long serverCode = (long)http(request, responseDic, errors); if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) { - throw Error(kerTiffDirectoryTooLarge, "Server", serverCode); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",serverCode), hostInfo_.Path); } response = responseDic["body"]; } @@ -2175,7 +2176,7 @@ namespace Exiv2 { int serverCode = http(request, response, errors); if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) { - throw Error(kerTiffDirectoryTooLarge, "Server", serverCode); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",serverCode), hostInfo_.Path); } } HttpIo::HttpIo(const std::string& url, size_t blockSize) From c920f2ac442f28d704cfdeb12fa51f7a25f4aaad Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 15 May 2020 13:06:38 +0100 Subject: [PATCH 21/35] CurlIo/http object to throw kerFileOpenFailed and not kerTiffDirectoryTooLarge --- src/basicio.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/basicio.cpp b/src/basicio.cpp index 283246da..3a46262f 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -2309,7 +2309,7 @@ namespace Exiv2 { long returnCode; curl_easy_getinfo (curl_, CURLINFO_RESPONSE_CODE, &returnCode); // get code if (returnCode >= 400 || returnCode < 0) { - throw Error(kerTiffDirectoryTooLarge, "Server", returnCode); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",returnCode),path_); } // get length double temp; @@ -2346,7 +2346,7 @@ namespace Exiv2 { long serverCode; curl_easy_getinfo (curl_, CURLINFO_RESPONSE_CODE, &serverCode); // get code if (serverCode >= 400 || serverCode < 0) { - throw Error(kerTiffDirectoryTooLarge, "Server", serverCode); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",serverCode),path_); } } } @@ -2398,7 +2398,7 @@ namespace Exiv2 { long serverCode; curl_easy_getinfo (curl_, CURLINFO_RESPONSE_CODE, &serverCode); if (serverCode >= 400 || serverCode < 0) { - throw Error(kerTiffDirectoryTooLarge, "Server", serverCode); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",serverCode),path_); } } } From 22b5ef671d7eff585a1031cf053b75ea70bf1d43 Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 15 May 2020 14:13:28 +0100 Subject: [PATCH 22/35] msvc/windows builds use the default port (and not the platform port). --- test/functions.source | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/functions.source b/test/functions.source index 69f0bb83..d82080e6 100644 --- a/test/functions.source +++ b/test/functions.source @@ -437,10 +437,15 @@ checkSum() # startHttpServer - power up the python web server startHttpServer() { cd "${testdir}/.." # testdir is the tmp output directory - - if [ "$PLATFORM" == "cygwin" ]; then dport=12762 - elif [ "$PLATFORM" == "mingw" ]; then dport=12761 - else dport=12760 + + # PLATFORM = the scripting host (eg mingw) + # host = the build host (eg windows for msvc) + host=$(runTest exiv2 -vVg platform | tail -1 | cut -d= -f 2) # windows + if [ "$host" != windows ]; then host="$PLATFORM" ; fi + + if [ "$host" == "cygwin" ]; then dport=12762 + elif [ "$host" == "mingw" ]; then dport=12761 + else dport=12760 fi if [ ! -z $EXIV2_PORT ]; then port=$EXIV2_PORT ; else port=$dport ; fi @@ -459,7 +464,7 @@ startHttpServer() { } ## -# cloaseHttpServer - power down the python web server +# closeHttpServer - power down the python web server closeHttpServer() { if [ ! -z $exiv2_httpServer ]; then echo kill exiv2_httpServer $exiv2_httpServer @@ -564,6 +569,7 @@ prepareTest() exit 42 fi done + } prepareTest From 5b4743301e1c62832c0541a340350dc1725041cb Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 15 May 2020 14:42:35 +0100 Subject: [PATCH 23/35] The smart robot at codeCover/lgtm spotted typos in the code! Robot's almost as smart as Dan! --- src/basicio.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/basicio.cpp b/src/basicio.cpp index 3a46262f..9e22add4 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -2098,9 +2098,9 @@ namespace Exiv2 { request["page" ] = hostInfo_.Path; if (hostInfo_.Port != "") request["port"] = hostInfo_.Port; request["verb"] = "HEAD"; - long serverCode = (long)http(request, response, errors); + int serverCode = http(request, response, errors); if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) { - throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",serverCode), hostInfo_.Path); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path); } Exiv2::Dictionary_i lengthIter = response.find("Content-Length"); @@ -2122,9 +2122,9 @@ namespace Exiv2 { request["header"] = ss.str(); } - long serverCode = (long)http(request, responseDic, errors); + int serverCode = http(request, responseDic, errors); if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) { - throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",serverCode), hostInfo_.Path); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path); } response = responseDic["body"]; } @@ -2176,7 +2176,7 @@ namespace Exiv2 { int serverCode = http(request, response, errors); if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) { - throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",serverCode), hostInfo_.Path); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path); } } HttpIo::HttpIo(const std::string& url, size_t blockSize) @@ -2305,11 +2305,11 @@ namespace Exiv2 { if(res != CURLE_OK) { // error happends throw Error(kerErrorMessage, curl_easy_strerror(res)); } - // get return code - long returnCode; - curl_easy_getinfo (curl_, CURLINFO_RESPONSE_CODE, &returnCode); // get code - if (returnCode >= 400 || returnCode < 0) { - throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",returnCode),path_); + // get status + int serverCode; + curl_easy_getinfo (curl_, CURLINFO_RESPONSE_CODE, &serverCode); // get code + if (serverCode >= 400 || serverCode < 0) { + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode),path_); } // get length double temp; @@ -2343,10 +2343,10 @@ namespace Exiv2 { if(res != CURLE_OK) { throw Error(kerErrorMessage, curl_easy_strerror(res)); } else { - long serverCode; + int serverCode; curl_easy_getinfo (curl_, CURLINFO_RESPONSE_CODE, &serverCode); // get code if (serverCode >= 400 || serverCode < 0) { - throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",serverCode),path_); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode),path_); } } } @@ -2395,10 +2395,10 @@ namespace Exiv2 { if(res != CURLE_OK) { throw Error(kerErrorMessage, curl_easy_strerror(res)); } else { - long serverCode; + int serverCode; curl_easy_getinfo (curl_, CURLINFO_RESPONSE_CODE, &serverCode); if (serverCode >= 400 || serverCode < 0) { - throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%ld",serverCode),path_); + throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode),path_); } } } From a3451e2e4379f8d25295b06a1fdea003485d0d0e Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 15 May 2020 14:48:46 +0100 Subject: [PATCH 24/35] Bump Version! (yea, code-complete, I believe). --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5e1ebee..37c2a871 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required( VERSION 3.3.2 ) project(exiv2 # use TWEAK to categorize the build - VERSION 0.27.3.1 # 0.27.3 = GM + VERSION 0.27.3.20 # 0.27.3 = GM # 0.27.3.00 = GM Preview # 0.27.3.09 = Not For Release # 0.27.3.1 = RC1 From 5f6738a098f550bd5c2baa9a779e997e2352f9d8 Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 15 May 2020 15:55:20 +0100 Subject: [PATCH 25/35] get http.cpp to call WSAStartup() on Cygwin and MinGW --- src/http.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/http.cpp b/src/http.cpp index 4327deb4..75bdab02 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -22,9 +22,8 @@ * http.cpp */ -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) #include -#pragma comment(lib, "ws2_32.lib") #endif // included header files @@ -52,9 +51,8 @@ // platform specific code #if defined(WIN32) || defined(_MSC_VER) || defined(__MINGW__) #include -#include #include -#ifndef __MINGW__ +#if !defined(__MINGW__) && !defined(__CYGWIN__) #define snprintf sprintf_s #define write _write #define read _read @@ -210,7 +208,7 @@ int Exiv2::http(Exiv2::Dictionary& request,Exiv2::Dictionary& response,std::stri //////////////////////////////////// // Windows specific code -#ifdef WIN32 +#if defined(WIN32) || defined(_MSC_VER) || defined(__MINGW__) || defined(__CYGWIN__) WSADATA wsaData; WSAStartup(MAKEWORD(2,2), &wsaData); #endif From 158fba1b99e2dd0fb167dd7c4ebb9b883b33a076 Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 15 May 2020 18:24:52 +0100 Subject: [PATCH 26/35] Fix blocksize in iotest.cpp. --- samples/iotest.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/samples/iotest.cpp b/samples/iotest.cpp index f7847b3f..f0f4ed44 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -68,11 +68,11 @@ int main(int argc, char* const argv[]) const char* ba = argv[5]; // block argument if ( argc >= 5 ) { - int bs = argc==6 ? atoi(ba) : 10000; + int blocksize = argc==6 ? atoi(ba) : 10000; // ensure bs is sane - if (bs<1) bs=1 ; - if (bs>1024*1024) bs=10000; - Exiv2::byte* b = new Exiv2::byte[bs]; + if (blocksize<1) blocksize=1 ; + if (blocksize>1024*1024) blocksize=10000; + Exiv2::byte* bytes = new Exiv2::byte[blocksize]; // copy fileIn from a remote location. FILE* f = fopen(f0,"wb"); @@ -82,20 +82,20 @@ int main(int argc, char* const argv[]) BasicIo::AutoPtr io = Exiv2::ImageFactory::createIo(fr); io->open(); size_t l = 0; - if ( bs > 1 ) { + if ( blocksize > 1 ) { int r ; - while ( (r=io->read(b,sizeof(bs))) > 0 ) { + while ( (r=io->read(bytes,blocksize)) > 0 ) { l += r; - fwrite(b,r,1,f) ; + fwrite(bytes,r,1,f) ; } } else { - // bs ==1, read/write byte-wise (#1029) + // blocksize == 1, read/write byte-wise (#1029) while ( l++ < io->size() ) { - b[0] = io->getb(); - fwrite(b,1,1,f) ; + bytes[0] = io->getb(); + fwrite(bytes,1,1,f) ; } } - delete [] b; + delete [] bytes; fclose(f); if ( !l ) { Error(Exiv2::kerFileOpenFailed, fr, "rb", strError()); From ef56e5b61ef738681cf37ca939e9817a8eacb5ff Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sat, 16 May 2020 08:38:42 +0100 Subject: [PATCH 27/35] Fix comment typo --- samples/iotest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/iotest.cpp b/samples/iotest.cpp index f0f4ed44..405e4d78 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -69,7 +69,7 @@ int main(int argc, char* const argv[]) if ( argc >= 5 ) { int blocksize = argc==6 ? atoi(ba) : 10000; - // ensure bs is sane + // ensure blocksize is sane if (blocksize<1) blocksize=1 ; if (blocksize>1024*1024) blocksize=10000; Exiv2::byte* bytes = new Exiv2::byte[blocksize]; From 83cab13ae12f68e01c52205b5136c5e20ae723b2 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sat, 16 May 2020 08:50:42 +0100 Subject: [PATCH 28/35] 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 From c64f2e8ea19aa15bec877d8a25af514b7473c0f9 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sat, 16 May 2020 10:11:40 +0100 Subject: [PATCH 29/35] iotest.cpp polishing. --- samples/iotest.cpp | 31 ++++++++++++++----------------- test/iotest.sh | 8 ++++---- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/samples/iotest.cpp b/samples/iotest.cpp index 405e4d78..ee593530 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -70,36 +70,33 @@ int main(int argc, char* const argv[]) if ( argc >= 5 ) { int blocksize = argc==6 ? atoi(ba) : 10000; // ensure blocksize is sane - if (blocksize<1) blocksize=1 ; if (blocksize>1024*1024) blocksize=10000; - Exiv2::byte* bytes = new Exiv2::byte[blocksize]; + Exiv2::byte* bytes = blocksize>0 ? new Exiv2::byte[blocksize]: NULL; // copy fileIn from a remote location. - FILE* f = fopen(f0,"wb"); - if ( !f ) { - Error(Exiv2::kerFileOpenFailed, f0, "w+b", strError()); - } BasicIo::AutoPtr io = Exiv2::ImageFactory::createIo(fr); - io->open(); + if ( io->open() != 0 ) { + Error(Exiv2::kerFileOpenFailed, io->path(), "rb", strError()); + } + FileIo output(f0); + if ( !output.open("wb") ) { + Error(Exiv2::kerFileOpenFailed, output.path() , "w+b", strError()); + } size_t l = 0; - if ( blocksize > 1 ) { + if ( bytes ) { int r ; while ( (r=io->read(bytes,blocksize)) > 0 ) { l += r; - fwrite(bytes,r,1,f) ; + output.write(bytes,r) ; } } else { - // blocksize == 1, read/write byte-wise (#1029) + // read/write byte-wise (#1029) while ( l++ < io->size() ) { - bytes[0] = io->getb(); - fwrite(bytes,1,1,f) ; + output.putb(io->getb()) ; } } - delete [] bytes; - fclose(f); - if ( !l ) { - Error(Exiv2::kerFileOpenFailed, fr, "rb", strError()); - } + if ( bytes ) delete [] bytes; + output.close(); } FileIo fileIn(f0); diff --git a/test/iotest.sh b/test/iotest.sh index 3f8e3bc8..310e8a47 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -35,7 +35,7 @@ if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then 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 @@ -44,11 +44,11 @@ if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then runTest exiv2 -g City -g DateTime $t done done - - runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 1 ; sniff + + runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 0 ; 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 From c85c930b265fd651cf591f89aa9fde54dcc5ea63 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sat, 16 May 2020 10:25:34 +0100 Subject: [PATCH 30/35] Fixing ioTest -> iotest (fails on NetBSD). --- test/iotest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/iotest.sh b/test/iotest.sh index 310e8a47..bc86b7c9 100755 --- a/test/iotest.sh +++ b/test/iotest.sh @@ -10,7 +10,7 @@ source ./functions.source echo printf "file io tests" copyTestFiles $test_files - for i in $test_files; do runTest ioTest $i s1 s2; done + for i in $test_files; do runTest iotest $i s1 s2; done printf "\n---------------------------------------------------------\n" if [ $errors -eq 0 ]; then From 214851cd2108fff97c201a33e979f63b930b361d Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sat, 16 May 2020 11:57:28 +0100 Subject: [PATCH 31/35] Only perform platform test on ming/cygwin. --- test/functions.source | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/functions.source b/test/functions.source index ed9b73c4..afc694f8 100644 --- a/test/functions.source +++ b/test/functions.source @@ -440,7 +440,10 @@ startHttpServer() { # PLATFORM = the scripting host (eg mingw) # host = the build host (eg windows for msvc) - host=$(runTest exiv2 -vVg platform | tail -1 | cut -d= -f 2) # windows + host=$PLATFORM + if [ $PLATFORM == 'cygwin' -o $PLATFORM == 'mingw' ]; then + host=$(runTest exiv2 -vVg platform | tail -1 | cut -d= -f 2) # windows + fi if [ "$host" != windows ]; then host="$PLATFORM" ; fi if [ "$host" == "cygwin" ]; then dport=12762 From 18e6a1f5d348c430f3ed87c577dd0bf45b4a519d Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sat, 16 May 2020 19:09:31 +0100 Subject: [PATCH 32/35] Removing redundant line of code. --- test/functions.source | 1 - 1 file changed, 1 deletion(-) diff --git a/test/functions.source b/test/functions.source index afc694f8..9f98de39 100644 --- a/test/functions.source +++ b/test/functions.source @@ -440,7 +440,6 @@ startHttpServer() { # PLATFORM = the scripting host (eg mingw) # host = the build host (eg windows for msvc) - host=$PLATFORM if [ $PLATFORM == 'cygwin' -o $PLATFORM == 'mingw' ]; then host=$(runTest exiv2 -vVg platform | tail -1 | cut -d= -f 2) # windows fi From ea28be68e9db9825b4876bb5083ae04091f74bcb Mon Sep 17 00:00:00 2001 From: clanmills Date: Sun, 17 May 2020 17:49:21 +0100 Subject: [PATCH 33/35] Fixing fedora/mingw build breaker. https://gitlab.com/D4N/exiv2/-/jobs/555626122 Thanks to @D4N for this discovery. --- src/http.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/http.cpp b/src/http.cpp index 75bdab02..ceaeaff4 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -18,14 +18,6 @@ * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. */ -/* - * http.cpp - */ - -#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) -#include -#endif - // included header files #include "config.h" @@ -40,6 +32,10 @@ #include #include +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) +#include +#endif + #define SLEEP 1000 #define SNOOZE 0 From 2f2bf69f6cf149422dde2332594b2ab8b743336a Mon Sep 17 00:00:00 2001 From: clanmills Date: Sun, 17 May 2020 17:59:22 +0100 Subject: [PATCH 34/35] README.md General revision. Mostly simplifying "4 Test Suite". --- README.md | 193 +++++++++++++++++------------------------- samples/exifprint.cpp | 2 +- 2 files changed, 80 insertions(+), 115 deletions(-) diff --git a/README.md b/README.md index f026775b..9b39c20b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,24 @@ | Travis | AppVeyor | GitLab| Codecov| Repology| |:-------------:|:-------------:|:-----:|:------:|:-------:| | [![Build Status](https://travis-ci.org/Exiv2/exiv2.svg?branch=0.27-maintenance)](https://travis-ci.org/Exiv2/exiv2) | [![Build status](https://ci.appveyor.com/api/projects/status/d6vxf2n0cp3v88al/branch/0.27-maintenance?svg=true)](https://ci.appveyor.com/project/piponazo/exiv2-wutfp/branch/0.27-maintenance) | [![pipeline status](https://gitlab.com/D4N/exiv2/badges/0.27-maintenance/pipeline.svg)](https://gitlab.com/D4N/exiv2/commits/0.27-maintenance) | [![codecov](https://codecov.io/gh/Exiv2/exiv2/branch/0.27-maintenance/graph/badge.svg)](https://codecov.io/gh/Exiv2/exiv2) | [![Packaging status](https://repology.org/badge/tiny-repos/exiv2.svg)](https://repology.org/metapackage/exiv2/versions) | + +
+ +# Welcome to Exiv2 + +Exiv2 is a C++ library and a command-line utility to read, +write, delete and modify Exif, IPTC, XMP and ICC image metadata. + +| Exiv2 Resource | Location | +|:---------- |:------ | +| Releases and Documentation
Prereleases:
Project Resources
License (GPLv2)
CMake Downloads | [https://exiv2.org](https://exiv2.org)
[https://pre-release.exiv2.org](https://pre-release.exiv2.org)
[https://github.com/Exiv2/exiv2](https://github.com/Exiv2/exiv2)
[COPYING](COPYING)
[https://cmake.org/download/](https://cmake.org/download/) | + +The file ReadMe.txt in a build bundle describes how to install the library on the platform. ReadMe.txt also documents how to compile and link code on the platform. +
### TABLE OF CONTENTS +![Exiv2](exiv2.png) 1. [Welcome to Exiv2](#1) 2. [Building, Installing, Using and Uninstalling Exiv2](#2) @@ -41,25 +56,6 @@ 5. [Microsoft Visual C++](#5-5) 6. [Unix](#5-6) -
- -# Welcome to Exiv2 - -![Exiv2](exiv2.png) - -Exiv2 is a C++ library and a command line utility to read, -write, delete and modify Exif, IPTC, XMP and ICC image metadata. - -| Exiv2 Resource | Location | -|:------ |:---- | -| Releases and Documentation | [https://exiv2.org](https://exiv2.org) | -| Prereleases: | [https://pre-release.exiv2.org](https://pre-release.exiv2.org) | -| Project Resources | [https://github.com/Exiv2/exiv2](https://github.com/Exiv2/exiv2) | -| License (GPLv2) | [COPYING](COPYING) | -| CMake Downloads | [https://cmake.org/download/](https://cmake.org/download/) | - -The file ReadMe.txt in a build bundle describes how to install the library on the platform. ReadMe.txt also documents how to compile and link code on the platform. - [TOC](#TOC)
@@ -72,12 +68,12 @@ You need [CMake](https://cmake.org/download/) to configure the Exiv2 project and ### 2.1 Build, Install, Use Exiv2 on a UNIX-like system ```bash -cd ~/gnu/github/exiv2 # location of the project code -mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Release -cmake --build . -make tests -sudo make install +$ cd ~/gnu/github/exiv2 # location of the project code +$ mkdir build && cd build +$ cmake .. -DCMAKE_BUILD_TYPE=Release +$ cmake --build . +$ make tests +$ sudo make install ``` This will install the library into the "standard locations". The library will be installed in `/usr/local/lib`, executables (including the exiv2 command-line program) in `/usr/local/bin/` and header files in `/usr/local/include/exiv2` @@ -104,9 +100,8 @@ $ export DYLD_LIBRARY_PATH="/usr/local/lib:$DYLD_LIBRARY_PATH" # macOS ### 2.2 Build and Install Exiv2 with Visual Studio -We recommend that you use conan to download the Exiv2 external dependencies on Windows (On Linux/OSX you can use or install system packages). -Apart from handling the dependencies, to configure and compile the project is pretty similar to the UNIX like systems. -See [README-CONAN](README-CONAN.md) for more information +We recommend that you use conan to download the Exiv2 external dependencies on Windows. On other platforms (maxOS, Ubuntu and others), you should use the platform package manger. These are discussed: [Platform Notes](#5) The options to configure and compile the project using Visual Studio are similar to UNIX like systems. +See [README-CONAN](README-CONAN.md) for more information about Conan. [TOC](#TOC)
@@ -131,9 +126,10 @@ option( EXIV2_ENABLE_PNG "Build with png support (requires libz)" ON 577 rmills@rmillsmm:~/gnu/github/exiv2/exiv2 $ ``` -Options are defined on the CMake command line: +Options are defined on the CMake command-line: + ```bash -$ cmake -DBUILD_SHARED_LIBS=On -DEXIV2_ENABLE_NLS=OFF +$ cmake -DBUILD_SHARED_LIBS=On -DEXIV2_ENABLE_NLS=Off ``` [TOC](#TOC) @@ -150,9 +146,8 @@ The following Exiv2 features require external libraries: | Natural language system | gettext | OFF | -DEXIV2\_ENABLE\_NLS=On | [http://www.gnu.org/software/gettext/](http://www.gnu.org/software/gettext/) | On UNIX systems, you may install the dependencies using the distribution's package management system. Install the -development package of a dependency to install the header files and libraries required to build Exiv2. In the file -`ci/install_dependencies.sh` you can check to the list of packages we install on different Linux distributions. This -file is used to setup some CI images in which we try out the Exiv2 compilation. +development package of a dependency to install the header files and libraries required to build Exiv2. The script +`ci/install_dependencies.sh` is used to setup CI images on which we build and test Exiv2 on many platforms when we modify code. You may find that helpful in setting up your platform dependencies. Natural language system is discussed in more detail here: [Localisation](#2-8) @@ -169,7 +164,7 @@ See [README-CONAN](README-CONAN.md) for more information. There are detailed platform notes about compiling and linking in `releasenotes/{platform}/ReadMe.txt` -where `platform: { CYGWIN | macOS | Linux | MinGW | msvc }` +where `platform: { CYGWIN | Darwin | Linux | MinGW | msvc | Unix }` In general you need to do the following: @@ -202,27 +197,24 @@ You can build samples/exifprint.cpp as follows: $ cd $ mkdir exifprint $ cd exifprint -$ *** EDIT CMakeLists.txt *** -$ cat CMakeLists.txt +$ cat - > CMakeLists.txt < @@ -255,7 +247,7 @@ g++ -std=c++98 myprogram.cpp -o myprogram $(pkg-config exiv2 --libs --cflags) Localisation is supported on a UNIX-like platform: Linux, macOS, Cygwin and MinGW/msys2. Localisation is not supported for Visual Studio builds. -To build localisation support, use the CMake option `-DEXIV2_ENABLE_NLS=ON`. You must install the `gettext` package with your package manager or from source. The `gettext` package is available from [http://www.gnu.org/software/gettext/](http://www.gnu.org/software/gettext/) and includes the library `libintl` and utilities to build localisation files. If CMake produces error messages which mention libintl or gettext, you should verify that the package `gettext` has been correctly built and installed. +To build localisation support, use the CMake option `-DEXIV2_ENABLE_NLS=On`. You must install the `gettext` package with your package manager or from source. The `gettext` package is available from [http://www.gnu.org/software/gettext/](http://www.gnu.org/software/gettext/) and includes the library `libintl` and utilities to build localisation files. If CMake produces error messages which mention libintl or gettext, you should verify that the package `gettext` has been correctly built and installed. You must install the build to test localisation. This ensures that the localisation message files can be found at run-time. You cannot test localisation in the directory `build\bin`. @@ -350,7 +342,7 @@ To build documentation, use the CMake option **`-DEXIV2_BUILD_DOC=On`**. Additionally, you will require an additional build step to actually build the documentation. ```bash -$ cmake ..options.. -DEXIV2_BUILD_DOC=ON +$ cmake ..options.. -DEXIV2_BUILD_DOC=On $ make doc ``` @@ -365,7 +357,7 @@ To build the documentation, you must install the following products: ### 2.10 Building Exiv2 Packages -To enable the building of Exiv2 packages, use the CMake option `-DEXIV2_TEAM_PACKAGING=ON`. +To enable the building of Exiv2 packages, use the CMake option `-DEXIV2_TEAM_PACKAGING=On`. You should not build Exiv2 Packages. This feature is intended for use by Team Exiv2 to create Platform and Source Packages on the buildserver. @@ -443,19 +435,19 @@ Exiv2 respects the symbol `NDEBUG` which is set only for Release builds. There a #endif ``` -Those blocks of code are not compiled unless you define `EXIV2_DEBUG_MESSAGES` by yourself. They are provided for additional debugging information. For example, if you are interested in additional output from webpimage.cpp, you can update your build as follows: +Those blocks of code are not compiled unless you define `EXIV2_DEBUG_MESSAGES`. They are provided for additional debugging information. For example, if you are interested in additional output from webpimage.cpp, you can update your build as follows: ```bash $ cd $ touch src/webpimage.cpp -$ make CXXFLAGS=-DEXIV2_DEBUG_MESSAGESDEBUG +$ make CXXFLAGS=-DEXIV2_DEBUG_MESSAGES $ bin/exiv2 ... -- or -- $ sudo make install $ exiv2 ... ``` -If you are debugging library code, it is recommended that you use the exiv2 command-line as your test harness as Team Exiv2 is very familiar with this tool and able to give support. +If you are debugging library code, it is recommended that you use the exiv2 command-line program as your test harness as Team Exiv2 is very familiar with this tool and able to give support. [TOC](#TOC) @@ -479,7 +471,7 @@ I personally use CLion which has excellent integration with CMake. It will auto 5) cmake --build . options **`--config Release|Debug`** and **`--target install`** -Visual Studio and Xcode can build debug or release builds without using the option **`-DCMAKE_BUILD_TYPE`** because the generated project files can build multiple types. The option **`--config Debug`** can be specified on the command-line to specify the build type. Alternatively, if you prefer to build in the IDE, the UI provides options to select the configuration and target. +Visual Studio and Xcode can build debug or release builds without using the option **`-DCMAKE_BUILD_TYPE`** because the generated project files can build multiple types. The option **`--config Debug`** can be specified on the cmake command-line to specify the build type. Alternatively, if you prefer to build in the IDE, the UI provides options to select the configuration and target. With the Unix Makefile generator, the targets can be listed: @@ -579,7 +571,7 @@ As discussed in the section on Thread Safety, Exiv2 classes for Exif and IPTC me Adobe's XMPsdk is generally thread-safe, however it has to be initialized and terminated before and after starting any threads to access XMP metadata. The Exiv2 library will initialize this if necessary, however it does not terminate the XMPsdk. -The Exiv2 command-line and the sample applications call the following at the outset: +The exiv2 command-line program and sample applications call the following at the outset: ``` Exiv2::XmpParser::initialize(); @@ -630,11 +622,11 @@ $ make Note, you may wish to choose to build with optional features and/or build static libraries. To do this, request appropriately on the mingw64-cmake command: ```bash -$ mingw64-cmake .. -DEXIV2_TEAM_EXTRA_WARNINGS=ON \ - -DEXIV2_ENABLE_VIDEO=ON \ - -DEXIV2_ENABLE_WEBREADY=ON \ - -DEXIV2_ENABLE_WIN_UNICODE=ON \ - -DBUILD_SHARED_LIBS=OFF +$ mingw64-cmake .. -DEXIV2_TEAM_EXTRA_WARNINGS=On \ + -DEXIV2_ENABLE_VIDEO=On \ + -DEXIV2_ENABLE_WEBREADY=On \ + -DEXIV2_ENABLE_WIN_UNICODE=On \ + -DBUILD_SHARED_LIBS=Off ``` The options available for cross-compiling are the same as provided for all builds. See: [Build Options](#2-3) @@ -671,9 +663,9 @@ If you have not installed wine, Fedora will offer to install it for you. ####6 Running the test suite -On a default wine installation, you are in the MSDOS/cmd prompt. You cannot execute the exiv2 test suite in this environment as you require python3 and MSYS/bash to run the suite. +On a default wine installation, you are in the MSDOS/cmd.exe prompt. You cannot execute the exiv2 test suite in this environment as you require python3 and MSYS/bash to run the suite. -You should mount the your Fedora exiv2/ directory on a Windows machine on which you have installed MSYS2. You will need python3 and make. +You should mount the your Fedora exiv2/ directory on a Windows machine on which you have installed MinGW/msys2. You will need python3 and make. My build machines is a MacMini with VMs for Windows, Fedora and other platforms. On Fedora, I build in a Mac directory which is shared to all VMs. @@ -685,7 +677,7 @@ My build machines is a MacMini with VMs for Windows, Fedora and other platforms. [rmills@rmillsmm-fedora 0.27-maintenance]$ ``` -On MSYS2, I can directly access the share: +On MinGW/msys2, I can directly access the share: ```bash $ cd //Mac/Home/gnu/github/exiv2/0.27/maintenance/build_mingw_fedora @@ -760,7 +752,7 @@ For new bug reports and feature requests, please open an issue in Github. ## 4 Running the test suite -There are different kinds of tests: +#### Different kinds of tests: | Description | Language | Location | Command
_(in build or test directory)_ | CMake Option to Build | |:-- |:-- |:-- |:-- |:-- | @@ -770,9 +762,11 @@ There are different kinds of tests: | Unit tests | C++ | \/unitTests | $ make unit_test | -DEXIV2\_BUILD\_UNIT\_TESTS=On | | Version test | C++ | \/src/version.cpp | $ make version_test | Always in library | -**Caution Visual Studio Users using cmd.exe**
_You may use `make` to to execute tests in the test directory. To execute tests from the build directory, use `cmake`._ This is discussed in detail below: [Running tests on Visual Studio builds](#4-2) +_**Caution Visual Studio Users using cmd.exe**_
_You may use MinGW/msys2 `make` to to execute tests in the test directory. To execute tests from the build directory, use `cmake`. This is discussed in detail below: [Running tests on Visual Studio builds](#4-2)_ -Environment Variables used by the test suite: +#### Environment Variables used by the test suite: + +If you build the code in the directory \build, tests will run using the default values of Environment Variables. | Variable | Default | Platforms | Purpose | |:-- |:-- |:-- |:-- | @@ -785,8 +779,9 @@ Environment Variables used by the test suite: | VALGRIND | _**not set**_ | All Platforms | For debugging Bash scripts | | VERBOSE | _**not set**_ | All Platforms | Causes make to report its actions | -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. +The Variable 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 _**once**_ to authorise the firewall to permit python to use the port. +[TOC](#TOC)
### 4.1 Running tests on a UNIX-like system @@ -794,15 +789,16 @@ The Variables EXIV2\_PORT or EXIV2\_HTTP can be set to None to skip http tests. You can run tests directly from the build: ```bash -$ cmake .. -G "Unix Makefiles" +$ cmake .. -G "Unix Makefiles" -DEXIV2_BUILD_UNIT_TESTS=On $ make -... +... lots of output ... $ make tests ... lots of output ... -Summary report +$ ``` -You can run individual tests in the `test` directory using the environment variable EXIV2\_BINDIR to specify the location of the build artifacts. For Windows builds (msvc, Cygwin, Msys, MinGW), set EXIV2_EXT=.exe +You can run individual tests in the `test` directory. **Caution:** If you build in a directory other than \/build, you must set EXIV2\_BINDIR to run tests from the `test` directory. + ```bash $ cd /build @@ -817,6 +813,7 @@ test_run (tiff_test.test_tiff_test_program.TestTiffTestProg) ... ok ---------------------------------------------------------------------- Ran 176 tests in 9.526s OK (skipped=6) +$ ``` [TOC](#TOC) @@ -828,23 +825,21 @@ To run the bash scripts you will need to install MinGW/msys2 which provides you ##### Running tests from MinGW/msys2 bash -Use the bash interpreter for MinGW/msys2 to run the test suite. It's essential to have a DOS Python3 interpreter on your path called `python3.exe` The variables EXIV2\_BINDIR and EXIV2\_EXT enable the test suite to locate the MSVC build artifacts. +Use the bash interpreter for MinGW/msys2 to run the test suite. It's essential to have a DOS Python3 interpreter on your path called `python3.exe` ```bash $ cd /build $ cd ../test $ PATH="/c/Python37:$PATH" -$ export EXIV2_EXT=.exe -$ export EXIV2_BINDIR=${PWD}/../build/bin ``` **Caution:** _The python3 interpreter must be for DOS and called python3.exe. I copied the python.exe program:_ ``` -..>copy c:\Python37\python.exe c:\Python37\python3.exe +$ cp /cygpath/c/Python37/python.exe /cygpath/c/Python37/python3.exe ``` -Once you have modified the PATH and exported EXIV2\_BINDIR and EXIV2\_EXT, you can execute the test suite as described for UNIX-like systems: +You can execute the test suite as described for UNIX-like systems: ```bash $ cd /test @@ -852,6 +847,9 @@ $ make tests $ make python_tests $ ./icc-test.sh ``` +**Caution:** If you build in a directory other than \/build, you must set EXIV2\_BINDIR to run tests from the `test` directory. + + ##### Running tests from cmd.exe You can build with Visual Studio using Conan. The is described in detail in [README-CONAN.md](README-CONAN.md) @@ -868,25 +866,23 @@ c:\...\exiv2\build>cmake --build . --config Release c:\...\exiv2\build> ``` -**Caution:** _You will need a DOS python3 interpreter which must be called python3.exe. I copied the python.exe program:_ +**Caution:** To run the python tests, _You will need a DOS python3 interpreter which must be called python3.exe. I copied the python.exe program:_ You may have to modify the PATH to ensure that the DOS python3 is used. You may have to modify the PATH to access MinGW/msys2 tools such as bash and make. Be careful to ensure the DOS python3.exe is found before the MinGW/msys2 python3. ``` c:\...\exiv2\build>copy c:\Python37\python.exe c:\Python37\python3.exe +c:\...\exiv2\build>set "PATH=c:\Python37;c:\Python37\Scripts;c:\msys64\usr\bin;%PATH%" ``` -You must set the environment strings EXIV2\_BINDIR, EXIV2\_EXT and modify PATH. You will need a DOS Python3 interpreter on your path, and you'll need the bash interpreter. By careful to ensure the DOS python3.exe is found before the MingW/msys2 python3. +You can now run the tests from cmd.exe: ``` -c:\...\exiv2\build>cd bin -c:\...\exiv2\build\bin>set EXIV2_BINDIR=%CD% -c:\...\exiv2\build\bin>set EXIV2_EXT=.exe -c:\...\exiv2\build\bin>set "PATH=c:\Python37;c:\Python37\Scripts;c:\msys64\usr\bin;%PATH%" +c:\...\exiv2\build>cmake --build . --config Release --target tests ``` -Move to the test directory and use make (which is in c:\msys64\usr\bin) to drive the test procedures. You cannot run the tests in the build directory because there is no Makefile in the build directory. +You may prefer to run tests in the directory using MinGW/msys2 make. ``` -c:\...\exiv2\build\bin>cd ..\..\test +c:\...\exiv2\build\>cd ..\test c:\...\exiv2\test>make bash_tests ... c:\...\exiv2\test>make python_tests # or unit_test or version_test @@ -895,53 +891,24 @@ c:\...\exiv2\test>make tests # run all the tests ... ``` -I use the following batch file _cmd64.bat_ to set up a special path for cmd.exe. This ensures that I can jump instantly to the test directory with all the correct tools (DOS python, DOS cmake, msys/bash etc) on the PATH. - -``` -@echo off -setlocal -set "P=" -set "P=%P%C:\Python37\;C:\Python37\Scripts;" # DOS Python3 -set "P=%P%c:\Program Files\cmake\bin;" # DOS cmake -set "P=%P%c:\msys64\usr\bin;" # msys2 make, bash etc -set "P=%P%c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin;" -set "P=%P%c:\Windows\System32;" # windows -set "P=%P%%USERPROFILE%\com;" # my home-made magic -set "PATH=%P%" -set "EXIV2_EXT=.exe" -color 1e -cmd /S /K cd "%USERPROFILE%\gnu\github\exiv2\0.27-maintenance\" -color -endlocal -``` - -When you have the PATH constructed is this way, you can use the cmake command to run tests directly from the build directory as follows: - -``` -c:\...\exiv2\test>cd ..\build -c:\...\exiv2\build>cmake --build . --config Release --target tests -``` - If you wish to use an environment variables, use env: ``` c:\...\exiv2\build>env VERBOSE=1 cmake --build . --config Release --target tests ``` -When you are in the test directory, msys/make provides the following _(more convenient)_ syntax: +When you are in the test directory, MinGW/msys2 make supports the following _(more convenient)_ syntax: ``` c:\...\exiv2\test>make tests VERBOSE=1 ``` - - [TOC](#TOC)
### 4.3 Unit tests -The code for the unit tests is in `/unitTests`. To include unit tests in the build, use the *cmake* option `-DEXIV2_BUILD_UNIT_TESTS=ON`. +The code for the unit tests is in `/unitTests`. To include unit tests in the build, use the *cmake* option `-DEXIV2_BUILD_UNIT_TESTS=On`. There is a discussion on the web about installing GTest: [https://github.com/Exiv2/exiv2/issues/575](https://github.com/Exiv2/exiv2/issues/575) @@ -1089,7 +1056,7 @@ $ make #### MinGW and Regex -The exiv2 command line program provides an option **`--grep`** to filter output. The implementation requires the header file **``** and supporting library to be available during the build. When not available, the option **`--grep`** degrades to a substring match. Because there are several versions of **``** available on the MinGW platform, detection of regex is always disabled on this platform and uses substring match. The following command reveals if regex is included in your build: +The exiv2 command-line program provides an option **`--grep`** to filter output. The implementation requires the header file **``** and supporting library to be available during the build. When not available, the option **`--grep`** degrades to a substring match. Because there are several versions of **``** available on the MinGW platform, detection of regex is always disabled on this platform and uses substring match. The following command reveals if regex is included in your build: ```bash $ exiv2 -vVg regex @@ -1152,15 +1119,13 @@ setlocal set "P=" set "P=%P%C:\Python37\;C:\Python37\Scripts;" # DOS Python3 set "P=%P%c:\Program Files\cmake\bin;" # DOS cmake -set "P=%P%c:\msys64\usr\bin;" # msys2 make, bash etc +set "P=%P%c:\msys64\usr\bin;" # MinGW/msys2 make, bash etc set "P=%P%c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin;" set "P=%P%c:\Windows\System32;" # windows set "P=%P%%USERPROFILE%\com;" # my home-made magic set "PATH=%P%" set "EXIV2_EXT=.exe" -color 1e cmd /S /K cd "%USERPROFILE%\gnu\github\exiv2\0.27-maintenance\" -color endlocal ``` @@ -1263,5 +1228,5 @@ $ sudo pkg install developer/gcc-7 [TOC](#TOC) -Written by Robin Mills
robin@clanmills.com
Updated: 2020-05-12 +Written by Robin Mills
robin@clanmills.com
Updated: 2020-05-17 diff --git a/samples/exifprint.cpp b/samples/exifprint.cpp index a8bfbc3d..19c521d9 100644 --- a/samples/exifprint.cpp +++ b/samples/exifprint.cpp @@ -36,7 +36,7 @@ try { const _tchar* file = argv[1]; if (argc != 2) { - std::_tcout << _t("Usage: ") << prog << _t(" [ file | --version || --version-test ]") << std::endl; + std::_tcout << _t("Usage: ") << prog << _t(" [ path | --version | --version-test ]") << std::endl; return 1; } From f24f24e02678939435c4a1c65d7587e37809c6a1 Mon Sep 17 00:00:00 2001 From: clanmills Date: Mon, 18 May 2020 18:28:30 +0100 Subject: [PATCH 35/35] Documentation updates for v0.27.3 RC2 --- README-SAMPLES.md | 23 ++++++++++++++--------- README.md | 1 + samples/exifcomment.cpp | 10 +++------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/README-SAMPLES.md b/README-SAMPLES.md index 22505ace4..5c7b512f 100644 --- a/README-SAMPLES.md +++ b/README-SAMPLES.md @@ -10,6 +10,8 @@ Exiv2 is a C++ library and a command line utility to read, write, delete and mod ### Sample Programs +The following programs are build and installed in /usr/local/bin. + | Name | Purpose | More information | Code | |:--- |:--- |:--- |:-- | | _**addmoddel**_ | Demonstrates Exiv2 library APIs to add, modify or delete metadata | [addmoddel](#addmoddel) | [addmoddel.cpp](samples/addmoddel.cpp) | @@ -24,6 +26,8 @@ Exiv2 is a C++ library and a command line utility to read, write, delete and mod | _**iptcprint**_ | Demonstrates Exiv2 library APIs to print Iptc data | [iptceasy](#iptceasy) | [iptcprint.cpp](samples/iptcprint.cpp) | | _**metacopy**_ | Demonstrates copying metadata from one image to another | [metacopy](#metacopy) | [metacopy.cpp](samples/metacopy.cpp) | | _**mrwthumb**_ | Sample program to extract a Minolta thumbnail from the makernote | [mrwthumb](#mrwthumb) | [mrwthumb.cpp](samples/mrwthumb.cpp) | +| _**taglist**_ | Print a simple comma separated list of tags defined in Exiv2 | [taglist](#taglist) | +| _**xmpdump**_ | Sample program to dump the XMP packet of an image | [xmpdump](#xmpdump) | | _**xmpparse**_ | Read an XMP packet from a file, parse it and print all (known) properties. | [xmpparse](#xmpparse) | [xmpparse.cpp](samples/xmpparse.cpp) | | _**xmpprint**_ | Read an XMP from a file, parse it and print all (known) properties.. | [xmpprint](#xmpprint) | [xmpprint.cpp](samples/xmpprint.cpp) | | _**xmpsample**_ | Demonstrates Exiv2 library high level XMP classes | [xmpsample](#xmpsample) | [xmpsample.cpp](samples/exmpsample.cpp) | @@ -34,7 +38,7 @@ Exiv2 is a C++ library and a command line utility to read, write, delete and mod ### Test Programs -As Exiv2 is open source, we publish all our materials. Some of the following programs are actively used in our test harness. Some of the following programs were written during the development of features and their on-going use may be limited, or even obsolete. In general these programs are published as source and Team Exiv2 will not provide support to users. +As Exiv2 is open source, we publish all our materials. The following programs are actively used in our test harness. Some were written during feature development of features and their on-going use may be limited, or even obsolete. In general these programs are published as source and Team Exiv2 will not provide support to users. | Name | Kind | More information | |:--- |:--- |:--- | @@ -52,13 +56,11 @@ As Exiv2 is open source, we publish all our materials. Some of the following pr | _**prevtest**_ | Test access to preview images | [prevtest](#prevtest) | | _**remotetest**_ | Tester application for testing remote i/o. | [remotetest](#remotetest) | | _**stringto-test**_ | Test conversions from string to long, float and Rational types. | [stringto-test](#stringto-test) | -| _**taglist**_ | Print a simple comma separated list of tags defined in Exiv2 | [taglist](#taglist) | | _**tiff-test**_ | Simple TIFF write test | [tiff-test](#tiff-test) | | _**werror-test**_ | Simple tests for the wide-string error class WError | [werror-test](#werror-test) | | _**write-test**_ | ExifData write unit tests | [write-test](#write-test) | | _**write2-test**_ | ExifData write unit tests for Exif data created from scratch | [write2-test](#write2-test) | -| _**xmpdump**_ | Sample program to dump the XMP packet of an image | [xmpdump](#xmpdump) | -| _**xmpparser-test**_ | Read an XMP packet from a file, parse and re-serialize it. | [xmpparser-test](#xmpparser-test) | +| _**xmpparser-test**_ | Read an XMP packet from a file, parse and re-serialize it. | [xmpparser-test](#xmpparser-test)| [Sample](#TOC1) Programs [Test](#TOC2) Programs @@ -106,16 +108,16 @@ This is a simple program to demonstrate dumping _**Exif**_ metadata in common fo #### exifprint ``` -Usage: exifprint [ file | --version | --version-test ] +Usage: exifprint [ path | --version | --version-test ] ``` | Arguments | Description | |:-- |:--- | -| file | Path to image | +| path | Path to image | | --version | Print version information from build | | --version-test | Tests Exiv2 VERSION API | -This program demonstrates how to print _**Exif**_ metadata in an image. This program is also discussed in the platform ReadMe.txt file included in a build bundle. The option **--version** was added enable the user to build a test application which dumps the build information. The option **--version-test** was added to test the macro EXIV2\_TEST\_VERSION() in **include/exiv2/version.hpp**. +This program demonstrates how to print _**Exif**_ metadata in an image. This program is also discussed in the platform ReadMe.txt file included in a build bundle. The option **--version** was added to enable the user to build a test application which dumps the build information. The option **--version-test** was added to test the macro EXIV2\_TEST\_VERSION() in **include/exiv2/version.hpp**. There is one other unique feature of this program. It is the only test/sample program which can use the EXV\_UNICODE\_PATH build feature of Exiv2 on Windows. @@ -204,13 +206,16 @@ If the path is a directory, geotag will read all the files in the directory. It | Arguments | Description | |:-- |:--- | -| -ascii | Output in ascii (not UTF8). Prints `deg` instead of °. | +| -help | print usage statement | +| -version | prints data and time of compiling geotag.cpp | | -dst | Apply 1 hour adjustment for daylight saving time. | | -dryrun | Read arguments and print report. Does not modify images. | +| -ascii | Output in ascii (not UTF8). Prints `deg` instead of °. | | -verbose | Report progress. | | -adjust value | Add/subtract time from image data. | | -tz value | Specify time zone. For example PST = -8:00 | | -delta value | Correction between Image DataTime and GPS time. | +| path+ | One or more directories, image paths or gpx paths. Directories are searched for gpx and images | I use this program frequently. I have a little Canon camera which I take when I run. My Samsung Galaxy Watch uploads my runs to Strava and I download the GPX. If I'm in another time-zone and have forgotten to change the time setting in the camera, I use `-adjust` to alter the images. The GPX time is always correct, however the camera is normally off by seconds or minutes. This option enables you to correct for inaccuracy in the setting of the camera time. @@ -647,4 +652,4 @@ Read an XMP packet from a file, parse and re-serialize it. Robin Mills
robin@clanmills.com
-Revised: 2019-06-20 \ No newline at end of file +Revised: 2020-05-17 \ No newline at end of file diff --git a/README.md b/README.md index 9b39c20b..a44bd3c8 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ write, delete and modify Exif, IPTC, XMP and ICC image metadata. | Exiv2 Resource | Location | |:---------- |:------ | | Releases and Documentation
Prereleases:
Project Resources
License (GPLv2)
CMake Downloads | [https://exiv2.org](https://exiv2.org)
[https://pre-release.exiv2.org](https://pre-release.exiv2.org)
[https://github.com/Exiv2/exiv2](https://github.com/Exiv2/exiv2)
[COPYING](COPYING)
[https://cmake.org/download/](https://cmake.org/download/) | +| README.md
README-CONAN.md
README-SAMPLES.md | User Manual. _This document_
Conan User Manual _[click here](README-CONAN.md)_
Sample Code Manual. _[click here](README-SAMPLES.md)_ | The file ReadMe.txt in a build bundle describes how to install the library on the platform. ReadMe.txt also documents how to compile and link code on the platform. diff --git a/samples/exifcomment.cpp b/samples/exifcomment.cpp index e395560c..08724a46 100644 --- a/samples/exifcomment.cpp +++ b/samples/exifcomment.cpp @@ -4,14 +4,10 @@ Exif.Photo.UserComment File: exifcomment.cpp - Author(s): Andreas Huggel (ahu) - History : 10-May-04, ahu: created - 16-Jan-05, ahu: updated using CommentValue and operator trickery */ // ***************************************************************************** // included header files #include - #include #include @@ -36,7 +32,7 @@ try { Exiv2 uses a CommentValue for Exif user comments. The format of the comment string includes an optional charset specification at the beginning: - [charset=["]Ascii|Jis|Unicode|Undefined["] ]comment + [charset=[Ascii|Jis|Unicode|Undefined]] comment Undefined is used as a default if the comment doesn't start with a charset definition. @@ -45,9 +41,9 @@ try { the file. */ exifData["Exif.Photo.UserComment"] - = "charset=\"Unicode\" An Unicode Exif comment added with Exiv2"; + = "charset=Unicode A Unicode Exif comment added with Exiv2"; exifData["Exif.Photo.UserComment"] - = "charset=\"Undefined\" An undefined Exif comment added with Exiv2"; + = "charset=Undefined An undefined Exif comment added with Exiv2"; exifData["Exif.Photo.UserComment"] = "Another undefined Exif comment added with Exiv2"; exifData["Exif.Photo.UserComment"]