From f3393f83080c93f70068f81711d02e9612b9ea60 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 20 Dec 2021 11:01:17 +0000 Subject: [PATCH] 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 8adf9e08..98671c33 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 233ecd98..6a70e9f8 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 8e22ab95..f67f6122 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)