From 122fb95eb348cde083af388f4ea1d5ca3a93b3d7 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Fri, 17 Dec 2021 16:05:33 +0000 Subject: [PATCH 1/6] Updating documentation to respect ctest. --- CMakeLists.txt | 4 +- README-CONAN.md | 4 +- README.md | 116 ++++++++++++++++++++++++------------------------ 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88a3258735..3dc49c9620 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,9 +118,9 @@ if( EXIV2_BUILD_SAMPLES ) WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose tiff_test ) - add_test(NAME lensTests + add_test(NAME versionTest WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests - COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose lens_tests + COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests/version_test.py ) endif() endif() diff --git a/README-CONAN.md b/README-CONAN.md index bf677ef319..7fca000c78 100644 --- a/README-CONAN.md +++ b/README-CONAN.md @@ -110,7 +110,7 @@ _Profiles for Visual Studio are discussed in detail here: [Visual Studio Notes]( | _**1**_ | Get conan to fetch dependencies

The output can be quite
long as conan downloads and/or builds
zlib, expat, curl and other dependencies.| $ conan install ..
     --build missing | c:\\..\\build> conan install .. --build missing
    --profile msvc2019Release64 | | _**2**_ | Get cmake to generate
makefiles or sln/vcxproj | $ cmake .. | c:\\..\\build> cmake .. -G "Visual Studio 16 2019" | _**3**_ | Build | $ cmake --build . | c:\\..\\build> cmake --build . --config Release
You may prefer to open exiv2.sln and build using the IDE. | -| _**4**_ | Optionally Run Test Suite | $ make tests | c:\\..\\build> cmake --build . --config Release --target tests
[README.md](README.md) | +| _**4**_ | Optionally Run Test Suite | $ make test | c:\\..\\build> cmake --build . --config Release --target test
[README.md](README.md) | @@ -587,4 +587,4 @@ $ cmake -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_ENABLE_CURL=ON .. [TOC](#TOC) -Written by Robin Mills
robin@clanmills.com
Updated: 2021-03-18 +Written by Robin Mills
robin@clanmills.com
Updated: 2021-12-17 diff --git a/README.md b/README.md index 51282b5eb2..29a806ca95 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ The file ReadMe.txt in a build bundle describes how to install the library on th 1. [Running tests on a UNIX-like system](#4-1) 2. [Running tests on Visual Studio builds](#4-2) 3. [Unit tests](#4-3) - 4. [Python tests](#4-4) + 4. [Bugfix tests](#4-4) 5. [Test Summary](#4-5) 6. [Fuzzing](#4-6) 1. [OSS-Fuzz](#4-6-1) @@ -90,8 +90,8 @@ $ 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 +$ ctest +$ sudo cmake --build . --target 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` @@ -120,7 +120,7 @@ I don't know why anybody would uninstall Exiv2. ```bash $ cd ~/gnu/github/exiv2 # location of the project code $ cd build -$ sudo make uninstall +$ sudo cmake --build . --target uninstall ``` These commands will remove the exiv2 executables, library, header files and man page from the standard locations. @@ -395,7 +395,7 @@ Additionally, you will require an additional build step to actually build the do ```bash $ cmake ..options.. -DEXIV2_BUILD_DOC=On -$ make doc +$ cmake --build . --target doc ``` To build the documentation, you must install the following products: @@ -429,7 +429,7 @@ $ cmake .. -G "Unix Makefiles" -DEXIV2_TEAM_PACKAGING=On $ cmake --build . --config Release ... [100%] Built target addmoddel -$ make package +$ cmake --build . --target package ... CPack: - package: /path/to/exiv2/build/exiv2-0.27.1-Linux.tar.gz generated. ``` @@ -437,14 +437,12 @@ CPack: - package: /path/to/exiv2/build/exiv2-0.27.1-Linux.tar.gz generated. 2) Source Package ```bash -$ make package_source +$ cmake --build . --target package_source Run CPack packaging tool for source... ... CPack: - package: /path/to/exiv2/build/exiv2-0.27.1-Source.tar.gz generated. ``` -You may prefer to run `$ cmake --build . --config Release --target package_source` - [TOC](#TOC)
@@ -460,8 +458,7 @@ $ cd $ mkdir build $ cd build $ cmake .. -G "Unix Makefiles" "-DCMAKE_BUILD_TYPE=Debug" -$ make - +$ cmake --build . ``` You must install the library to ensure that your code is linked to the debug library. @@ -532,7 +529,7 @@ Visual Studio and Xcode can build debug or release builds without using the opti With the Unix Makefile generator, the targets can be listed: ```bash -$ make help +$ cmake --build . --target help The following are some of the valid targets for this Makefile: ... all (the default if no target is provided) ... clean @@ -593,10 +590,10 @@ To build with ccache, use the cmake option **-DBUILD\_WITH\_CCACHE=On** $ cd $ mkdir build ; cd build ; cd build $ cmake .. -G "Unix Makefiles" -DBUILD_WITH_CCACHE=On -$ make +$ cmake --build . # Build again to appreciate the performance gain -$ make clean -$ make +$ cmake --build . --target clean +$ cmake --build . ``` Due to the way in which ccache is installed in Fedora (and other Linux distros), ccache effectively replaces the compiler. A default build or **-DBUILD\_WITH\_CCACHE=Off** is not effective and the environment variable CCACHE_DISABLE is required to disable ccache. [https://github.com/Exiv2/exiv2/issues/361](https://github.com/Exiv2/exiv2/issues/361) @@ -767,7 +764,7 @@ To build Exiv2 v0.27.X with C++11: cd mkdir build ; cd build cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_FLAGS=-Wno-deprecated -make +cmake --build . ``` The option -DCMAKE\_CXX\_STANDARD=11 specifies the C++ Language Standard. Possible values are 98, 11, 14, 17 or 20. @@ -864,18 +861,27 @@ For new bug reports, feature requests and support: Please open an issue in Gith [TOC](#TOC)
-## 4 Running the test suite +## 4 Test Suite + +The test suite is implemented using CTest. CMake adds the target 'test' to the build. You can run ctest with the command `$ cmake --build . --target test`, or simply with `$ ctest`. The build creates 5 tests: bashTests, bugfixes, tiffTests, unit_tests and versionTest. You can run all tests or a subset. + +```bash +$ cmake --build . --target test +$ ctest # run all tests and display summary +$ ctest --output-on-failure # run all tests and output failures +$ ctest -R bugfixes # run only bugfixes and display summary +$ ctest -R bugfixes --verbose # run only bugfixes and display all output +``` -#### Different kinds of tests: +#### Test Architecture -| Description | Language | Location | Command
_(in build directory)_ | CMake Option to Build | -|:-- |:-- |:-- |:-- |:-- | -| Run all tests | | | $ make tests | | -| Run all tests | | **Visual Studio Users** | > cmake --build . --target tests | | -| Bash tests | python | tests/bash\_tests | $ make bash_tests | -DEXIV2\_BUILD\_SAMPLES=On | -| Python tests | python | tests | $ make python_tests | -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 | +| Name | Language | Location | Command
_(in build directory)_ | CMake Option to Build | +|:-- |:-- |:-- |:-- |:-- | +| bashTests | python | tests/bash\_tests | $ ctest -R bash | -DEXIV2\_BUILD\_SAMPLES=On | +| bugfixes | python | tests/bugfixes | $ ctest -R bugfixes | -DEXIV2\_BUILD\_SAMPLES=On | +| tiffTests | python | tests/tiff_test | $ ctest -R tiff | -DEXIV2\_BUILD\_SAMPLES=On | +| unit_tests | C++ | unitTests | $ ctest -R unit | -DEXIV2\_BUILD\_UNIT\_TESTS=On | +| versionTest | C++ | src/version.cpp | $ ctest -R version | Always in library | The term _**bash scripts**_ is historical. The implementation of the tests in this collection originally required bash. These scripts have been rewritten in python. Visual Studio Users will appreciate the python implementation as it avoids the @@ -899,17 +905,17 @@ The Variable EXIV2\_PORT or EXIV2\_HTTP can be set to None to skip http tests. [TOC](#TOC)
- -### 4.1 Running tests on a UNIX-like system +### 4.1 Running tests on Unix-like systems You can run tests directly from the build: ```bash $ cmake .. -G "Unix Makefiles" -DEXIV2_BUILD_UNIT_TESTS=On -$ make -... lots of output ... -$ make tests +... lots of output and build summary ... +$ cmake --build . ... lots of output ... +$ cmake --build . --target test +... test summary ... $ ``` @@ -917,13 +923,13 @@ You can run individual tests in the `test` directory. **Caution:** If you build ```bash $ cd /build -$ make bash_tests +$ ctest -R bash --verbose addmoddel_test (testcases.TestCases) ... ok .... Ran 176 tests in 9.526s OK (skipped=6) -$ make python_tests +$ ctest -R bugfixes --verbose ... lots of output ... test_run (tiff_test.test_tiff_test_program.TestTiffTestProg) ... ok ---------------------------------------------------------------------- @@ -934,10 +940,9 @@ $ [TOC](#TOC)
- ### 4.2 Running tests on Visual Studio builds from cmd.exe -**Caution:** _The python3 interpreter must be on the PATH, build for DOS, and called python3.exe. I copied the python.exe program: +**Caution:** _The python3 interpreter must be on the PATH, build for DOS, and called python3.exe._ I copied the python.exe program: ```cmd > copy c:\Python37\python.exe c:\Python37\python3.exe @@ -945,13 +950,11 @@ $ ``` You can execute the test suite as described for UNIX-like systems. -The main difference is that you must use cmake to initiate the test -as make is not a system utility on Windows. ```bash > cd /build -> cmake --build . --target tests -> cmake --build . --target python_tests +> cmake --build . --target test +> ctest -R bugfixes --verbose ``` ##### Running tests from cmd.exe @@ -974,13 +977,12 @@ If you wish to use an environment variables, use set: ``` set VERBOSE=1 -cmake --build . --config Release --target tests +cmake --build . --config Release --target test set VERBOSE= ``` [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`. @@ -1000,24 +1002,23 @@ $ popd [TOC](#TOC)
+### 4.4 Bugfix tests -### 4.4 Python tests - -You can run the python tests from the build directory: +You can run the bugfix tests from the build directory: ```bash $ cd /build -$ make python_tests +$ ctest -R bugfixes ``` If you wish to run in verbose mode: ```bash $ cd /build -$ make python_tests VERBOSE=1 +$ $ ctest -R bugfixes --verbose ``` -The python tests are stored in the directory tests and you can run them all with the command: +The bugfix tests are stored in the directory tests and you can run them all with the command: ```bash $ cd /tests @@ -1036,24 +1037,23 @@ You may wish to get a brief summary of failures with commands such as: ```bash $ cd /build -$ make python_tests 2>&1 | grep FAIL +$ ctest -R bugfixes --verbose 2>&1 | grep FAIL ``` [TOC](#TOC)
- ### 4.5 Test Summary -| *Tests* | Unix Style Platforms _(bash)_ | Visual Studio _(cmd.exe)_ | +| *Tests* | Execute using ctest | Execute using cmake | |:-- |:--- |:-- | -| | $ cd \/build | \> cd \/build | -| tests | $ make tests | \> cmake --build . --config Release --target tests | -| bash_tests | $ make bash_tests | \> cmake --build . --config Release --target bash_tests | -| python_tests | $ make python_tests | \> cmake --build . --config Release --target python_tests | -| unit_test | $ make unit_test | \> cmake --build . --config Release --target unit_test | -| version_test | $ make version_test | \> cmake --build . --config Release --target version_test | - -The name **bash_tests** is historical. They are implemented in python. +| | $ cd \/build | \> cd \/build | +| test | $ ctest | \> cmake --build . --config Release --target test | +| bash_tests | $ ctest -R bash | \> cmake --build . --config Release --target bash_tests | +| bugfixes | $ ctest -R bugfixes | \> cmake --build . --config Release --target bugfix_tests | +| unit_test | $ ctest -R unit | \> cmake --build . --config Release --target unit_test | +| version_test | $ ctest -R version | \> cmake --build . --config Release --target version_test | + +The name **bashTests** is historical. The tests are implemented in python. [TOC](#TOC)
From 56939796a0ae748c7e3636496058a9c1c017a524 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sun, 19 Dec 2021 12:02:18 +0000 Subject: [PATCH 2/6] Restored test lensTest. Minimized differences between main/README.md and 0.27-maintenance/README.md. --- CMakeLists.txt | 4 ++ README.md | 113 ++++++++++++++++++++----------------------------- 2 files changed, 50 insertions(+), 67 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dc49c9620..8adf9e0807 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,6 +114,10 @@ if( EXIV2_BUILD_SAMPLES ) WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bugfixes ) + add_test(NAME lensTests + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests + COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose lens_tests + ) add_test(NAME tiffTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose tiff_test diff --git a/README.md b/README.md index 29a806ca95..233ecd9850 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,19 @@ | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | | [![codecov](https://codecov.io/gh/Exiv2/exiv2/branch/main/graph/badge.svg?token=O9G7Iswx26)](https://codecov.io/gh/Exiv2/exiv2) | [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/exiv2.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:exiv2) | [![Packaging status](https://repology.org/badge/tiny-repos/exiv2.svg)](https://repology.org/metapackage/exiv2/versions) | [![#exiv2-chat on matrix.org](matrix-standard-vector-logo-xs.png)](https://matrix.to/#/#exiv2-chat:matrix.org) | -CI Status: -[![Basic CI for all platforms on push](https://github.com/Exiv2/exiv2/actions/workflows/on_push_BasicWinLinMac.yml/badge.svg?branch=main)](https://github.com/Exiv2/exiv2/actions/workflows/on_push_BasicWinLinMac.yml) -[![CI for different Linux distributions](https://github.com/Exiv2/exiv2/actions/workflows/nightly_Linux_distributions.yml/badge.svg?branch=main)](https://github.com/Exiv2/exiv2/actions/workflows/nightly_Linux_distributions.yml) - -[![Linux Special Builds on PRs](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_linux_special_buils.yml/badge.svg)](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_linux_special_buils.yml) - -[![Linux-Ubuntu Matrix on PRs](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_linux_matrix.yml/badge.svg)](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_linux_matrix.yml) - -[![Mac Matrix on PRs](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_mac_matrix.yml/badge.svg)](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_mac_matrix.yml) - -[![Win Matrix on PRs](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_windows_matrix.yml/badge.svg)](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_windows_matrix.yml) +| **CI Status:** | | | +|:-- |:-- |:-- | +| [![Basic CI for all platforms on push](https://github.com/Exiv2/exiv2/actions/workflows/on_push_BasicWinLinMac.yml/badge.svg?branch=main)](https://github.com/Exiv2/exiv2/actions/workflows/on_push_BasicWinLinMac.yml) | [![CI for different Linux distributions](https://github.com/Exiv2/exiv2/actions/workflows/nightly_Linux_distributions.yml/badge.svg?branch=main)](https://github.com/Exiv2/exiv2/actions/workflows/nightly_Linux_distributions.yml) | [![Linux Special Builds on PRs](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_linux_special_buils.yml/badge.svg)](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_linux_special_buils.yml) | +| [![Linux-Ubuntu Matrix on PRs](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_linux_matrix.yml/badge.svg)](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_linux_matrix.yml) | [![Mac Matrix on PRs](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_mac_matrix.yml/badge.svg)](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_mac_matrix.yml) | [![Win Matrix on PRs](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_windows_matrix.yml/badge.svg)](https://github.com/Exiv2/exiv2/actions/workflows/on_PR_windows_matrix.yml) |
# 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. @@ -32,7 +28,6 @@ The file ReadMe.txt in a build bundle describes how to install the library on th
### TABLE OF CONTENTS -![Exiv2](exiv2.png) 1. [Welcome to Exiv2](#1) 2. [Building, Installing, Using and Uninstalling Exiv2](#2) @@ -63,9 +58,8 @@ The file ReadMe.txt in a build bundle describes how to install the library on th 2. [Running tests on Visual Studio builds](#4-2) 3. [Unit tests](#4-3) 4. [Bugfix tests](#4-4) - 5. [Test Summary](#4-5) - 6. [Fuzzing](#4-6) - 1. [OSS-Fuzz](#4-6-1) + 5. [Fuzzing](#4-5) + 1. [OSS-Fuzz](#4-5-1) 5. [Platform Notes](#5) 1. [Linux](#5-1) 2. [macOS](#5-2) @@ -90,7 +84,7 @@ $ cd ~/gnu/github/exiv2 # location of the project code $ mkdir build && cd build $ cmake .. -DCMAKE_BUILD_TYPE=Release $ cmake --build . -$ ctest +$ ctest --verbose $ sudo cmake --build . --target install ``` @@ -120,7 +114,7 @@ I don't know why anybody would uninstall Exiv2. ```bash $ cd ~/gnu/github/exiv2 # location of the project code $ cd build -$ sudo cmake --build . --target uninstall +$ sudo make uninstall ``` These commands will remove the exiv2 executables, library, header files and man page from the standard locations. @@ -443,7 +437,6 @@ Run CPack packaging tool for source... CPack: - package: /path/to/exiv2/build/exiv2-0.27.1-Source.tar.gz generated. ``` - [TOC](#TOC)
@@ -458,7 +451,8 @@ $ cd $ mkdir build $ cd build $ cmake .. -G "Unix Makefiles" "-DCMAKE_BUILD_TYPE=Debug" -$ cmake --build . +$ make + ``` You must install the library to ensure that your code is linked to the debug library. @@ -756,22 +750,18 @@ You will find that 3 tests fail at the end of the test suite. It is safe to ign ### 2.17 Building with C++11 and other compilers -Exiv2 uses the default compiler for your system. Exiv2 v0.27 was written to the C++ 1998 standard and uses `auto_ptr`. The C++11 and C++14 compilers will issue deprecation warnings about `auto_ptr`. As `auto_ptr` support has been removed from C++17, you cannot build Exiv2 v0.27 with C++17 or later compilers._ Exiv2 v1.0 and later do not use `auto_ptr` and will require a compiler compliant with the C++11 Standard. +Exiv2 uses the default compiler for your system. To build Exiv2 v0.27.X with C++11: ```bash cd mkdir build ; cd build -cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_FLAGS=-Wno-deprecated -cmake --build . +cmake .. -DCMAKE_CXX_STANDARD=11 +make ``` -The option -DCMAKE\_CXX\_STANDARD=11 specifies the C++ Language Standard. Possible values are 98, 11, 14, 17 or 20. - -The option -DCMAKE\_CXX\_FLAGS=-Wno-deprecated suppresses warnings from C++11 concerning `auto_ptr`. The compiler will issue deprecation warnings about video, eps and ssh code in Exiv2 v0.27. This is intentional. These features of Exiv2 will not be available in Exiv2 v1.0. - -**Caution:** Visual Studio users should not use -DCMAKE\_CXX\_FLAGS=-Wno-deprecated. +The option -DCMAKE\_CXX\_STANDARD=11 specifies the C++ Language Standard. Possible values are 11, 14, 17 or 20. [TOC](#TOC)
@@ -863,7 +853,7 @@ For new bug reports, feature requests and support: Please open an issue in Gith ## 4 Test Suite -The test suite is implemented using CTest. CMake adds the target 'test' to the build. You can run ctest with the command `$ cmake --build . --target test`, or simply with `$ ctest`. The build creates 5 tests: bashTests, bugfixes, tiffTests, unit_tests and versionTest. You can run all tests or a subset. +The test suite is implemented using CTest. CMake adds the target 'test' to the build. You can run ctest with the command `$ cmake --build . --target test`, or simply with `$ ctest`. The build creates 6 tests: bashTests, bugfixes, lensTest, tiffTests, unit_tests and versionTest. You can run all tests or a subset. ```bash $ cmake --build . --target test @@ -873,19 +863,16 @@ $ ctest -R bugfixes # run only bugfixes and display summary $ ctest -R bugfixes --verbose # run only bugfixes and display all output ``` -#### Test Architecture - | Name | Language | Location | Command
_(in build directory)_ | CMake Option to Build | |:-- |:-- |:-- |:-- |:-- | | bashTests | python | tests/bash\_tests | $ ctest -R bash | -DEXIV2\_BUILD\_SAMPLES=On | | bugfixes | python | tests/bugfixes | $ ctest -R bugfixes | -DEXIV2\_BUILD\_SAMPLES=On | +| LensTest | C++ | tests/lens_tests | $ ctest -R lens | -DEXIV2\_BUILD\_SAMPLES=On | | tiffTests | python | tests/tiff_test | $ ctest -R tiff | -DEXIV2\_BUILD\_SAMPLES=On | | unit_tests | C++ | unitTests | $ ctest -R unit | -DEXIV2\_BUILD\_UNIT\_TESTS=On | | versionTest | C++ | src/version.cpp | $ ctest -R version | Always in library | -The term _**bash scripts**_ is historical. The implementation of the tests in this collection originally required bash. These -scripts have been rewritten in python. Visual Studio Users will appreciate the python implementation as it avoids the -installation of mingw/cygwin and special PATH settings. +The term _**bash**_ is historical. These tests were originally bash scripts and they have been rewritten in python. Visual Studio Users will appreciate the python implementation as it avoids the installation of mingw/cygwin and special PATH settings. #### Environment Variables used by the test suite: @@ -894,11 +881,11 @@ If you build the code in the directory \build, tests will run using t | Variable | Default | Platforms | Purpose | |:-- |:-- |:-- |:-- | | EXIV2_BINDIR | **\/build/bin** | All Platforms | Path of built binaries (exiv2.exe) | -| EXIV2_PORT | **12762**
**12671**
**12760** | Cygwin
MinGW/msys2
Other Platforms | Test TCP/IP Port | -| EXIV2_HTTP | **http://localhost** | All Platforms | Test http server | -| EXIV2_ECHO | _**not set**_ | All Platforms | For debugging bash scripts | -| VALGRIND | _**not set**_ | All Platforms | For debugging bash scripts | -| VERBOSE | _**not set**_ | All Platforms | Causes make to report its actions | +| EXIV2_PORT | **12762**
**12671**
**12760** | Cygwin
MinGW/msys2
Other Platforms | Test TCP/IP Port | +| EXIV2_HTTP | **http://localhost** | All Platforms | Test http server | +| EXIV2_ECHO | _**not set**_ | All Platforms | For debugging bash scripts | +| VALGRIND | _**not set**_ | All Platforms | For debugging bash scripts | +| VERBOSE | _**not set**_ | Makefile platforms | Causes make to report its actions | | PATH
DYLD\_LIBRARY\_PATH
LD\_LIBRARY\_PATH | $EXIV2\_BINDIR/../lib | Windows
macOS
Other platforms | Path of dynamic libraries | 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. @@ -914,7 +901,7 @@ $ cmake .. -G "Unix Makefiles" -DEXIV2_BUILD_UNIT_TESTS=On ... lots of output and build summary ... $ cmake --build . ... lots of output ... -$ cmake --build . --target test +$ ctest ... test summary ... $ ``` @@ -946,16 +933,23 @@ $ ```cmd > copy c:\Python37\python.exe c:\Python37\python3.exe -> set "PATH=c:\Python37;%PATH% +> set PATH=c:\Python37;%PATH% ``` -You can execute the test suite as described for UNIX-like systems. +You can execute the test suite in a similar manner to that described for UNIX-like systems. You _**must**_ provide the -C config option to ctest for Visual Studio builds. -```bash +```cmd > cd /build -> cmake --build . --target test -> ctest -R bugfixes --verbose +> ctest -C Release +> ctest -C Release -R bugfixes --verbose ``` +Visual Studio can build different configs as follows: + +```cmd +> cmake --build . --config Release # or Debug or MinSizeRel or RelWithDebInfo +> ctest -C Release +``` +The default for **cmake** config option `--config` is `Release`. **ctest** does not have a default for config option `-C`. ##### Running tests from cmd.exe @@ -970,15 +964,15 @@ c:\...\exiv2\build>conan install .. --build missing --profile msvc2019Release c:\...\exiv2\build>cmake .. -DEXIV2_BUILD_UNIT_TESTS=On -G "Visual Studio 16 2019" c:\...\exiv2\build>cmake --build . --config Release ... lots of output from compiler and linker ... -c:\...\exiv2\build> +c:\...\exiv2\build>ctest -C Release ``` If you wish to use an environment variables, use set: ``` -set VERBOSE=1 -cmake --build . --config Release --target test -set VERBOSE= +set EXIV2_PORT=54321 +ctest -C Release --verbose -R bash +set EXIV2_PORT= ``` [TOC](#TOC) @@ -1042,23 +1036,8 @@ $ ctest -R bugfixes --verbose 2>&1 | grep FAIL [TOC](#TOC)
-### 4.5 Test Summary - -| *Tests* | Execute using ctest | Execute using cmake | -|:-- |:--- |:-- | -| | $ cd \/build | \> cd \/build | -| test | $ ctest | \> cmake --build . --config Release --target test | -| bash_tests | $ ctest -R bash | \> cmake --build . --config Release --target bash_tests | -| bugfixes | $ ctest -R bugfixes | \> cmake --build . --config Release --target bugfix_tests | -| unit_test | $ ctest -R unit | \> cmake --build . --config Release --target unit_test | -| version_test | $ ctest -R version | \> cmake --build . --config Release --target version_test | - -The name **bashTests** is historical. The tests are implemented in python. - -[TOC](#TOC) -
-### 4.6 Fuzzing +### 4.5 Fuzzing The code for the fuzzers is in `exiv2dir/fuzz` @@ -1085,9 +1064,9 @@ mkdir corpus For more information about fuzzing see [`fuzz/README.md`](fuzz/README.md). [TOC](#TOC) -
+
-### 4.6.1 OSS-Fuzz +### 4.5.1 OSS-Fuzz Exiv2 is enrolled in [OSS-Fuzz](https://google.github.io/oss-fuzz/), which is a fuzzing service for open-source projects, run by Google. @@ -1331,5 +1310,5 @@ $ sudo pkg install developer/gcc-7 [TOC](#TOC) -Written by Robin Mills
robin@clanmills.com
Updated: 2021-09-21 +Written by Robin Mills
robin@clanmills.com
Updated: 2021-12-19 From 82371c4d09c96c10d510770cc5e9b422377a02b8 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sun, 19 Dec 2021 12:13:15 +0000 Subject: [PATCH 3/6] Adding version_test.py. --- tests/bash_tests/version_test.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/bash_tests/version_test.py diff --git a/tests/bash_tests/version_test.py b/tests/bash_tests/version_test.py new file mode 100644 index 0000000000..62cf67f468 --- /dev/null +++ b/tests/bash_tests/version_test.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +import system_tests +system_tests.BT.verbose_version(True) From e32d3fccad6c65f6611af382c5b26c53dd17f374 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 20 Dec 2021 08:12:43 +0000 Subject: [PATCH 4/6] Fixes following review. --- README-CONAN.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README-CONAN.md b/README-CONAN.md index 7fca000c78..bc0c40d637 100644 --- a/README-CONAN.md +++ b/README-CONAN.md @@ -98,21 +98,19 @@ os_build=Windows [env] ``` -_Profiles for Visual Studio are discussed in detail here: [Visual Studio Notes](#2-2)__ +_Profiles for Visual Studio are discussed in detail here: [Visual Studio Notes](#2-2)_ ##### 1.4) Build dependencies, create build environment, build and test -| | Build Steps | Linux and macOS | Visual Studio | -|:-- |:--------------|--------------------------------|------------------------------| +| | Build Steps | Linux and macOS | Visual Studio | +|:-- |:-------------------------------------------------------------------------|-----------------------|------------------------------| | _**1**_ | Get conan to fetch dependencies

The output can be quite
long as conan downloads and/or builds
zlib, expat, curl and other dependencies.| $ conan install ..
     --build missing | c:\\..\\build> conan install .. --build missing
    --profile msvc2019Release64 | -| _**2**_ | Get cmake to generate
makefiles or sln/vcxproj | $ cmake .. | c:\\..\\build> cmake .. -G "Visual Studio 16 2019" -| _**3**_ | Build | $ cmake --build . | c:\\..\\build> cmake --build . --config Release
You may prefer to open exiv2.sln and build using the IDE. | -| _**4**_ | Optionally Run Test Suite | $ make test | c:\\..\\build> cmake --build . --config Release --target test
[README.md](README.md) | - - +| _**2**_ | Get cmake to generate
makefiles or sln/vcxproj | $ cmake .. | c:\\..\\build> cmake .. -G "Visual Studio 16 2019" +| _**3**_ | Build | $ cmake --build . | c:\\..\\build> cmake --build . --config Release
You may prefer to open exiv2.sln and build using the IDE. | +| _**4**_ | Optionally Run Test Suite
Test documentation: [README.md](README.md) | $ ctest | c:\\..\\build> ctest -C Release | [TOC](#TOC) From f3393f83080c93f70068f81711d02e9612b9ea60 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 20 Dec 2021 11:01:17 +0000 Subject: [PATCH 5/6] Fixes following review. --- CMakeLists.txt | 4 +-- README.md | 74 +++++++++++++++++++++++++--------------- unitTests/CMakeLists.txt | 2 +- 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8adf9e0807..98671c338b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,7 @@ if( EXIV2_BUILD_SAMPLES ) WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests ) - add_test(NAME bugfixes + add_test(NAME bugfixTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bugfixes ) @@ -122,7 +122,7 @@ if( EXIV2_BUILD_SAMPLES ) WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose tiff_test ) - add_test(NAME versionTest + add_test(NAME versionTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests COMMAND cmake -E env EXIV2_BINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${Python3_EXECUTABLE} runner.py --verbose bash_tests/version_test.py ) diff --git a/README.md b/README.md index 233ecd9850..6a70e9f87b 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,8 @@ The file ReadMe.txt in a build bundle describes how to install the library on th 4. [Test Suite](#4) 1. [Running tests on a UNIX-like system](#4-1) 2. [Running tests on Visual Studio builds](#4-2) - 3. [Unit tests](#4-3) - 4. [Bugfix tests](#4-4) + 3. [Unit Tests](#4-3) + 4. [Bugfix Tests](#4-4) 5. [Fuzzing](#4-5) 1. [OSS-Fuzz](#4-5-1) 5. [Platform Notes](#5) @@ -853,39 +853,57 @@ For new bug reports, feature requests and support: Please open an issue in Gith ## 4 Test Suite -The test suite is implemented using CTest. CMake adds the target 'test' to the build. You can run ctest with the command `$ cmake --build . --target test`, or simply with `$ ctest`. The build creates 6 tests: bashTests, bugfixes, lensTest, tiffTests, unit_tests and versionTest. You can run all tests or a subset. +You execute the Test Suite using CTest with the command `$ ctest`. + +The build creates 6 tests: bashTests, bugfixTests, lensTests, tiffTests, unitTests and versionTests. You can run all tests or a subset. To list all available tests, execute ctest with the `-N` or `--show-only` option, which disables execution: + +```bash +.../main/build $ ctest -N +Test project ...main/build + Test #1: bashTests + Test #2: bugfixTests + Test #3: lensTests + Test #4: tiffTests + Test #5: versionTests + Test #6: unitTests + +Total Tests: 6 +.../main/build $ +``` + +ctest provides many option and the following show common use-case scenarios: ```bash -$ cmake --build . --target test $ ctest # run all tests and display summary $ ctest --output-on-failure # run all tests and output failures -$ ctest -R bugfixes # run only bugfixes and display summary -$ ctest -R bugfixes --verbose # run only bugfixes and display all output +$ ctest -R bugfix # run only bugfixTests and display summary +$ ctest -R bugfix --verbose # run only bugfixTests and display all output ``` | Name | Language | Location | Command
_(in build directory)_ | CMake Option to Build | |:-- |:-- |:-- |:-- |:-- | | bashTests | python | tests/bash\_tests | $ ctest -R bash | -DEXIV2\_BUILD\_SAMPLES=On | -| bugfixes | python | tests/bugfixes | $ ctest -R bugfixes | -DEXIV2\_BUILD\_SAMPLES=On | -| LensTest | C++ | tests/lens_tests | $ ctest -R lens | -DEXIV2\_BUILD\_SAMPLES=On | +| bugfixTests | python | tests/bugfixes | $ ctest -R bugfix | -DEXIV2\_BUILD\_SAMPLES=On | +| lensTest | C++ | tests/lens_tests | $ ctest -R lens | -DEXIV2\_BUILD\_SAMPLES=On | | tiffTests | python | tests/tiff_test | $ ctest -R tiff | -DEXIV2\_BUILD\_SAMPLES=On | -| unit_tests | C++ | unitTests | $ ctest -R unit | -DEXIV2\_BUILD\_UNIT\_TESTS=On | -| versionTest | C++ | src/version.cpp | $ ctest -R version | Always in library | +| unitTests | C++ | unitTests/ | $ ctest -R unit | -DEXIV2\_BUILD\_UNIT\_TESTS=On | +| versionTests | C++ | src/version.cpp | $ ctest -R version | Always in library | -The term _**bash**_ is historical. These tests were originally bash scripts and they have been rewritten in python. Visual Studio Users will appreciate the python implementation as it avoids the installation of mingw/cygwin and special PATH settings. +The term _**bashTests**_ is historical. These tests were originally bash scripts and have been rewritten in python. +Visual Studio Users will appreciate the python implementation as it avoids the installation of mingw/cygwin and special PATH settings. #### 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 | -|:-- |:-- |:-- |:-- | -| EXIV2_BINDIR | **\/build/bin** | All Platforms | Path of built binaries (exiv2.exe) | -| EXIV2_PORT | **12762**
**12671**
**12760** | Cygwin
MinGW/msys2
Other Platforms | Test TCP/IP Port | +| Variable | Default | Platforms | Purpose | +|:-- |:-- |:-- |:-- | +| EXIV2_BINDIR | **\/build/bin** | All Platforms | Path of built binaries (exiv2.exe) | +| EXIV2_PORT | **12762**
**12671**
**12760** | Cygwin
MinGW/msys2
Other Platforms | Test TCP/IP Port | | EXIV2_HTTP | **http://localhost** | All Platforms | Test http server | -| EXIV2_ECHO | _**not set**_ | All Platforms | For debugging bash scripts | -| VALGRIND | _**not set**_ | All Platforms | For debugging bash scripts | -| VERBOSE | _**not set**_ | Makefile platforms | Causes make to report its actions | +| EXIV2_ECHO | _**not set**_ | All Platforms | For debugging bashTests | +| VALGRIND | _**not set**_ | All Platforms | For debugging bashTests | +| VERBOSE | _**not set**_ | Makefile platforms | Instructs make to report its actions | | PATH
DYLD\_LIBRARY\_PATH
LD\_LIBRARY\_PATH | $EXIV2\_BINDIR/../lib | Windows
macOS
Other platforms | Path of dynamic libraries | 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. @@ -916,7 +934,7 @@ addmoddel_test (testcases.TestCases) ... ok Ran 176 tests in 9.526s OK (skipped=6) -$ ctest -R bugfixes --verbose +$ ctest -R bugfix --verbose ... lots of output ... test_run (tiff_test.test_tiff_test_program.TestTiffTestProg) ... ok ---------------------------------------------------------------------- @@ -936,12 +954,12 @@ $ > set PATH=c:\Python37;%PATH% ``` -You can execute the test suite in a similar manner to that described for UNIX-like systems. You _**must**_ provide the -C config option to ctest for Visual Studio builds. +You can execute the test suite in a similar manner to that described for UNIX-like systems. You _**must**_ provide the `-C` config option to ctest for Visual Studio builds. ```cmd > cd /build > ctest -C Release -> ctest -C Release -R bugfixes --verbose +> ctest -C Release -R bugfix --verbose ``` Visual Studio can build different configs as follows: @@ -977,7 +995,7 @@ set EXIV2_PORT= [TOC](#TOC)
-### 4.3 Unit tests +### 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`. @@ -996,23 +1014,23 @@ $ popd [TOC](#TOC)
-### 4.4 Bugfix tests +### 4.4 Bugfix Tests You can run the bugfix tests from the build directory: ```bash $ cd /build -$ ctest -R bugfixes +$ ctest -R bugfix ``` If you wish to run in verbose mode: ```bash $ cd /build -$ $ ctest -R bugfixes --verbose +$ $ ctest -R bugfix --verbose ``` -The bugfix tests are stored in the directory tests and you can run them all with the command: +The bugfix tests are stored in directory tests/ and you can run them all with the command: ```bash $ cd /tests @@ -1031,7 +1049,7 @@ You may wish to get a brief summary of failures with commands such as: ```bash $ cd /build -$ ctest -R bugfixes --verbose 2>&1 | grep FAIL +$ ctest -R bugfix --verbose 2>&1 | grep FAIL ``` [TOC](#TOC) @@ -1310,5 +1328,5 @@ $ sudo pkg install developer/gcc-7 [TOC](#TOC) -Written by Robin Mills
robin@clanmills.com
Updated: 2021-12-19 +Written by Robin Mills
robin@clanmills.com
Updated: 2021-12-20 diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 8e22ab95ae..f67f61227e 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -51,4 +51,4 @@ if (MSVC) set_target_properties(unit_tests PROPERTIES LINK_FLAGS "/ignore:4099") endif() -add_test(NAME unit_tests COMMAND unit_tests) +add_test(NAME unitTests COMMAND unit_tests) From 10661d63706c32ff1acadc7608f4a3c8d8a8851d Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 20 Dec 2021 11:41:45 +0000 Subject: [PATCH 6/6] Fix `$ $` typo. Well spotted, @kmilos. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a70e9f87b..1a9d2e70b2 100644 --- a/README.md +++ b/README.md @@ -1027,7 +1027,7 @@ If you wish to run in verbose mode: ```bash $ cd /build -$ $ ctest -R bugfix --verbose +$ ctest -R bugfix --verbose ``` The bugfix tests are stored in directory tests/ and you can run them all with the command: