diff --git a/.travis.yml b/.travis.yml index d10b8cf9..9a8bffec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ matrix: dist: xenial sudo: required compiler: gcc - env: COVERAGE=1 CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DBUILD_WITH_COVERAGE=ON -DEXIV2_ENABLE_CURL=ON" + env: COVERAGE=1 CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DBUILD_WITH_COVERAGE=ON -DEXIV2_ENABLE_CURL=ON -DCMAKE_CXX_STANDARD=98" - os: linux dist: xenial @@ -18,18 +18,18 @@ matrix: compiler: gcc env: - WITH_VALGRIND=1 - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DEXIV2_ENABLE_CURL=ON" + - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DEXIV2_ENABLE_CURL=ON -DCMAKE_CXX_STANDARD=98" - os: linux dist: xenial sudo: required compiler: clang - env: CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DEXIV2_ENABLE_CURL=ON" + env: CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DEXIV2_ENABLE_CURL=ON -DCMAKE_CXX_STANDARD=98" - os: osx osx_image: xcode11.3 compiler: clang - env: CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DEXIV2_ENABLE_NLS=OFF -DEXIV2_ENABLE_CURL=ON" + env: CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DEXIV2_ENABLE_NLS=OFF -DEXIV2_ENABLE_CURL=ON -DCMAKE_CXX_STANDARD=98" install: ./ci/install.sh script: ./ci/run.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 99e694a4..5088b10f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,9 +28,8 @@ option( EXIV2_ENABLE_SSH "USE Libssh for SshIo (WEBREADY)" option( EXIV2_BUILD_SAMPLES "Build sample applications" ON ) option( EXIV2_BUILD_EXIV2_COMMAND "Build exiv2 command-line executable" ON ) -option( EXIV2_BUILD_UNIT_TESTS "Build unit tests" ON ) +option( EXIV2_BUILD_UNIT_TESTS "Build unit tests" OFF ) option( EXIV2_BUILD_DOC "Add 'doc' target to generate documentation" OFF ) -option( EXIV2_BUILD_USE_C++11 "Use the C++11 compiler" OFF ) # Only intended to be used by Exiv2 developers/contributors option( EXIV2_TEAM_EXTRA_WARNINGS "Add more sanity checks using compiler flags" OFF ) diff --git a/README.md b/README.md index 874c0eee..8268fed0 100644 --- a/README.md +++ b/README.md @@ -701,7 +701,7 @@ 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 v0.28 and later do not use auto\_ptr and will build with all 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 v0.28 and later do not use auto\_ptr and will build with modern Standard C++ Compilers. To generate a build with C++11: @@ -712,7 +712,9 @@ $ cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_FLAGS=-Wno-deprecated $ make ``` -The option -DCMAKE\_CXX\_FLAGS=-Wno-deprecated suppresses warnings from C++11 concerning auto\_ptr and other deprecated features. +The option -DCMAKE\_CXX\_STANDARD=11 specifies the C++ Language Standard. Possible values are 98, 11 or 14. + +The option -DCMAKE\_CXX\_FLAGS=-Wno-deprecated suppresses warnings from C++11 concerning auto\_ptr and other deprecated features. **Caution:** Visual Studio users should not use -DCMAKE\_CXX\_FLAGS=-Wno-deprecated. [TOC](#TOC) @@ -768,15 +770,16 @@ There are different kinds of tests: **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) -Environment Variables used by test suite +Environment Variables used by the 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 | +| 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 |
@@ -850,10 +853,11 @@ You can build with Visual Studio using Conan. The is described in detail in [RE As a summary, the procedure is: ``` -c:\...\exiv2> mkdir build +c:\...\exiv2>mkdir build +c:\...\exiv2>cd build 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 +c:\...\exiv2\build>cmake --build . --config Release ... lots of output from compiler and linker ... c:\...\exiv2\build> ``` @@ -867,10 +871,11 @@ c:\...\exiv2\build>copy c:\Python37\python.exe c:\Python37\python3.exe 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. ``` -c:\...\exiv2\build> set EXIV2_BINDIR=%CD% -c:\...\exiv2\build> set EXIV2_EXT=.exe -c:\...\exiv2\build\bin> set "PATH=c:\Python37;c:\Python37\Scripts;c:\msys64\usr\bin;%PATH%" +c:\...\exiv2\build>set EXIV2_BINDIR=%CD% +c:\...\exiv2\build>set EXIV2_EXT=.exe +c:\...\exiv2\build\bin>set "PATH=c:\Python37;c:\Python37\Scripts;c:\msys64\usr\bin;%PATH%" ``` + 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. ``` @@ -895,12 +900,10 @@ 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 -echo %P% set "PATH=%P%" set "EXIV2_EXT=.exe" -set "EXIV2_BINDIR=%USERPROFILE%\gnu\github\exiv2\0.27-maintenance\build\bin" -color 0d -cmd /S /K cd "%EXIV2_BINDIR%\..\.." +color 1e +cmd /S /K cd "%USERPROFILE%\gnu\github\exiv2\0.27-maintenance\" color endlocal ``` @@ -912,6 +915,19 @@ 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: + +``` +c:\...\exiv2\test>make tests VERBOSE=1 +``` + + [TOC](#TOC)
@@ -1078,12 +1094,10 @@ 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 -echo %P% set "PATH=%P%" set "EXIV2_EXT=.exe" -set "EXIV2_BINDIR=%USERPROFILE%\gnu\github\exiv2\0.27-maintenance\build\bin" -color 0d -cmd /S /K cd "%EXIV2_BINDIR%\..\.." +color 1e +cmd /S /K cd "%USERPROFILE%\gnu\github\exiv2\0.27-maintenance\" color endlocal ``` @@ -1187,4 +1201,4 @@ $ sudo pkg install developer/gcc-7 [TOC](#TOC) -Written by Robin Mills
robin@clanmills.com
Updated: 2020-05-02 +Written by Robin Mills
robin@clanmills.com
Updated: 2020-05-06 diff --git a/appveyor.yml b/appveyor.yml index da25fbb5..461d7bf5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,13 +5,14 @@ environment: PYTHON: "C:/Python37-x64" matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 CMAKE_GENERATOR: Ninja INTEGRATION_TESTS: 1 - VS_COMPILER_VERSION: 14 - VCVARS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat + VS_COMPILER_VERSION: 16 + VCVARS: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat ARCHITECTURE: x86_64 UNIT_TESTS: 1 + WEBREADY: True WARNINGS_AS_ERRORS: ON - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 CMAKE_GENERATOR: Ninja @@ -20,14 +21,16 @@ environment: VCVARS: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat ARCHITECTURE: x86_64 UNIT_TESTS: 1 + WEBREADY: True WARNINGS_AS_ERRORS: ON - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 CMAKE_GENERATOR: Ninja - INTEGRATION_TESTS: 0 - VS_COMPILER_VERSION: 11 - VCVARS: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat + INTEGRATION_TESTS: 1 + VS_COMPILER_VERSION: 14 + VCVARS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat ARCHITECTURE: x86_64 UNIT_TESTS: 1 + WEBREADY: True WARNINGS_AS_ERRORS: ON - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 CMAKE_GENERATOR: Ninja @@ -35,8 +38,9 @@ environment: VS_COMPILER_VERSION: 12 VCVARS: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat ARCHITECTURE: x86_64 - UNIT_TESTS: 1 - WARNINGS_AS_ERRORS: ON + UNIT_TESTS: 0 + WEBREADY: False + WARNINGS_AS_ERRORS: OFF shallow_clone: true @@ -45,11 +49,11 @@ install: - echo %APPVEYOR_BUILD_FOLDER% - mkdir C:\projects\deps - cd C:\projects\deps - - appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-win.zip -FileName ninja.zip + - appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.10.0/ninja-win.zip -FileName ninja.zip - 7z x ninja.zip -oC:\projects\deps\ninja > nul - set PATH=C:\projects\deps\ninja;%PATH% - ninja --version - - pip.exe install conan==1.24.0 + - pip.exe install conan==1.24.1 - cd %APPVEYOR_BUILD_FOLDER% before_build: @@ -66,9 +70,9 @@ build_script: - cmd: cd build - cmd: call "%VCVARS%" x86_amd64 - cmd: conan --version - - cmd: conan install .. -o webready=True --build missing + - cmd: conan install .. -o webready=%WEBREADY% --build missing - cmd: echo %CMAKE_GENERATOR% - - cmd: cmake -G "%CMAKE_GENERATOR%" -DEXIV2_TEAM_WARNINGS_AS_ERRORS=%WARNINGS_AS_ERRORS% -DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_NLS=OFF -DEXIV2_ENABLE_PNG=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=%UNIT_TESTS% -DCMAKE_INSTALL_PREFIX=install .. + - cmd: cmake -G "%CMAKE_GENERATOR%" -DEXIV2_TEAM_WARNINGS_AS_ERRORS=%WARNINGS_AS_ERRORS% -DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_NLS=OFF -DEXIV2_ENABLE_PNG=ON -DEXIV2_ENABLE_WEBREADY=%WEBREADY% -DEXIV2_BUILD_UNIT_TESTS=%UNIT_TESTS% -DCMAKE_INSTALL_PREFIX=install .. - cmd: cmake --build . --config Release - cmd: cmake --build . --config Release --target install - cmd: cd bin @@ -76,3 +80,5 @@ build_script: - cmd: cd ../../tests/ - cmd: set EXIV2_EXT=.exe - cmd: if %INTEGRATION_TESTS% == 1 %PYTHON%/python.exe runner.py -v + - cmd: cd ../build/bin + - cmd: exiv2 --version --verbose diff --git a/ci/run.sh b/ci/run.sh index d358fe0f..2a6dfe40 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -6,7 +6,6 @@ set -x source conan/bin/activate if [[ "$(uname -s)" == 'Linux' ]]; then - if [ "$CC" == "clang" ]; then # clang + Ubuntu don't like to run with UBSAN, but ASAN works export CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_CXX_FLAGS=\"-fsanitize=address\" -DCMAKE_C_FLAGS=\"-fsanitize=address\" -DCMAKE_EXE_LINKER_FLAGS=\"-fsanitize=address\" -DCMAKE_MODULE_LINKER_FLAGS=\"-fsanitize=address\"" @@ -19,15 +18,13 @@ else export CMAKE_OPTIONS="$CMAKE_OPTIONS -DEXIV2_TEAM_USE_SANITIZERS=ON" fi - -mkdir build && cd build +mkdir build +cd build conan install .. -o webready=True --build missing - cmake ${CMAKE_OPTIONS} -DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON -DCMAKE_INSTALL_PREFIX=install .. -make -j2 - -make tests -make install +make -j 2 +make tests +make install # Check for detecting issues with the installation of headers if [ `ls install/include/exiv2/ | wc -l` > 10 ]; then @@ -37,11 +34,6 @@ else exit 1 fi -pushd . -cd bin -$EXIV2_VALGRIND ./unit_tests -popd - if [ -n "$COVERAGE" ]; then bash <(curl -s https://codecov.io/bash) fi diff --git a/cmake/compilerFlags.cmake b/cmake/compilerFlags.cmake index f2018781..0418aa61 100644 --- a/cmake/compilerFlags.cmake +++ b/cmake/compilerFlags.cmake @@ -90,6 +90,7 @@ endif () # http://stackoverflow.com/questions/10113017/setting-the-msvc-runtime-in-cmake if(MSVC) + find_program(CLCACHE name clcache.exe PATHS ENV CLCACHE_PATH PATH_SUFFIXES Scripts clcache-4.1.0 @@ -136,4 +137,10 @@ if(MSVC) # Object Level Parallelism add_compile_options(/MP) add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) + + # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ + if (MSVC_VERSION GREATER_EQUAL "1910") # VS2017 and up + add_compile_options("/Zc:__cplusplus") + endif() + endif() diff --git a/conanfile.py b/conanfile.py index d161e655..ad76b393 100644 --- a/conanfile.py +++ b/conanfile.py @@ -40,6 +40,8 @@ class Exiv2Conan(ConanFile): # libopenssl (a transitive dependency) if os_info.is_windows: self.requires('libcurl/7.69.1') + self.options['libcurl'].with_openssl = False + self.options['libcurl'].with_winssl = True else: self.requires('libcurl/7.64.1@bincrafters/stable') diff --git a/contrib/Qt/ReadMe.txt b/contrib/Qt/ReadMe.txt new file mode 100644 index 00000000..5795c885 --- /dev/null +++ b/contrib/Qt/ReadMe.txt @@ -0,0 +1,47 @@ +contrib/Qt/ReadMe.txt +--------------------- + +Exiv2 works well with Qt. + +Qt requires C++11 libraries which are the default for Exiv2 v0.28 and later. +Exiv2 v0.27 default build (and pre-built binaries) are for C++98 +You will have to build Exiv2 v0.27 from source with C++11 for Qt. + +To build and run commandLineTool +-------------------------------- + +1) Windows Users should install MinGW/msys2 as documented in README.md + +2) All users should build Exiv2 with C++11 support as documented in README.md + +3) Generate Makefile + Caution: You will have to modify commandLineTool.pro to fit your environment. + $ cd + $ cd contrib/Qt + $ qmake commandLinePro.pro + +4) Build commandLineTool.cpp + $ make + +5) Run commandLineTool.exe + $ commandLineTool.exe + +UNICODE_PATH on Windows +----------------------- + +Windows users may prefer to build Exiv2 to support UNICODE_PATH. +The sample application samples/exifprint.cpp works with UNICODE_PATH. +The cmake option -DEXIV2_ENABLE_WIN_UNICODE=ON is documented in README.md + +Searching for more information about Qt, MinGW and UNICODE_PATH +--------------------------------------------------------------- +These matters are occasionally discussed on the forum. Please search to read discussions. + +https://github.com/Exiv2/exiv2/issues/1101#issuecomment-623141576 +http://dev.exiv2.org/boards/3/topics/2311?r=2312#message-2312 +http://dev.exiv2.org/issues/1169 +http://dev.exiv2.org/boards/3/topics/2705 + +Robin Mills +http://clanmills.com +2020-05-04 diff --git a/contrib/Qt/commandLineTool.pro b/contrib/Qt/commandLineTool.pro new file mode 100644 index 00000000..f8b9bef2 --- /dev/null +++ b/contrib/Qt/commandLineTool.pro @@ -0,0 +1,15 @@ +QT += core +QT -= gui + +TARGET = commandLineTool +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app +SOURCES += main.cpp + +win32 { + INCLUDEPATH += $$quote(c:/Qt/5.14.2/mingw73_64/include) + INCLUDEPATH += /usr/local/include + LIBS += -L$$quote(c:/Qt/5.14.2/mingw73_64/include) -L/usr/local/lib -lexiv2 +} diff --git a/contrib/Qt/main.cpp b/contrib/Qt/main.cpp new file mode 100644 index 00000000..9e72c4fd --- /dev/null +++ b/contrib/Qt/main.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + exv_grep_keys_t keys; + Exiv2::dumpLibraryInfo(std::cout,keys); + + return 0; + // return a.exec(); +} + diff --git a/include/exiv2/config.h b/include/exiv2/config.h index 2dddcae8..01897dea 100644 --- a/include/exiv2/config.h +++ b/include/exiv2/config.h @@ -97,7 +97,9 @@ typedef int pid_t; #if __cplusplus >= 201103L #include #include - #include + #ifndef _MSC_VER + #include + #endif template using auto_ptr = std::unique_ptr; #endif diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 7628110d..26393352 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -105,7 +105,9 @@ if (EXIV2_ENABLE_WEBREADY) if (USING_CONAN) target_compile_definitions(conntest PRIVATE ${CONAN_COMPILE_DEFINITIONS_LIBCURL}) target_link_libraries(conntest PRIVATE ${CONAN_EXE_LINKER_FLAGS_LIBCURL}) - if (NOT APPLE) + if ( MSVC ) + target_link_libraries(conntest PRIVATE Crypt32 Ws2_32 ${CURL_LIBRARIES}) + elseif (NOT APPLE) target_link_libraries(conntest PRIVATE CONAN_PKG::OpenSSL) endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7809863e..f6efba2a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -182,7 +182,9 @@ if (EXIV2_ENABLE_WEBREADY) if (USING_CONAN) target_compile_definitions(exiv2lib PRIVATE ${CONAN_COMPILE_DEFINITIONS_LIBCURL}) target_link_libraries(exiv2lib PRIVATE ${CONAN_EXE_LINKER_FLAGS_LIBCURL}) - if (NOT APPLE) + if ( MSVC ) + target_link_libraries(exiv2lib PRIVATE Crypt32) + elseif (NOT APPLE) target_link_libraries(exiv2lib PRIVATE CONAN_PKG::OpenSSL) endif() endif() diff --git a/src/version.cpp b/src/version.cpp index 765306db..4c32da5d 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -74,6 +74,7 @@ # include # include # include +# include #elif defined(__sun__) # include # include @@ -185,21 +186,24 @@ static Exiv2::StringVector getLoadedLibraries() pushPath(path,libs,paths); } #elif defined(__FreeBSD__) - unsigned int n; - struct procstat* procstat = procstat_open_sysctl(); - struct kinfo_proc* procs = procstat ? procstat_getprocs(procstat, KERN_PROC_PID, getpid(), &n) : NULL; - struct filestat_list* files = procs ? procstat_getfiles(procstat, procs, true) : NULL; - if ( files ) { - filestat* entry; - STAILQ_FOREACH(entry, files, next) { - std::string path(entry->fs_path); - pushPath(path,libs,paths); + // this code seg-faults when called from an SSH script! (security?) + if ( isatty(STDIN_FILENO) ) { + unsigned int n; + struct procstat* procstat = procstat_open_sysctl(); + struct kinfo_proc* procs = procstat ? procstat_getprocs(procstat, KERN_PROC_PID, getpid(), &n) : NULL; + struct filestat_list* files = procs ? procstat_getfiles(procstat, procs, true) : NULL; + if ( files ) { + filestat* entry; + STAILQ_FOREACH(entry, files, next) { + std::string path(entry->fs_path); + pushPath(path,libs,paths); + } } + // free resources + if ( files ) procstat_freefiles(procstat, files); + if ( procs ) procstat_freeprocs(procstat, procs); + if ( procstat ) procstat_close (procstat); } - // free resources - if ( files ) procstat_freefiles(procstat, files); - if ( procs ) procstat_freeprocs(procstat, procs); - if ( procstat ) procstat_close (procstat); #elif defined (__sun__) || defined(__unix__) // http://stackoverflow.com/questions/606041/how-do-i-get-the-path-of-a-process-in-unix-linux char procsz[100]; @@ -210,8 +214,6 @@ static Exiv2::StringVector getLoadedLibraries() pathsz[l]='\0'; path.assign(pathsz); libs.push_back(path); - } else { - libs.push_back("unknown"); } // read file /proc/self/maps which has a list of files in memory @@ -259,7 +261,7 @@ void Exiv2::dumpLibraryInfo(std::ostream& os,const exv_grep_keys_t& keys) size_t edition = (_MSC_VER-600)/100; const char* editions[] = { "0","1","2","3","4","5","6","2003", "2005", "2008", "2010", "2012","2013","2015","2017","2019"}; if ( edition == 13 && _MSC_VER >= 1910 ) edition++ ; // 2017 _MSC_VAR == 1910 - if ( edition == 13 && _MSC_VER >= 1920 ) edition++ ; // 2019 _MSC_VAR == 1920 + if ( edition == 14 && _MSC_VER >= 1920 ) edition++ ; // 2019 _MSC_VAR == 1920 if ( edition > lengthof(editions) ) edition = 0 ; if ( edition ) sprintf(version+::strlen(version)," (%s/%s)",editions[edition],bits==64?"x64":"x86"); diff --git a/test/Makefile b/test/Makefile index 9d049679..7a5100ee 100644 --- a/test/Makefile +++ b/test/Makefile @@ -139,14 +139,14 @@ unit_test : -@./$@.sh bash_tests: - -if [ -e $$EXIV2_BINDIR/../Makefile ]; then \ + -@if [ -e $$EXIV2_BINDIR/../Makefile ]; then \ -@./$@.sh ; \ else \ make alltest ; \ fi tests: - -if [ -e $$EXIV2_BINDIR/../Makefile ]; then \ + -@if [ -e $$EXIV2_BINDIR/../Makefile ]; then \ -@./$@.sh ; \ else \ make unit_test ; make alltest ; make python_tests ; make version_test ; \ @@ -184,7 +184,7 @@ unixtest: @if [ -e tmp/test-failed ]; then echo '***' FAILED ; cat tmp/test-failed ; echo '***' ; fi python_tests: - -( cd ../tests ; python3 runner.py --verbose ) + -( cd ../tests ; if [ ! -z $$VERBOSE ]; then verbose=--verbose ;fi ; python3 runner.py $$verbose ) testv: diff --git a/test/functions.source b/test/functions.source index 0f1f993e..949394c8 100644 --- a/test/functions.source +++ b/test/functions.source @@ -495,7 +495,7 @@ prepareTest() good="$here/data/${this}.out" results="$here/tmp/${this}.out" tmpfile=$here/tmp/$this - touch $tmpfile + echo '' >> $tmpfile if [ "$PLATFORM" == SunOS -o "$PLATFORM" == FreeBSD -o "$PLATFORM" == NetBSD ] ; then da1="" @@ -508,7 +508,7 @@ prepareTest() fi tmpfile=tmp/ttt - touch $tmpfile + echo '' >> $tmpfile da1="--strip-trailing-cr" diff -q $da1 $tmpfile $tmpfile 2>/dev/null if [ $? -ne 0 ] ; then diff --git a/test/unit_test.sh b/test/unit_test.sh index c2cb0174..70150875 100755 --- a/test/unit_test.sh +++ b/test/unit_test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Test driver for exiv2.exe --verbose --version -( source ./functions.source ; $bin/unit_tests$exe ) +( source ./functions.source ; runTest unit_tests --gtest_color=no | grep -v "Warning: Unsupported date format") # That's all Folks! ## diff --git a/tests/system_tests.py b/tests/system_tests.py index 78e52b98..15525d10 100644 --- a/tests/system_tests.py +++ b/tests/system_tests.py @@ -526,7 +526,6 @@ def path(path_string): return os.path.join(*path_string.split('/')) -def test_run(self): """ This function reads in the attributes commands, retval, stdout, stderr, stdin and runs the `expand_variables` function on each. The resulting @@ -539,6 +538,7 @@ def test_run(self): test by the CaseMeta metaclass. This ensures that it is run by each system test **after** setUp() and setUpClass() were run. """ +def test_run(self): if not (len(self.commands) == len(self.retval) == len(self.stdout) == len(self.stderr) == len(self.stdin)): raise ValueError(