diff --git a/CMakeLists.txt b/CMakeLists.txt index 57eb73f4..c89f90f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,21 +80,49 @@ add_subdirectory( src ) if( EXIV2_BUILD_UNIT_TESTS ) add_subdirectory ( unitTests ) + add_custom_target(unit_test + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make unit_test + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test" + ) endif() # Run a reduced test suite on UNIX #902 -set (TEST test) +set (TEST alltest) if ( CMAKE_HOST_SOLARIS OR CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" ) set (TEST unixtest) endif() +add_custom_target(version_test + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ./version_test.sh + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test" +) if( EXIV2_BUILD_SAMPLES ) ## # tests - add_custom_target(tests - COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make ${TEST} - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test" - ) + if( EXIV2_BUILD_UNIT_TESTS ) + add_custom_target(tests + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make unit_test + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make ${TEST} + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make newtests + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make version_test + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test" + ) + else() + add_custom_target(tests + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make ${TEST} + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make newtests + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make version_test + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test" + ) + endif() + add_custom_target(newtests + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make newtests + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test" + ) + add_custom_target(test + COMMAND env EXIV2_BINDIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" make ${TEST} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test" + ) add_subdirectory( samples ) get_directory_property(SAMPLES DIRECTORY samples DEFINITION APPLICATIONS) add_dependencies(tests exiv2lib exiv2 ${SAMPLES}) diff --git a/README.md b/README.md index d7fa1363..d2ce0d4e 100644 --- a/README.md +++ b/README.md @@ -589,7 +589,7 @@ The Exiv2 command-line and the sample applications call the following at the out ### 2.16 Cross Platform Build and Test on Linux for MinGW -You can cross compile Exiv2 on Linux to build for MinGW. We have used the following method on **Fedora** and believe this is also possible on Ubuntu and other distros. Detailed instructions are provided here for **Fedora**. +You can cross compile Exiv2 on Linux for MinGW. We have used the following method on **Fedora** and believe this is also possible on Ubuntu and other distros. Detailed instructions are provided here for **Fedora**. ### Cross Build and Test On Fedora @@ -736,7 +736,25 @@ For new bug reports and feature requests, please open an issue in Github. ## 4 Running the test suite -The test suite is a mix of bash and python scripts. The python scripts are new to v0.27 and the bash scripts are being replaced as time permits. +There are different kinds of tests: + +| Description | Language | Location | Command
_(in build or test directory)_ | CMake Option to Build | +|:-- |:-- |:-- |:-- |:-- | +| Run all tests | | | $ make tests | | +| Bash scripts | bash | \/test | $ make test | -DEXIV2\_BUILD\_SAMPLES=On | +| Python scripts | python | \/tests | $ make newtests | -DEXIV2\_BUILD\_SAMPLES=On | +| Unit tests | C++ | \/unitTests | $ make unit_test | -DEXIV2\_BUILD\_UNIT\_TESTS_=On | +| Version test | C++ | \/src/version.cpp | $ make version_test | Always in library | + +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_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 |
@@ -753,15 +771,21 @@ $ make tests 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 Cygwin and MinGW/msys builds, also set EXIV2_EXT=.exe +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 ```bash -rmills@rmillsmbp-w7 ~/gnu/github/exiv2/exiv2/build $ cd ../test -rmills@rmillsmbp-w7 ~/gnu/github/exiv2/exiv2/test $ env EXIV2_BINDIR=${PWD}/../build/bin ./icc-test.sh +$ cd /build +$ cd ../test +$ env EXIV2_BINDIR=${PWD}/../build/bin ./icc-test.sh ICC jpg md5 webp md5 png md5 jpg md5 all testcases passed. -rmills@rmillsmbp-w7 ~/gnu/github/exiv2/exiv2/test $ env EXIV2_BINDIR=${PWD}/../build/bin make newtests +$ env EXIV2_BINDIR=${PWD}/../build/bin make newtests +... lots of output ... +test_run (tiff_test.test_tiff_test_program.TestTiffTestProg) ... ok +---------------------------------------------------------------------- +Ran 176 tests in 9.526s +OK (skipped=6) ``` [TOC](#TOC) @@ -779,9 +803,13 @@ $ export EXIV2_EXT=.exe $ export EXIV2_BINDIR=${PWD}/../build/bin ``` -**Caution: ** _The python3 interpreter must be for DOS and called python3.exe. I copied `c:\Python37\python.exe c:\Python37\python3.exe`__ +**Caution:** _The python3 interpreter must be for DOS and called python3.exe. I copied the python.exe program:_ -Once you have modified the PATH and and exported EXIV2\_BINDIR and EXIV2\_EXT, you can execute the test suite as described for UNIX-like systems: +``` +..> copy c:\Python37\python.exe 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: ```bash $ cd /test @@ -795,16 +823,7 @@ $ ./icc-test.sh ### 4.3 Unit tests -The code for the unit tests is in `/unitTests` - -To build the unit tests, use the *cmake* option `-DEXIV2_BUILD_UNIT_TESTS=ON`. - -To execute the unit tests: - -```bash -$ cd /build -$ bin/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`. There is a discussion on the web about installing GTest: [https://github.com/Exiv2/exiv2/issues/575](https://github.com/Exiv2/exiv2/issues/575) @@ -1054,4 +1073,4 @@ $ sudo pkg install developer/gcc-7 [TOC](#TOC) -Written by Robin Mills
robin@clanmills.com
Updated: 2020-04-16 +Written by Robin Mills
robin@clanmills.com
Updated: 2020-04-18 diff --git a/src/exiv2.cpp b/src/exiv2.cpp index ce3fb5ec..a7c542ec 100644 --- a/src/exiv2.cpp +++ b/src/exiv2.cpp @@ -222,7 +222,7 @@ void Params::cleanup() void Params::version(bool verbose,std::ostream& os) const { os << EXV_PACKAGE_STRING << std::endl; - if ( Params::instance().greps_.empty() ) { + if ( Params::instance().greps_.empty() && !verbose) { os << "\n" << _("This program is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU General Public License\n" diff --git a/test/Makefile b/test/Makefile index e706f80b..88b0b134 100644 --- a/test/Makefile +++ b/test/Makefile @@ -133,48 +133,45 @@ xmpparser-test: @echo ---- Running test: $@.sh ---- @echo ./$@.sh - -tests: - cd .. ; make tests -unixtests: - cd .. ; make unixtests +version_test \ +unit_test \ +test \ +tests: + @./$@.sh -test: +alltest: @echo - @echo ---- Running tests: ALL ---- + @echo ---- Running bash tests: ALL ---- @echo mkdir -p tmp @rm -rf tmp/test-failed - @list='$(TESTS1) $(TESTS2) version-test.sh'; for p in $$list; do \ + @list='$(TESTS1) $(TESTS2)'; for p in $$list; do \ echo Running $$p ...; \ ./$$p; \ rc=$$?; \ if [ $$rc -ne 0 ]; then echo '***' ; echo '***' $$p result = $$rc ; echo '***' ; fi ; \ if [ $$rc -ne 0 ]; then echo '***' $$p result = $$rc >> tmp/test-failed ; fi ; \ done - make newtests - @if [ -e tmp/test-failed ]; then echo '***' FAILED ; cat tmp/test-failed ; echo '***' ; exit 255; fi unixtest: @echo - @echo ---- Running test: UNIX subset ---- + @echo ---- Running bash tests: UNIX subset ---- @echo mkdir -p tmp @rm -rf tmp/test-failed - @list='$(TESTS1) version-test.sh'; for p in $$list; do \ + @list='$(TESTS1)'; for p in $$list; do \ echo Running $$p ...; \ ./$$p; \ rc=$$?; \ if [ $$rc -ne 0 ]; then echo '***' ; echo '***' $$p result = $$rc ; echo '***' ; fi ; \ if [ $$rc -ne 0 ]; then echo '***' $$p result = $$rc >> tmp/test-failed ; fi ; \ done - make newtests - @if [ -e tmp/test-failed ]; then echo '***' FAILED ; cat tmp/test-failed ; echo '***' ; exit 255; fi newtests: ( cd ../tests ; python3 runner.py --verbose ) + testv: @for t in /video ; do \ if [ ! -e data/$$t ]; then \ diff --git a/test/functions.source b/test/functions.source index f81a50ee..2a3a3268 100644 --- a/test/functions.source +++ b/test/functions.source @@ -10,8 +10,8 @@ runTest() cd $here/tmp if [ ! -z $EXIV2_ECHO ]; then echoTest $VALGRIND $bin$prog "$@" - fi - $VALGRIND $bin$prog$exe "$@" + fi + $VALGRIND $bin$prog$exe "$@" ) } diff --git a/test/version-test.sh b/test/version-test.sh deleted file mode 100755 index cdf92ee1..00000000 --- a/test/version-test.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -# Test driver for exiv2.exe --verbose --version - -source ./functions.source - -( cd "$testdir" - runTest exiv2 --verbose --version -) - -# That's all Folks! -## diff --git a/test/version_test.sh b/test/version_test.sh new file mode 100755 index 00000000..c9b3cea7 --- /dev/null +++ b/test/version_test.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# Test driver for exiv2.exe --verbose --version + +source ./functions.source + +( cd "$testdir" + runTest exiv2 --verbose --version | grep -v -e ^xmlns + echo xmlns entry count: $(runTest exiv2 --verbose --version | grep -e ^xmlns | wc -l) +) + +# That's all Folks! +##