diff --git a/.travis.yml b/.travis.yml index 2b8f1b91..31d7db6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,10 @@ env: - secure: "p17X8wFVnUeU3oGAUeUpOJknniwIkliHaLLeHWNHrX1Op794acHEz8wVyuVHLxf5B1Irm8R4UXslzM4y/qAPIB03uaeiam9JJXLVXvKtalMxn856hx9+4TWie/HWQjoKQp4zEgUbLrvSkSW2NYUkFjnY3BvotoqyRW3BlYPonw0=" matrix: include: - - env: TARGET="coverity" + - name: "Coverity" + env: + - CONFIGURE_OPTIONS="" + - TARGET="coverity" compiler: clang os: linux dist: trusty @@ -20,43 +23,224 @@ matrix: build_command_prepend: "./synclibs.sh && ./autogen.sh && ./configure" build_command: "make -j4" branch_pattern: master - - env: TARGET="linux-clang" + - name: "Linux with clang" + env: + - CONFIGURE_OPTIONS="" + - CFLAGS="--coverage" + - LDFLAGS="--coverage" + - TARGET="linux-clang" compiler: clang os: linux dist: trusty sudo: required group: edge - - env: TARGET="linux-gcc" + - name: "Linux with gcc" + env: + - CONFIGURE_OPTIONS="" + - CFLAGS="--coverage" + - LDFLAGS="--coverage" + - TARGET="linux-gcc" compiler: gcc os: linux dist: trusty sudo: required group: edge - - env: TARGET="macos-clang" + - name: "Linux with gcc and wide character type (wchar_t) support" + env: + - CONFIGURE_OPTIONS="--enable-wide-character-type" + - CFLAGS="--coverage" + - LDFLAGS="--coverage" + - TARGET="linux-gcc-wide-character-type" + compiler: gcc + os: linux + dist: trusty + sudo: required + group: edge + - name: "Linux with gcc without optimization" + env: + - CONFIGURE_OPTIONS="--enable-shared=no --enable-wide-character-type" + - CFLAGS="--coverage -O0" + - CPPFLAGS="-DOPTIMIZATION_DISABLED" + - LDFLAGS="--coverage" + - TARGET="linux-gcc-no-optimization" + compiler: gcc + os: linux + dist: trusty + sudo: required + group: edge + - name: "Linux with gcc and Python module" + env: + - CONFIGURE_OPTIONS="--enable-python" + - CFLAGS="--coverage" + - LDFLAGS="--coverage" + - TARGET="linux-gcc-python" + compiler: gcc + os: linux + dist: trusty + sudo: required + group: edge + - name: "Linux with gcc and Python 2 module" + env: + - CONFIGURE_OPTIONS="--enable-python2" + - CFLAGS="--coverage" + - LDFLAGS="--coverage" + - PYTHON_VERSION=2 + - TARGET="linux-gcc-python2" + compiler: gcc + os: linux + dist: trusty + sudo: required + group: edge + - name: "Linux with gcc and Python 3 module" + env: + - CONFIGURE_OPTIONS="--enable-python3" + - CFLAGS="--coverage" + - LDFLAGS="--coverage" + - PYTHON_VERSION=3 + - TARGET="linux-gcc-python3" + compiler: gcc + os: linux + dist: trusty + sudo: required + group: edge + - name: "Linux with gcc and Python 2 module (setup.py)" + env: + - TARGET="linux-gcc-python-setup-py" + compiler: gcc + os: linux + dist: trusty + sudo: required + group: edge + python: 2.7 + - name: "Linux with gcc and Python 3 module (setup.py)" + env: + - TARGET="linux-gcc-python-setup-py" + compiler: gcc + os: linux + dist: trusty + sudo: required + group: edge + python: 3.4 + - name: "Linux with gcc and shared libraries" + env: + - CONFIGURE_OPTIONS="" + - CFLAGS="--coverage" + - LDFLAGS="--coverage" + - TARGET="linux-gcc-shared" + compiler: gcc + os: linux + dist: trusty + sudo: required + group: edge + - name: "Linux with gcc, shared libraries and wide character type (wchar_t) support" + env: + - CONFIGURE_OPTIONS="--enable-wide-character-type" + - CFLAGS="--coverage" + - LDFLAGS="--coverage" + - TARGET="linux-gcc-shared-wide-character-type" + compiler: gcc + os: linux + dist: trusty + sudo: required + group: edge + - name: "Linux with gcc and static executables support" + env: + - CONFIGURE_OPTIONS="--enable-static-executables" + - CFLAGS="--coverage" + - LDFLAGS="--coverage" + - TARGET="linux-gcc-static-executables" + compiler: gcc + os: linux + dist: trusty + sudo: required + group: edge + - name: "MacOS with clang" + env: + - CONFIGURE_OPTIONS="" + - TARGET="macos-clang" compiler: clang os: osx osx_image: xcode8.3 - - env: TARGET="macos-gcc" + - name: "MacOS with gcc" + env: + - CONFIGURE_OPTIONS="" + - TARGET="macos-gcc" + compiler: clang compiler: gcc os: osx osx_image: xcode8.3 - - env: TARGET="shared" + - name: "MacOS with gcc and Python module" + env: + - CONFIGURE_OPTIONS="--enable-python" + - TARGET="macos-gcc-python" + compiler: clang compiler: gcc - os: linux - dist: trusty - sudo: required - group: edge + os: osx + osx_image: xcode8.3 + - name: "MacOS with gcc and Python 2 module" + env: + - CONFIGURE_OPTIONS="--enable-python2" + - PYTHON_VERSION=2 + - TARGET="macos-gcc-python2" + compiler: clang + compiler: gcc + os: osx + osx_image: xcode8.3 + - name: "MacOS with gcc and Python 2 module (setup.py)" + env: + - TARGET="macos-gcc-python-setup-py" + compiler: clang + compiler: gcc + os: osx + osx_image: xcode8.3 + - name: "MacOS gcc and pkgbuild" + env: + - CONFIGURE_OPTIONS="--disable-dependency-tracking --prefix=/usr/local --enable-python --with-pyprefix" + - TARGET="macos-gcc-pkgbuild" + compiler: clang + compiler: gcc + os: osx + osx_image: xcode8.3 before_install: - - if test ${TRAVIS_OS_NAME} = "linux"; then sudo apt-get update && sudo apt-mark hold oracle-java9-installer postgresql-9.2 postgresql-9.3 postgresql-9.4 postgresql-9.5 postgresql-9.6 postgresql-client postgresql-client-common postgresql-common postgresql-contrib-9.2 postgresql-contrib-9.3 postgresql-contrib-9.4 postgresql-contrib-9.5 postgresql-contrib-9.6 postgresql-doc && sudo apt-get --fix-missing -o Dpkg::Options::="--force-confold" upgrade -y --allow-unauthenticated && sudo apt-get install -y autopoint zlib1g-dev; fi - - if test ${TRAVIS_OS_NAME} = "osx"; then brew update && brew install gettext gnu-sed && brew link --force gettext; fi - - if test ${TARGET} = "coverity"; then echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-; fi + - if test ${TRAVIS_OS_NAME} = "linux"; then + sudo apt-get update && sudo apt-mark hold oracle-java8-installer oracle-java9-installer postgresql-9.2 postgresql-9.3 postgresql-9.4 postgresql-9.5 postgresql-9.6 postgresql-client postgresql-client-common postgresql-common postgresql-contrib-9.2 postgresql-contrib-9.3 postgresql-contrib-9.4 postgresql-contrib-9.5 postgresql-contrib-9.6 postgresql-doc && sudo apt-get --fix-missing -o Dpkg::Options::="--force-confold" upgrade -y --allow-unauthenticated && sudo apt-get install -y autopoint zlib1g-dev; + elif test ${TRAVIS_OS_NAME} = "osx"; then + brew update && brew install gettext gnu-sed && brew link --force gettext; + fi + - if test ${TARGET} = "coverity"; then + echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-; + fi install: - - if test ${TRAVIS_OS_NAME} = "osx"; then export SED="/usr/local/bin/gsed"; fi + - if test ${TRAVIS_OS_NAME} = "osx"; then + export SED="/usr/local/bin/gsed"; + fi - ./synclibs.sh --use-head && ./autogen.sh - - if test ${TARGET} = "shared"; then ./configure > /dev/null && make > /dev/null && ./syncsharedlibs.sh --use-head; fi - - if test -x "synctestdata.sh"; then ./synctestdata.sh; fi + - if test ${TARGET} = "linux-gcc-shared" || test ${TARGET} = "linux-gcc-shared-wide-character-type"; then + ./configure > /dev/null && make > /dev/null && ./syncsharedlibs.sh --use-head; + fi + - if test -x "synctestdata.sh"; then + ./synctestdata.sh; + fi script: - - if test ${TRAVIS_OS_NAME} = "linux"; then export PATH=$(echo $PATH | tr ":" "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s/::/:/g"); fi - - if test ${TARGET} != "coverity"; then ./runtests.sh; fi + - if test ${TRAVIS_OS_NAME} = "linux"; then + export PATH=$(echo $PATH | tr ":" "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s/::/:/g"); + fi + - if test ${TARGET} = "linux-gcc-python-setup-py" || test ${TARGET} = "macos-gcc-python-setup-py"; then + python ./setup.py build; + elif test ${TARGET} != "coverity"; then + ./configure ${CONFIGURE_OPTIONS} && make > /dev/null && make check CHECK_WITH_STDERR=1; + if test $? -ne 0 && test -f tests/test-suite.log; then + cat tests/test-suite.log; + fi; + if test ${TARGET} = "macos-gcc-pkgbuild"; then + VERSION=`sed '5!d; s/^ \[//;s/\],$//' configure.ac` && + make install DESTDIR=${PWD}/osx-pkg && + mkdir -p ${PWD}/osx-pkg/usr/share/doc/libpff && + cp AUTHORS COPYING NEWS README ${PWD}/osx-pkg/usr/share/doc/libpff && + pkgbuild --root osx-pkg --identifier com.github.libyal.libpff --version ${VERSION} --ownership recommended ../libpff-${VERSION}.pkg; + fi + fi after_success: - - if test ${TARGET} = "linux-gcc"; then curl -o codecov.sh -s https://codecov.io/bash && /bin/bash ./codecov.sh; fi + - if test ${TARGET} = "linux-gcc-no-optimization"; then + curl -o codecov.sh -s https://codecov.io/bash && /bin/bash ./codecov.sh -n ${TARGET} -y .codecov.yml; + fi diff --git a/appveyor.yml b/appveyor.yml index 274bcfbe..df1dbda1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -108,5 +108,5 @@ test_script: after_test: - cmd: if [%TARGET%]==[mingw] ( copy C:\projects\codecov-bash\codecov C:\MinGW\msys\1.0\home\appveyor\libpff\codecov.sh && - C:\MinGW\msys\1.0\bin\bash -e -l -c "cd libpff && chmod a+x ./codecov.sh && ./codecov.sh" ) + C:\MinGW\msys\1.0\bin\bash -e -l -c "cd libpff && chmod a+x ./codecov.sh && sed -i 's/-execdir /-exec /' ./codecov.sh && ./codecov.sh -n mingw -y .codecov.yml" ) diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 00000000..a28f4256 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,150 @@ +# Script that builds libpff +# +# Version: 20180728 + +Param ( + [string]$Configuration = ${Env:Configuration}, + [string]$MSVSCppConvertOptions = "--extend-with-x64", + [string]$Platform = ${Env:Platform}, + [string]$PythonPath = "C:\Python27", + [string]$VSToolsPath = "..\vstools" +) + +$ExitSuccess = 0 +$ExitFailure = 1 + +$Python = "${PythonPath}\python.exe" + +$Git = "git" +$GitUrl = "https://github.com/libyal/vstools.git" + +$MSVSCppConvert = "${VSToolsPath}\scripts\msvscpp-convert.py" + +If (-Not (Test-Path $Python)) +{ + Write-Host "Missing Python: ${Python}" -foreground Red + + Exit ${ExitFailure} +} +If (-Not (Test-Path ${VSToolsPath})) +{ + # PowerShell will raise NativeCommandError if git writes to stdout or stderr + # therefore 2>&1 is added and the output is stored in a variable. + $Output = Invoke-Expression -Command "${Git} clone ${GitUrl} ${VSToolsPath} 2>&1" +} +Else +{ + Push-Location "${VSToolsPath}" + + Try + { + # Make sure vstools are up to date. + $Output = Invoke-Expression -Command "${Git} pull 2>&1" + } + Finally + { + Pop-Location + } +} +If (-Not (Test-Path ${MSVSCppConvert})) +{ + Write-Host "Missing msvscpp-convert.py: ${MSVSCppConvert}" -foreground Red + + Exit ${ExitFailure} +} +ElseIf (-Not ${Env:VisualStudioVersion}) +{ + Write-Host "Unknown Visual Studio version make sure to set %VisualStudioVersion%" -foreground Red + + Exit ${ExitFailure} +} +$OutputFormat = "" + +If (${Env:VisualStudioVersion} -eq "15.0") +{ + $OutputFormat = "2017" +} +ElseIf (${Env:VisualStudioVersion} -eq "14.0") +{ + $OutputFormat = "2015" +} +ElseIf (${Env:VisualStudioVersion} -eq "12.0") +{ + $OutputFormat = "2013" +} +ElseIf (${Env:VisualStudioVersion} -eq "11.0") +{ + $OutputFormat = "2012" +} +ElseIf (${Env:VisualStudioVersion} -eq "10.0") +{ + $OutputFormat = "2010" +} +ElseIf (${Env:VisualStudioVersion} -eq "9.0") +{ + $OutputFormat = "2008" +} +Else +{ + Write-Host "Unsupported Visual Studio version: %VisualStudioVersion% = ${Env:VisualStudioVersion}" -foreground Red + + Exit ${ExitFailure} +} +If (${OutputFormat} -eq "2017") +{ + $MSBuild = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\amd64\MSBuild.exe" +} +ElseIf (${OutputFormat} -eq "2008") +{ + $MSBuild = "C:\\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe" +} +Else +{ + $MSBuild = "C:\\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" +} +If (-Not (Test-Path ${MSBuild})) +{ + Write-Host "Missing msbuild.exe: ${MSBuild}" -foreground Red + + Exit ${ExitFailure} +} +If (${OutputFormat} -eq "2008") +{ + $VSSolutionPath = "msvscpp" +} +Else +{ + $VSSolutionPath = "vs${OutputFormat}" + + If (-Not (Test-Path "${VSSolutionPath}")) + { + ${Env:PYTHONPATH} = ${VSToolsPath} + + Invoke-Expression -Command "& '${Python}' ${MSVSCppConvert} --output-format ${OutputFormat} ${MSVSCppConvertOptions} msvscpp\libpff.sln" + } +} +$VSSolutionFile = "${VSSolutionPath}\libpff.sln" + +If (-Not (Test-Path "${VSSolutionFile}")) +{ + Write-Host "Missing Visual Studio ${OutputFormat} solution file: ${VSSolutionFile}" -foreground Red + + Exit ${ExitFailure} +} +If (-Not ${Configuration}) +{ + $Configuration = "Release" +} +If (-Not ${Platform}) +{ + $Platform = "Win32" +} +$MSBuildOptions = "/verbosity:quiet /target:Build /property:Configuration=${Configuration},Platform=${Platform}" + +If (${Env:VisualStudioVersion} -eq "15.0") +{ + $MSBuildOptions = "${MSBuildOptions} /property:PlatformToolset=v141" +} +Invoke-Expression -Command "& '${MSBuild}' ${MSBuildOptions} ${VSSolutionFile}" + +Exit ${ExitSuccess} diff --git a/common/types.h.in b/common/types.h.in index 420cb25e..a683efbb 100644 --- a/common/types.h.in +++ b/common/types.h.in @@ -246,7 +246,7 @@ typedef int system_integer_t; #define PRIzu "zu" #define PRIzx "zx" -#elif defined( WINAPI ) +#elif defined( _MSC_VER ) #define PRIzd "Id" #define PRIzi "Ii" #define PRIzu "Iu" @@ -337,6 +337,18 @@ typedef int system_integer_t; #define UINT_MAX UINT32_MAX #endif +/* The maximum signed long integer + */ +#if !defined( LONG_MAX ) +#define LONG_MAX INT32_MAX +#endif + +/* The maximum unsigned long integer + */ +#if !defined( ULONG_MAX ) +#define ULONG_MAX UINT32_MAX +#endif + /* The maximum signed size type is platform dependent */ #if !defined( SSIZE_MAX ) diff --git a/configure.ac b/configure.ac index 25817eea..6faf57d7 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ( 2.59 ) AC_INIT( [libpff], - [20180716], + [20180812], [joachim.metz@gmail.com]) AC_CONFIG_SRCDIR( @@ -119,10 +119,7 @@ dnl Check if libpff required headers and functions are available AX_LIBPFF_CHECK_LOCAL dnl Check if libpff Python bindings (pypff) required headers and functions are available -AX_PYTHON_CHECK_PYPREFIX AX_PYTHON_CHECK_ENABLE -AX_PYTHON2_CHECK_ENABLE -AX_PYTHON3_CHECK_ENABLE AS_IF( [test "x${ac_cv_enable_python}" != xno || test "x${ac_cv_enable_python2}" != xno || test "x${ac_cv_enable_python3}" != xno], @@ -137,10 +134,6 @@ AS_IF( ]) ]) -AM_CONDITIONAL( - HAVE_PYTHON_TESTS, - [test "x${ac_cv_enable_python}" != xno || test "x${ac_cv_enable_python2}" != xno || test "x${ac_cv_enable_python3}" != xno]) - dnl Check if libpff java bindings (jpff) should be build AX_JAVA_CHECK_ENABLE @@ -155,7 +148,7 @@ AS_IF( [test "x$enable_shared" = xyes], [AS_CASE( [$host], - [*cygwin* | *mingw*], + [*cygwin* | *mingw* | *msys*], [AC_DEFINE( [HAVE_DLLMAIN], [1], @@ -164,7 +157,10 @@ AS_IF( [HAVE_DLLMAIN], [1]) - dnl Used in tests + AC_SUBST( + [LIBPFF_DLL_EXPORT], + ["-DLIBPFF_DLL_EXPORT"]) + AC_SUBST( [LIBPFF_DLL_IMPORT], ["-DLIBPFF_DLL_IMPORT"]) @@ -271,9 +267,6 @@ Features: Wide character type support: $ac_cv_enable_wide_character_type pfftools are build as static executables: $ac_cv_enable_static_executables Python (pypff) support: $ac_cv_enable_python - Python version 2 (pypff) support: $ac_cv_enable_python2 - Python version 3 (pypff) support: $ac_cv_enable_python3 - Java (jpff) support: $ac_cv_enable_java Verbose output: $ac_cv_enable_verbose_output Debug output: $ac_cv_enable_debug_output ]); diff --git a/libpff.ini b/libpff.ini index 2b102725..61aa5b0a 100644 --- a/libpff.ini +++ b/libpff.ini @@ -27,6 +27,6 @@ profiles: ["libpff", "pypff", "pffinfo", "pffexport"] example_filename1: "Archive.pst" example_filename2: "outlook.ost" -[coverty] +[coverity] scan_token: "p17X8wFVnUeU3oGAUeUpOJknniwIkliHaLLeHWNHrX1Op794acHEz8wVyuVHLxf5B1Irm8R4UXslzM4y/qAPIB03uaeiam9JJXLVXvKtalMxn856hx9+4TWie/HWQjoKQp4zEgUbLrvSkSW2NYUkFjnY3BvotoqyRW3BlYPonw0=" diff --git a/libpff/Makefile.am b/libpff/Makefile.am index 0a0af6b2..22d7d51f 100644 --- a/libpff/Makefile.am +++ b/libpff/Makefile.am @@ -18,7 +18,8 @@ AM_CPPFLAGS = \ @LIBFWNT_CPPFLAGS@ \ @LIBFMAPI_CPPFLAGS@ \ @ZLIB_CPPFLAGS@ \ - @PTHREAD_CPPFLAGS@ + @PTHREAD_CPPFLAGS@ \ + @LIBPFF_DLL_EXPORT@ lib_LTLIBRARIES = libpff.la diff --git a/libpff/libpff_extern.h b/libpff/libpff_extern.h index 6079b65f..5623ed12 100644 --- a/libpff/libpff_extern.h +++ b/libpff/libpff_extern.h @@ -28,13 +28,6 @@ */ #if !defined( HAVE_LOCAL_LIBPFF ) -/* If libtool DLL support is enabled set LIBPFF_DLL_EXPORT - * before including libpff/extern.h - */ -#if defined( _WIN32 ) && defined( DLL_EXPORT ) -#define LIBPFF_DLL_EXPORT -#endif - #include #define LIBPFF_EXTERN_VARIABLE LIBPFF_EXTERN diff --git a/m4/common.m4 b/m4/common.m4 index b843102e..d9580d45 100644 --- a/m4/common.m4 +++ b/m4/common.m4 @@ -1,6 +1,6 @@ dnl Checks for common headers and functions dnl -dnl Version: 20170903 +dnl Version: 20180729 dnl Function to test if a certain feature was enabled AC_DEFUN([AX_COMMON_ARG_ENABLE], @@ -58,6 +58,9 @@ AC_DEFUN([AX_COMMON_CHECK_ENABLE_WINAPI], [*mingw*],[AC_MSG_NOTICE( [detected MinGW enabling WINAPI support for cross-compilation]) ac_cv_enable_winapi=yes], + [*msys*],[AC_MSG_NOTICE( + [detected MSYS enabling WINAPI support for cross-compilation]) + ac_cv_enable_winapi=yes], [*],[ac_cv_enable_winapi=no]) ]) ]) @@ -78,7 +81,8 @@ AC_DEFUN([AX_COMMON_CHECK_ENABLE_STATIC_EXECUTABLES], AC_SUBST( [STATIC_LDFLAGS]) - ac_cv_enable_static_executables=yes]) + ac_cv_enable_static_executables=yes + enable_shared=no]) ]) dnl Function to detect whether static executables support should be enabled diff --git a/m4/libcpath.m4 b/m4/libcpath.m4 index 04fd062b..acecd8b6 100644 --- a/m4/libcpath.m4 +++ b/m4/libcpath.m4 @@ -1,6 +1,6 @@ -dnl Checks for libcpath or required headers and functions +dnl Checks for libcpath required headers and functions dnl -dnl Version: 20180715 +dnl Version: 20180716 dnl Function to detect if libcpath is available dnl ac_libcpath_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l arguments @@ -24,7 +24,7 @@ AC_DEFUN([AX_LIBCPATH_CHECK_LIB], [test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"], [PKG_CHECK_MODULES( [libcpath], - [libcpath >= 20180715], + [libcpath >= 20180716], [ac_cv_libcpath=yes], [ac_cv_libcpath=check]) ]) @@ -91,22 +91,22 @@ AC_DEFUN([AX_LIBCPATH_CHECK_LIB], [ac_cv_libcpath=no]) AC_CHECK_LIB( cpath, - libcpath_path_join, + libcpath_path_get_sanitized_filename, [ac_cv_libcpath_dummy=yes], [ac_cv_libcpath=no]) AC_CHECK_LIB( cpath, - libcpath_path_make_directory, + libcpath_path_get_sanitized_path, [ac_cv_libcpath_dummy=yes], [ac_cv_libcpath=no]) AC_CHECK_LIB( cpath, - libcpath_path_sanitize, + libcpath_path_join, [ac_cv_libcpath_dummy=yes], [ac_cv_libcpath=no]) AC_CHECK_LIB( cpath, - libcpath_path_sanitize_filename, + libcpath_path_make_directory, [ac_cv_libcpath_dummy=yes], [ac_cv_libcpath=no]) @@ -129,22 +129,22 @@ AC_DEFUN([AX_LIBCPATH_CHECK_LIB], [ac_cv_libcpath=no]) AC_CHECK_LIB( cpath, - libcpath_path_join_wide, + libcpath_path_get_sanitized_filename_wide, [ac_cv_libcpath_dummy=yes], [ac_cv_libcpath=no]) AC_CHECK_LIB( cpath, - libcpath_path_make_directory_wide, + libcpath_path_get_sanitized_path_wide, [ac_cv_libcpath_dummy=yes], [ac_cv_libcpath=no]) AC_CHECK_LIB( cpath, - libcpath_path_sanitize_wide, + libcpath_path_join_wide, [ac_cv_libcpath_dummy=yes], [ac_cv_libcpath=no]) AC_CHECK_LIB( cpath, - libcpath_path_sanitize_filename_wide, + libcpath_path_make_directory_wide, [ac_cv_libcpath_dummy=yes], [ac_cv_libcpath=no]) ]) diff --git a/m4/libfcache.m4 b/m4/libfcache.m4 index 14fe66e6..8ae5e764 100644 --- a/m4/libfcache.m4 +++ b/m4/libfcache.m4 @@ -1,6 +1,6 @@ -dnl Functions for libfcache +dnl Checks for libfcache required headers and functions dnl -dnl Version: 20170904 +dnl Version: 20180728 dnl Function to detect if libfcache is available dnl ac_libfcache_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l arguments diff --git a/m4/libuna.m4 b/m4/libuna.m4 index 4feb20a3..3f7882e2 100644 --- a/m4/libuna.m4 +++ b/m4/libuna.m4 @@ -1,6 +1,6 @@ dnl Checks for libuna or required headers and functions dnl -dnl Version: 20170903 +dnl Version: 20180803 dnl Function to detect if libuna is available as library dnl ac_libuna_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l arguments @@ -24,7 +24,7 @@ AC_DEFUN([AX_LIBUNA_CHECK_LIB], [test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"], [PKG_CHECK_MODULES( [libuna], - [libuna >= 20120425], + [libuna >= 20180803], [ac_cv_libuna=yes], [ac_cv_libuna=no]) ]) diff --git a/m4/python.m4 b/m4/python.m4 index c9683b89..35b19263 100644 --- a/m4/python.m4 +++ b/m4/python.m4 @@ -1,6 +1,6 @@ dnl Functions for Python bindings dnl -dnl Version: 20170806 +dnl Version: 20170830 dnl Function to check if the python binary is available dnl "python${PYTHON_VERSION} python python# python#.#" @@ -8,7 +8,7 @@ AC_DEFUN([AX_PROG_PYTHON], [AS_IF( [test "x${PYTHON_VERSION}" != x], [ax_python_progs="python${PYTHON_VERSION}"], - [ax_python_progs="python python2 python2.7 python2.6 python2.5 python3 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0"]) + [ax_python_progs="python python2 python2.7 python2.6 python2.5 python3 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0"]) AC_CHECK_PROGS( [PYTHON], [$ax_python_progs]) @@ -275,6 +275,12 @@ AC_DEFUN([AX_PYTHON2_CHECK], AC_MSG_RESULT( [$PYTHON2_LDFLAGS]) + dnl For CygWin add the -no-undefined linker flag + AS_CASE( + [$host_os], + [cygwin*],[PYTHON2_LDFLAGS="${PYTHON2_LDFLAGS} -no-undefined"], + [*],[]) + dnl Check for the existence of Python.h BACKUP_CPPFLAGS="${CPPFLAGS}" CPPFLAGS="${CPPFLAGS} ${PYTHON2_INCLUDES}" @@ -380,6 +386,12 @@ AC_DEFUN([AX_PYTHON3_CHECK], AC_MSG_RESULT( [$PYTHON3_LDFLAGS]) + dnl For CygWin add the -no-undefined linker flag + AS_CASE( + [$host_os], + [cygwin*],[PYTHON3_LDFLAGS="${PYTHON3_LDFLAGS} -no-undefined"], + [*],[]) + dnl Check for the existence of Python.h BACKUP_CPPFLAGS="${CPPFLAGS}" CPPFLAGS="${CPPFLAGS} ${PYTHON3_INCLUDES}" @@ -474,7 +486,9 @@ AC_DEFUN([AX_PYTHON_CHECK_PYPREFIX], dnl Function to detect if to enable Python AC_DEFUN([AX_PYTHON_CHECK_ENABLE], - [AX_COMMON_ARG_ENABLE( + [AX_PYTHON_CHECK_PYPREFIX + + AX_COMMON_ARG_ENABLE( [python], [python], [build Python bindings], @@ -486,26 +500,7 @@ AC_DEFUN([AX_PYTHON_CHECK_ENABLE], [no], [no]) - AS_IF( - [test "x${ac_cv_enable_python}" != xno], - [AX_PYTHON_CHECK]) - - AS_IF( - [test "x${ac_cv_enable_python}" != xno], - [AC_DEFINE( - [HAVE_PYTHON], - [1], - [Define to 1 if you have Python]) - ]) - - AM_CONDITIONAL( - HAVE_PYTHON, - [test "x${ac_cv_enable_python}" != xno]) -]) - -dnl Function to detect if to enable Python 2 -AC_DEFUN([AX_PYTHON2_CHECK_ENABLE], - [AX_COMMON_ARG_ENABLE( + AX_COMMON_ARG_ENABLE( [python2], [python2], [build Python 2 bindings], @@ -517,26 +512,7 @@ AC_DEFUN([AX_PYTHON2_CHECK_ENABLE], [no], [no]) - AS_IF( - [test "x${ac_cv_enable_python2}" != xno], - [AX_PYTHON2_CHECK]) - - AS_IF( - [test "x${ac_cv_enable_python2}" != xno], - [AC_DEFINE( - [HAVE_PYTHON2], - [1], - [Define to 1 if you have Python 2]) - ]) - - AM_CONDITIONAL( - HAVE_PYTHON2, - [test "x${ac_cv_enable_python2}" != xno]) -]) - -dnl Function to detect if to enable Python 3 -AC_DEFUN([AX_PYTHON3_CHECK_ENABLE], - [AX_COMMON_ARG_ENABLE( + AX_COMMON_ARG_ENABLE( [python3], [python3], [build Python 3 bindings], @@ -549,19 +525,49 @@ AC_DEFUN([AX_PYTHON3_CHECK_ENABLE], [no]) AS_IF( - [test "x${ac_cv_enable_python3}" != xno], - [AX_PYTHON3_CHECK]) + [test "x${ac_cv_enable_python}" != xno], + [AX_PYTHON_CHECK]) + + AS_IF( + [test "x${ac_cv_enable_python2}" != xno], + [AX_PYTHON2_CHECK]) AS_IF( [test "x${ac_cv_enable_python3}" != xno], - [AC_DEFINE( - [HAVE_PYTHON3], - [1], - [Define to 1 if you have Python 3]) - ]) + [AX_PYTHON3_CHECK]) + + AM_CONDITIONAL( + HAVE_PYTHON, + [test "x${ac_cv_enable_python}" != xno]) + + AM_CONDITIONAL( + HAVE_PYTHON2, + [test "x${ac_cv_enable_python2}" != xno]) AM_CONDITIONAL( HAVE_PYTHON3, [test "x${ac_cv_enable_python3}" != xno]) + + AM_CONDITIONAL( + HAVE_PYTHON_TESTS, + [test "x${ac_cv_enable_python}" != xno || test "x${ac_cv_enable_python2}" != xno || test "x${ac_cv_enable_python3}" != xno]) + + AS_IF( + [test "x${ac_cv_enable_python}" = xno], + [AS_IF( + [test "x${ac_cv_enable_python2}" != xno || test "x${ac_cv_enable_python3}" != xno], + [AS_IF( + [test "x${ac_cv_enable_python2}" != xno], + [ac_cv_enable_python=${ac_cv_enable_python2}], + [ac_cv_enable_python=""]) + AS_IF( + [test "x${ac_cv_enable_python3}" != xno], + [AS_IF( + [test "x${ac_cv_enable_python}" != x], + [ac_cv_enable_python="${ac_cv_enable_python}, "]) + ac_cv_enable_python="${ac_cv_enable_python}${ac_cv_enable_python3}"]) + ]) + ]) + ]) ]) diff --git a/m4/tests.m4 b/m4/tests.m4 index 128afbf7..d82e3dfd 100644 --- a/m4/tests.m4 +++ b/m4/tests.m4 @@ -1,12 +1,12 @@ dnl Functions for testing dnl -dnl Version: 20161212 +dnl Version: 20180723 dnl Function to detect if tests dependencies are available AC_DEFUN([AX_TESTS_CHECK_LOCAL], [AC_CHECK_HEADERS([dlfcn.h]) - AC_CHECK_FUNCS([fmemopen getopt]) + AC_CHECK_FUNCS([fmemopen getopt mkstemp]) AC_CHECK_LIB( dl, diff --git a/m4/types.m4 b/m4/types.m4 index af4a13ec..6343e8da 100644 --- a/m4/types.m4 +++ b/m4/types.m4 @@ -1,6 +1,6 @@ dnl Functions for type definitions dnl -dnl Version: 20161004 +dnl Version: 20180727 dnl Function to detect if type definitions are available AC_DEFUN([AX_TYPES_CHECK_LOCAL], @@ -67,7 +67,7 @@ AC_DEFUN([AX_TYPES_CHECK_LOCAL], AC_TYPE_MODE_T AC_TYPE_OFF_T AC_TYPE_SIZE_T - + AC_CHECK_TYPE( [size32_t], [AC_SUBST( @@ -77,7 +77,7 @@ AC_DEFUN([AX_TYPES_CHECK_LOCAL], [HAVE_SIZE32_T], [0]) ]) - + AC_CHECK_TYPE( [ssize32_t], [AC_SUBST( @@ -87,7 +87,7 @@ AC_DEFUN([AX_TYPES_CHECK_LOCAL], [HAVE_SSIZE32_T], [0]) ]) - + AC_CHECK_TYPE( [size64_t], [AC_SUBST( @@ -97,7 +97,7 @@ AC_DEFUN([AX_TYPES_CHECK_LOCAL], [HAVE_SIZE64_T], [0]) ]) - + AC_CHECK_TYPE( [ssize64_t], [AC_SUBST( @@ -107,7 +107,7 @@ AC_DEFUN([AX_TYPES_CHECK_LOCAL], [HAVE_SSIZE64_T], [0]) ]) - + AC_CHECK_TYPE( [off64_t], [AC_SUBST( @@ -117,14 +117,15 @@ AC_DEFUN([AX_TYPES_CHECK_LOCAL], [HAVE_OFF64_T], [0]) ]) - + AC_CHECK_TYPE([ssize_t]) AC_CHECK_TYPE([u64]) - + AC_CHECK_SIZEOF([int]) + AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([off_t]) AC_CHECK_SIZEOF([size_t]) - + AS_IF( [test "x$ac_cv_header_wchar_h" = xyes], [AC_CHECK_SIZEOF([wchar_t])]) diff --git a/pfftools/pfftools_libpff.h b/pfftools/pfftools_libpff.h index c8686efe..f7c3bd02 100644 --- a/pfftools/pfftools_libpff.h +++ b/pfftools/pfftools_libpff.h @@ -24,13 +24,6 @@ #include -/* If Cygwin libtool DLL support is enabled set LIBPFF_DLL_IMPORT - * before including libpff.h - */ -#if defined( _WIN32 ) && defined( DLL_IMPORT ) && !defined( HAVE_STATIC_EXECUTABLES ) -#define LIBPFF_DLL_IMPORT -#endif - #include #endif /* !defined( _PFFTOOLS_LIBPFF_H ) */ diff --git a/pypff-python2/Makefile.am b/pypff-python2/Makefile.am index d8bd5a25..44330bdf 100644 --- a/pypff-python2/Makefile.am +++ b/pypff-python2/Makefile.am @@ -14,7 +14,8 @@ AM_CFLAGS = \ @LIBUNA_CPPFLAGS@ \ @LIBCFILE_CPPFLAGS@ \ @LIBCPATH_CPPFLAGS@ \ - @LIBBFIO_CPPFLAGS@ + @LIBBFIO_CPPFLAGS@ \ + @LIBPFF_DLL_IMPORT@ am_pypff_la_rpath = -rpath $(pyexecdir2) diff --git a/pypff-python3/Makefile.am b/pypff-python3/Makefile.am index f584325d..abad844d 100644 --- a/pypff-python3/Makefile.am +++ b/pypff-python3/Makefile.am @@ -14,7 +14,8 @@ AM_CFLAGS = \ @LIBUNA_CPPFLAGS@ \ @LIBCFILE_CPPFLAGS@ \ @LIBCPATH_CPPFLAGS@ \ - @LIBBFIO_CPPFLAGS@ + @LIBBFIO_CPPFLAGS@ \ + @LIBPFF_DLL_IMPORT@ am_pypff_la_rpath = -rpath $(pyexecdir3) diff --git a/pypff/Makefile.am b/pypff/Makefile.am index 33d30f32..9d06e49a 100644 --- a/pypff/Makefile.am +++ b/pypff/Makefile.am @@ -8,7 +8,8 @@ AM_CFLAGS = \ @LIBUNA_CPPFLAGS@ \ @LIBCFILE_CPPFLAGS@ \ @LIBCPATH_CPPFLAGS@ \ - @LIBBFIO_CPPFLAGS@ + @LIBBFIO_CPPFLAGS@ \ + @LIBPFF_DLL_IMPORT@ pyexec_LTLIBRARIES = pypff.la diff --git a/pypff/pypff_libpff.h b/pypff/pypff_libpff.h index 830ed79d..f58bb1f2 100644 --- a/pypff/pypff_libpff.h +++ b/pypff/pypff_libpff.h @@ -24,14 +24,7 @@ #include -/* If Cygwin libtool DLL support is enabled set LIBPFF_DLL_IMPORT - * before including libpff.h - */ -#if defined( _WIN32 ) && defined( DLL_EXPORT ) -#define LIBPFF_DLL_IMPORT -#endif - #include -#endif +#endif /* !defined( _PYPFF_LIBPFF_H ) */ diff --git a/runtests.sh b/runtests.sh index 0ef7640f..2c58aa52 100755 --- a/runtests.sh +++ b/runtests.sh @@ -1,7 +1,7 @@ #!/bin/bash # Script that runs the tests # -# Version: 20180214 +# Version: 20180729 EXIT_SUCCESS=0; EXIT_FAILURE=1; @@ -77,7 +77,7 @@ run_configure_make_check_with_asan() then return ${EXIT_SUCCESS}; fi - local LIBASAN=`ldconfig -p | grep libasan | sed 's/^.* => //'`; + local LIBASAN=`ldconfig -p | grep libasan | sed 's/^.* => //' | sort | tail -n 1`; if test -z ${LIBASAN} || test ! -f ${LIBASAN}; then @@ -276,7 +276,7 @@ then exit ${EXIT_FAILURE}; fi - # Test "./configure && make && make check" with non-EVP openssl implementation. + # Test "./configure && make && make check" with OpenSSL non-EVP implementation. run_configure_make_check "--enable-openssl-evp-cipher=no --enable-openssl-evp-md=no"; RESULT=$?; @@ -285,6 +285,16 @@ then then exit ${EXIT_FAILURE}; fi + + # Test "./configure && make && make check" with OpenSSL EVP implementation. + + run_configure_make_check "--enable-openssl-evp-cipher=yes --enable-openssl-evp-md=yes"; + RESULT=$?; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + exit ${EXIT_FAILURE}; + fi fi if test ${HAVE_ENABLE_PYTHON} -eq 0 && test -n "${PYTHON_CONFIG}"; @@ -300,15 +310,19 @@ then run_configure_make_check_python "--enable-python"; RESULT=$?; + export PYTHON_VERSION=; + if test ${RESULT} -ne ${EXIT_SUCCESS}; then exit ${EXIT_FAILURE}; fi - export PYTHON_VERSION=; + export PYTHON_VERSION=2; - run_configure_make "--enable-python2"; + run_configure_make_check_python "--enable-python2"; RESULT=$?; + export PYTHON_VERSION=; + if test ${RESULT} -ne ${EXIT_SUCCESS}; then exit ${EXIT_FAILURE}; @@ -331,15 +345,19 @@ then run_configure_make_check_python "--enable-python"; RESULT=$?; + export PYTHON_VERSION=; + if test ${RESULT} -ne ${EXIT_SUCCESS}; then exit ${EXIT_FAILURE}; fi - export PYTHON_VERSION=; + export PYTHON_VERSION=3; - run_configure_make "--enable-python3"; + run_configure_make_check_python "--enable-python3"; RESULT=$?; + export PYTHON_VERSION=; + if test ${RESULT} -ne ${EXIT_SUCCESS}; then exit ${EXIT_FAILURE}; @@ -394,6 +412,10 @@ if test ${HAVE_ENABLE_WIDE_CHARACTER_TYPE} -eq 0; then CONFIGURE_OPTIONS="${CONFIGURE_OPTIONS} --enable-wide-character-type"; fi +if test ${HAVE_WITH_OPENSSL} -eq 0; +then + CONFIGURE_OPTIONS="${CONFIGURE_OPTIONS} --with-openssl=no"; +fi run_configure_make_check_with_coverage ${CONFIGURE_OPTIONS}; RESULT=$?; diff --git a/setup.py b/setup.py index b0aa2860..f9b5c4a7 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # # Script to build and install Python-bindings. -# Version: 20180408 +# Version: 20180728 from __future__ import print_function import glob @@ -60,18 +60,16 @@ def _RunCommand(self, command): """Runs the command.""" arguments = shlex.split(command) process = subprocess.Popen( - arguments, stderr=subprocess.PIPE, stdout=subprocess.PIPE) + arguments, stderr=subprocess.PIPE, stdout=subprocess.PIPE, + universal_newlines=True) if not process: raise RuntimeError("Running: {0:s} failed.".format(command)) output, error = process.communicate() if process.returncode != 0: - error = "\n".join(error.split(b"\n")[-5:]) - if sys.version_info[0] >= 3: - error = error.decode("ascii", errors="replace") - raise RuntimeError( - "Running: {0:s} failed with error:\n{1:s}.".format( - command, error)) + error = "\n".join(error.split("\n")[-5:]) + raise RuntimeError("Running: {0:s} failed with error:\n{1:s}.".format( + command, error)) return output @@ -97,32 +95,28 @@ def run(self): # We want to build as much as possible self contained Python binding. configure_arguments = [] - for line in output.split(b"\n"): + for line in output.split("\n"): line = line.strip() - line, _, _ = line.rpartition(b"[=DIR]") - if line.startswith(b"--with-lib") and not line.endswith(b"-prefix"): - if sys.version_info[0] >= 3: - line = line.decode("ascii") + line, _, _ = line.rpartition("[=DIR]") + if line.startswith("--with-lib") and not line.endswith("-prefix"): configure_arguments.append("{0:s}=no".format(line)) - elif line == b"--with-bzip2": + elif line == "--with-bzip2": configure_arguments.append("--with-bzip2=no") - elif line == b"--with-openssl": + elif line == "--with-openssl": configure_arguments.append("--with-openssl=no") - elif line == b"--with-zlib": + elif line == "--with-zlib": configure_arguments.append("--with-zlib=no") command = "sh configure {0:s}".format(" ".join(configure_arguments)) output = self._RunCommand(command) print_line = False - for line in output.split(b"\n"): + for line in output.split("\n"): line = line.rstrip() - if line == b"configure:": + if line == "configure:": print_line = True if print_line: - if sys.version_info[0] >= 3: - line = line.decode("ascii") print(line) self.define = [ diff --git a/synclibs.sh b/synclibs.sh index bc545cca..72e3a370 100755 --- a/synclibs.sh +++ b/synclibs.sh @@ -1,7 +1,7 @@ #!/bin/sh # Script that synchronizes the local library dependencies # -# Version: 20171003 +# Version: 20180728 EXIT_SUCCESS=0; EXIT_FAILURE=1; @@ -65,7 +65,7 @@ SED_SCRIPT="/AM_CPPFLAGS = / { if HAVE_LOCAL_${LOCAL_LIB_UPPER} } -/lib_LTLIBRARIES/ { +/lib_LTLIBRARIES = / { s/lib_LTLIBRARIES/noinst_LTLIBRARIES/ } @@ -103,6 +103,7 @@ endif sed -i'~' -f ${LOCAL_LIB}-$$.sed ${LOCAL_LIB_MAKEFILE_AM}; rm -f ${LOCAL_LIB}-$$.sed; + sed -i'~' "/AM_CPPFLAGS = /,/noinst_LTLIBRARIES = / { N; s/\\\\\\n.@${LOCAL_LIB_UPPER}_DLL_EXPORT@//; P; D; }" ${LOCAL_LIB_MAKEFILE_AM}; sed -i'~' "/${LOCAL_LIB}_definitions.h.in/d" ${LOCAL_LIB_MAKEFILE_AM}; sed -i'~' "/${LOCAL_LIB}.rc/d" ${LOCAL_LIB_MAKEFILE_AM}; diff --git a/syncsharedlibs.sh b/syncsharedlibs.sh index 677e9a68..fcf32728 100755 --- a/syncsharedlibs.sh +++ b/syncsharedlibs.sh @@ -1,7 +1,7 @@ #!/bin/sh # Script that synchronizes the shared library dependencies # -# Version: 20170905 +# Version: 20180728 EXIT_SUCCESS=0; EXIT_FAILURE=1; @@ -9,7 +9,7 @@ EXIT_FAILURE=1; GIT_URL_PREFIX="https://github.com/libyal"; SHARED_LIBS="libcerror libcthreads libcdata libclocale libcnotify libcsplit libuna libcfile libcpath libbfio libfcache libfdata libfdatetime libfguid libfvalue libfwnt libfmapi"; -if test ${TRAVIS_OS_NAME} != "linux"; +if test "${TRAVIS_OS_NAME}" != "linux"; then echo "ERROR: This script is intended to be run on Travis CI."; diff --git a/tests/pff_test_functions.c b/tests/pff_test_functions.c index 91ae92fb..85facf43 100644 --- a/tests/pff_test_functions.c +++ b/tests/pff_test_functions.c @@ -347,7 +347,6 @@ int pff_test_get_wide_source( return( -1 ); } - #endif /* defined( HAVE_WIDE_SYSTEM_CHARACTER ) */ if( wide_string_size < wide_source_size ) diff --git a/tests/pff_test_io_handle.c b/tests/pff_test_io_handle.c index 35657118..868c4fde 100644 --- a/tests/pff_test_io_handle.c +++ b/tests/pff_test_io_handle.c @@ -270,6 +270,134 @@ int pff_test_io_handle_free( return( 0 ); } +/* Tests the libpff_io_handle_clear function + * Returns 1 if successful or 0 if not + */ +int pff_test_io_handle_clear( + void ) +{ + libcerror_error_t *error = NULL; + libpff_io_handle_t *io_handle = NULL; + int result = 0; + + /* Initialize test + */ + result = libpff_io_handle_initialize( + &io_handle, + &error ); + + PFF_TEST_ASSERT_EQUAL_INT( + "result", + result, + 1 ); + + PFF_TEST_ASSERT_IS_NOT_NULL( + "io_handle", + io_handle ); + + PFF_TEST_ASSERT_IS_NULL( + "error", + error ); + + /* Test regular cases + */ + result = libpff_io_handle_clear( + io_handle, + &error ); + + PFF_TEST_ASSERT_EQUAL_INT( + "result", + result, + 1 ); + + PFF_TEST_ASSERT_IS_NULL( + "error", + error ); + + /* Test error cases + */ + result = libpff_io_handle_clear( + NULL, + &error ); + + PFF_TEST_ASSERT_EQUAL_INT( + "result", + result, + -1 ); + + PFF_TEST_ASSERT_IS_NOT_NULL( + "error", + error ); + + libcerror_error_free( + &error ); + +#if defined( HAVE_PFF_TEST_MEMORY ) + + /* Test libpff_io_handle_clear with memset failing + */ + pff_test_memset_attempts_before_fail = 0; + + result = libpff_io_handle_clear( + io_handle, + &error ); + + if( pff_test_memset_attempts_before_fail != -1 ) + { + pff_test_memset_attempts_before_fail = -1; + } + else + { + PFF_TEST_ASSERT_EQUAL_INT( + "result", + result, + -1 ); + + PFF_TEST_ASSERT_IS_NOT_NULL( + "error", + error ); + + libcerror_error_free( + &error ); + } +#endif /* defined( HAVE_PFF_TEST_MEMORY ) */ + + /* Clean up + */ + result = libpff_io_handle_free( + &io_handle, + &error ); + + PFF_TEST_ASSERT_EQUAL_INT( + "result", + result, + 1 ); + + PFF_TEST_ASSERT_IS_NULL( + "io_handle", + io_handle ); + + PFF_TEST_ASSERT_IS_NULL( + "error", + error ); + + return( 1 ); + +on_error: + if( error != NULL ) + { + libcerror_error_free( + &error ); + } + if( io_handle != NULL ) + { + libpff_io_handle_free( + &io_handle, + NULL ); + } + return( 0 ); +} + #endif /* defined( __GNUC__ ) && !defined( LIBPFF_DLL_IMPORT ) */ /* The main program @@ -297,7 +425,9 @@ int main( "libpff_io_handle_free", pff_test_io_handle_free ); - /* TODO: add tests for libpff_io_handle_clear */ + PFF_TEST_RUN( + "libpff_io_handle_clear", + pff_test_io_handle_clear ); /* TODO: add tests for libpff_io_handle_read_file_header */ diff --git a/tests/pff_test_libpff.h b/tests/pff_test_libpff.h index 2c625da4..100d35fa 100644 --- a/tests/pff_test_libpff.h +++ b/tests/pff_test_libpff.h @@ -24,13 +24,6 @@ #include -/* If Cygwin libtool DLL support is enabled and do not want to create static - * executables set LIBPFF_DLL_IMPORT before including libpff.h - */ -#if defined( _WIN32 ) && defined( DLL_EXPORT ) && !defined( HAVE_STATIC_EXECUTABLES ) -#define LIBPFF_DLL_IMPORT -#endif - #include #endif /* !defined( _PFF_TEST_LIBPFF_H ) */ diff --git a/tests/pff_test_macros.h b/tests/pff_test_macros.h index 774ff4db..9455485e 100644 --- a/tests/pff_test_macros.h +++ b/tests/pff_test_macros.h @@ -57,6 +57,34 @@ goto on_error; \ } +#define PFF_TEST_ASSERT_EQUAL_INTPTR( name, value, expected_value ) \ + if( value != expected_value ) \ + { \ + fprintf( stdout, "%s:%d %s (0x%08x" PRIjx ") != 0x%08x" PRIjx "\n", __FILE__, __LINE__, name, value, expected_value ); \ + goto on_error; \ + } + +#define PFF_TEST_ASSERT_NOT_EQUAL_INTPTR( name, value, expected_value ) \ + if( value == expected_value ) \ + { \ + fprintf( stdout, "%s:%d %s (0x%08x" PRIjx ") == 0x%08x" PRIjx "\n", __FILE__, __LINE__, name, value, expected_value ); \ + goto on_error; \ + } + +#define PFF_TEST_ASSERT_EQUAL_FLOAT( name, value, expected_value ) \ + if( value != expected_value ) \ + { \ + fprintf( stdout, "%s:%d %s (%f) != %f\n", __FILE__, __LINE__, name, value, expected_value ); \ + goto on_error; \ + } + +#define PFF_TEST_ASSERT_NOT_EQUAL_FLOAT( name, value, expected_value ) \ + if( value == expected_value ) \ + { \ + fprintf( stdout, "%s:%d %s (%f) == %f\n", __FILE__, __LINE__, name, value, expected_value ); \ + goto on_error; \ + } + #define PFF_TEST_ASSERT_EQUAL_SIZE( name, value, expected_value ) \ if( value != expected_value ) \ { \ diff --git a/tests/test_library.ps1 b/tests/test_library.ps1 index a1cc9729..1b78c995 100644 --- a/tests/test_library.ps1 +++ b/tests/test_library.ps1 @@ -1,6 +1,6 @@ # Tests C library functions and types. # -# Version: 20170911 +# Version: 20180805 $ExitSuccess = 0 $ExitFailure = 1 @@ -9,6 +9,34 @@ $ExitIgnore = 77 $LibraryTests = "allocation_table attached_file_io_handle column_definition data_array data_array_entry data_block descriptors_index error index index_node index_value io_handle item item_descriptor item_tree item_values local_descriptor_node local_descriptor_value local_descriptors multi_value name_to_id_map_entry notify offsets_index record_entry record_set reference_descriptor table table_block_index table_index_value value_type" $LibraryTestsWithInput = "file support" +$InputGlob = "*" + +Function GetTestProfileDirectory +{ + param( [string]$TestInputDirectory, [string]$TestProfile ) + + $TestProfileDirectory = "${TestInputDirectory}\.${TestProfile}" + + If (-Not (Test-Path -Path ${TestProfileDirectory} -PathType "Container")) + { + New-Item -ItemType "directory" -Path ${TestProfileDirectory} + } + Return ${TestProfileDirectory} +} + +Function GetTestSetDirectory +{ + param( [string]$TestProfileDirectory, [string]$TestSetInputDirectory ) + + $TestSetDirectory = "${TestProfileDirectory}\${TestSetInputDirectory.Basename}" + + If (-Not (Test-Path -Path ${TestSetDirectory} -PathType "Container")) + { + New-Item -ItemType "directory" -Path ${TestSetDirectory} + } + Return ${TestSetDirectory} +} + Function GetTestToolDirectory { $TestToolDirectory = "" @@ -17,12 +45,6 @@ Function GetTestToolDirectory { ForEach (${VSConfiguration} in "Release VSDebug" -split " ") { - $TestToolDirectory = "..\${VSDirectory}\${VSConfiguration}" - - If (Test-Path ${TestToolDirectory}) - { - Return ${TestToolDirectory} - } ForEach (${VSPlatform} in "Win32 x64" -split " ") { $TestToolDirectory = "..\${VSDirectory}\${VSConfiguration}\${VSPlatform}" @@ -32,11 +54,31 @@ Function GetTestToolDirectory Return ${TestToolDirectory} } } + $TestToolDirectory = "..\${VSDirectory}\${VSConfiguration}" + + If (Test-Path ${TestToolDirectory}) + { + Return ${TestToolDirectory} + } } } Return ${TestToolDirectory} } +Function ReadIgnoreList +{ + param( [string]$TestProfileDirectory ) + + $IgnoreFile = "${TestProfileDirectory}\ignore" + $IgnoreList = "" + + If (Test-Path -Path ${IgnoreFile} -PathType "Leaf") + { + $IgnoreList = Get-Content -Path ${IgnoreFile} | Where {$_ -notmatch '^#.*'} + } + Return $IgnoreList +} + Function RunTest { param( [string]$TestType ) @@ -64,6 +106,72 @@ Function RunTest Return ${Result} } +Function RunTestWithInput +{ + param( [string]$TestType ) + + $TestDescription = "Testing: ${TestName}" + $TestExecutable = "${TestToolDirectory}\pff_test_${TestName}.exe" + + $TestProfileDirectory = GetTestProfileDirectory "input" "libpff" + + $IgnoreList = ReadIgnoreList ${TestProfileDirectory} + + $Result = ${ExitSuccess} + + ForEach ($TestSetInputDirectory in Get-ChildItem -Path "input" -Exclude ".*") + { + If (-Not (Test-Path -Path ${TestSetInputDirectory} -PathType "Container")) + { + Continue + } + If (${TestSetInputDirectory} -Contains ${IgnoreList}) + { + Continue + } + $TestSetDirectory = GetTestSetDirectory ${TestProfileDirectory} ${TestSetInputDirectory} + + If (Test-Path -Path "${TestSetDirectory}\files" -PathType "Leaf") + { + $InputFiles = Get-Content -Path "${TestSetDirectory}\files" | Where {$_ -ne ""} + } + Else + { + $InputFiles = Get-ChildItem -Path ${TestSetInputDirectory} -Include ${InputGlob} + } + ForEach ($InputFile in ${InputFiles}) + { + # TODO: add test option support + $Output = Invoke-Expression ${TestExecutable} + $Result = ${LastExitCode} + + If (${Result} -ne ${ExitSuccess}) + { + Break + } + } + If (${Result} -ne ${ExitSuccess}) + { + Break + } + } + If (${Result} -ne ${ExitSuccess}) + { + Write-Host ${Output} -foreground Red + } + Write-Host "${TestDescription} " -nonewline + + If (${Result} -ne ${ExitSuccess}) + { + Write-Host " (FAIL)" + } + Else + { + Write-Host " (PASS)" + } + Return ${Result} +} + $TestToolDirectory = GetTestToolDirectory If (-Not (Test-Path ${TestToolDirectory})) @@ -97,9 +205,14 @@ Foreach (${TestName} in ${LibraryTestsWithInput} -split " ") { Continue } - # TODO: add RunTestWithInput - $Result = RunTest ${TestName} - + If (Test-Path -Path "input" -PathType "Container") + { + $Result = RunTestWithInput ${TestName} + } + Else + { + $Result = RunTest ${TestName} + } If (${Result} -ne ${ExitSuccess}) { Break diff --git a/tests/test_library.sh b/tests/test_library.sh index ddeb15d7..1c92c541 100755 --- a/tests/test_library.sh +++ b/tests/test_library.sh @@ -1,7 +1,7 @@ #!/bin/bash # Tests C library functions and types. # -# Version: 20170722 +# Version: 20180722 EXIT_SUCCESS=0; EXIT_FAILURE=1; @@ -44,8 +44,77 @@ run_test_with_input() TEST_EXECUTABLE="${TEST_EXECUTABLE}.exe"; fi - run_test_on_input_directory "libpff" "${TEST_DESCRIPTION}" "default" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "input" "${INPUT_GLOB}"; - local RESULT=$?; + if ! test -d "input"; + then + echo "Test input directory: input not found."; + + return ${EXIT_IGNORE}; + fi + local RESULT=`ls input/* | tr ' ' '\n' | wc -l`; + + if test ${RESULT} -eq ${EXIT_SUCCESS}; + then + echo "No files or directories found in the test input directory: input"; + + return ${EXIT_IGNORE}; + fi + + local TEST_PROFILE_DIRECTORY=$(get_test_profile_directory "input" "libpff"); + + local IGNORE_LIST=$(read_ignore_list "${TEST_PROFILE_DIRECTORY}"); + + RESULT=${EXIT_SUCCESS}; + + for TEST_SET_INPUT_DIRECTORY in input/*; + do + if ! test -d "${TEST_SET_INPUT_DIRECTORY}"; + then + continue; + fi + if check_for_directory_in_ignore_list "${TEST_SET_INPUT_DIRECTORY}" "${IGNORE_LIST}"; + then + continue; + fi + + local TEST_SET_DIRECTORY=$(get_test_set_directory "${TEST_PROFILE_DIRECTORY}" "${TEST_SET_INPUT_DIRECTORY}"); + + local OLDIFS=${IFS}; + + # IFS="\n"; is not supported by all platforms. + IFS=" +"; + + if test -f "${TEST_SET_DIRECTORY}/files"; + then + for INPUT_FILE in `cat ${TEST_SET_DIRECTORY}/files | sed "s?^?${TEST_SET_INPUT_DIRECTORY}/?"`; + do + run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "${TEST_DESCRIPTION}" "default" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "${INPUT_FILE}"; + RESULT=$?; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi + done + else + for INPUT_FILE in `ls -1 ${TEST_SET_INPUT_DIRECTORY}/${INPUT_GLOB}`; + do + run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "${TEST_DESCRIPTION}" "default" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "${INPUT_FILE}"; + RESULT=$?; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi + done + fi + IFS=${OLDIFS}; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi + done return ${RESULT}; } diff --git a/tests/test_pffexport.sh b/tests/test_pffexport.sh index 16236744..d03e0c6e 100755 --- a/tests/test_pffexport.sh +++ b/tests/test_pffexport.sh @@ -1,7 +1,7 @@ #!/bin/bash # Export tool testing script # -# Version: 20170901 +# Version: 20180721 EXIT_SUCCESS=0; EXIT_FAILURE=1; @@ -100,8 +100,77 @@ else assert_availability_binary md5sum; fi -run_test_on_input_directory "pffexport" "pffexport" "with_callback" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "input" "${INPUT_GLOB}" "${OPTIONS}"; -RESULT=$?; +if ! test -d "input"; +then + echo "Test input directory: input not found."; + + return ${EXIT_IGNORE}; +fi +RESULT=`ls input/* | tr ' ' '\n' | wc -l`; + +if test ${RESULT} -eq ${EXIT_SUCCESS}; +then + echo "No files or directories found in the test input directory: input"; + + return ${EXIT_IGNORE}; +fi + +TEST_PROFILE_DIRECTORY=$(get_test_profile_directory "input" "pffexport"); + +IGNORE_LIST=$(read_ignore_list "${TEST_PROFILE_DIRECTORY}"); + +RESULT=${EXIT_SUCCESS}; + +for TEST_SET_INPUT_DIRECTORY in input/*; +do + if ! test -d "${TEST_SET_INPUT_DIRECTORY}"; + then + continue; + fi + if check_for_directory_in_ignore_list "${TEST_SET_INPUT_DIRECTORY}" "${IGNORE_LIST}"; + then + continue; + fi + + TEST_SET_DIRECTORY=$(get_test_set_directory "${TEST_PROFILE_DIRECTORY}" "${TEST_SET_INPUT_DIRECTORY}"); + + OLDIFS=${IFS}; + + # IFS="\n"; is not supported by all platforms. + IFS=" +"; + + if test -f "${TEST_SET_DIRECTORY}/files"; + then + for INPUT_FILE in `cat ${TEST_SET_DIRECTORY}/files | sed "s?^?${TEST_SET_INPUT_DIRECTORY}/?"`; + do + run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "pffexport" "with_callback" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "${INPUT_FILE}"; + RESULT=$?; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi + done + else + for INPUT_FILE in `ls -1 ${TEST_SET_INPUT_DIRECTORY}/${INPUT_GLOB}`; + do + run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "pffexport" "with_callback" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "${INPUT_FILE}"; + RESULT=$?; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi + done + fi + IFS=${OLDIFS}; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi +done exit ${RESULT}; diff --git a/tests/test_pffinfo.ps1 b/tests/test_pffinfo.ps1 index d0901443..083cae0f 100644 --- a/tests/test_pffinfo.ps1 +++ b/tests/test_pffinfo.ps1 @@ -1,6 +1,6 @@ # Info tool testing script # -# Version: 20170911 +# Version: 20180805 $ExitSuccess = 0 $ExitFailure = 1 @@ -16,12 +16,6 @@ Function GetTestToolDirectory { ForEach (${VSConfiguration} in "Release VSDebug" -split " ") { - $TestToolDirectory = "..\${VSDirectory}\${VSConfiguration}" - - If (Test-Path ${TestToolDirectory}) - { - Return ${TestToolDirectory} - } ForEach (${VSPlatform} in "Win32 x64" -split " ") { $TestToolDirectory = "..\${VSDirectory}\${VSConfiguration}\${VSPlatform}" @@ -31,6 +25,12 @@ Function GetTestToolDirectory Return ${TestToolDirectory} } } + $TestToolDirectory = "..\${VSDirectory}\${VSConfiguration}" + + If (Test-Path ${TestToolDirectory}) + { + Return ${TestToolDirectory} + } } } Return ${TestToolDirectory} diff --git a/tests/test_pffinfo.sh b/tests/test_pffinfo.sh index 2402727c..de00be9c 100755 --- a/tests/test_pffinfo.sh +++ b/tests/test_pffinfo.sh @@ -1,7 +1,7 @@ #!/bin/bash # Info tool testing script # -# Version: 20170825 +# Version: 20180721 EXIT_SUCCESS=0; EXIT_FAILURE=1; @@ -47,8 +47,77 @@ fi source ${TEST_RUNNER}; -run_test_on_input_directory "pffinfo" "pffinfo" "with_stdout_reference" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "input" "${INPUT_GLOB}" "${OPTIONS}"; -RESULT=$?; +if ! test -d "input"; +then + echo "Test input directory: input not found."; + + return ${EXIT_IGNORE}; +fi +RESULT=`ls input/* | tr ' ' '\n' | wc -l`; + +if test ${RESULT} -eq ${EXIT_SUCCESS}; +then + echo "No files or directories found in the test input directory: input"; + + return ${EXIT_IGNORE}; +fi + +TEST_PROFILE_DIRECTORY=$(get_test_profile_directory "input" "pffinfo"); + +IGNORE_LIST=$(read_ignore_list "${TEST_PROFILE_DIRECTORY}"); + +RESULT=${EXIT_SUCCESS}; + +for TEST_SET_INPUT_DIRECTORY in input/*; +do + if ! test -d "${TEST_SET_INPUT_DIRECTORY}"; + then + continue; + fi + if check_for_directory_in_ignore_list "${TEST_SET_INPUT_DIRECTORY}" "${IGNORE_LIST}"; + then + continue; + fi + + TEST_SET_DIRECTORY=$(get_test_set_directory "${TEST_PROFILE_DIRECTORY}" "${TEST_SET_INPUT_DIRECTORY}"); + + OLDIFS=${IFS}; + + # IFS="\n"; is not supported by all platforms. + IFS=" +"; + + if test -f "${TEST_SET_DIRECTORY}/files"; + then + for INPUT_FILE in `cat ${TEST_SET_DIRECTORY}/files | sed "s?^?${TEST_SET_INPUT_DIRECTORY}/?"`; + do + run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "pffinfo" "with_stdout_reference" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "${INPUT_FILE}"; + RESULT=$?; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi + done + else + for INPUT_FILE in `ls -1 ${TEST_SET_INPUT_DIRECTORY}/${INPUT_GLOB}`; + do + run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "pffinfo" "with_stdout_reference" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "${INPUT_FILE}"; + RESULT=$?; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi + done + fi + IFS=${OLDIFS}; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi +done exit ${RESULT}; diff --git a/tests/test_python_module.sh b/tests/test_python_module.sh index a6e90973..f51f2f6a 100755 --- a/tests/test_python_module.sh +++ b/tests/test_python_module.sh @@ -1,7 +1,7 @@ #!/bin/bash # Tests Python module functions and types. # -# Version: 20170722 +# Version: 20180728 EXIT_SUCCESS=0; EXIT_FAILURE=1; @@ -34,8 +34,77 @@ test_python_function_with_input() local TEST_DESCRIPTION="Testing Python-bindings functions: ${TEST_FUNCTION}"; local TEST_SCRIPT="${TEST_TOOL_DIRECTORY}/pypff_test_${TEST_FUNCTION}.py"; - run_test_on_input_directory "pypff" "${TEST_DESCRIPTION}" "default" "${OPTION_SETS}" "${TEST_SCRIPT}" "input" "${INPUT_GLOB}"; - local RESULT=$?; + if ! test -d "input"; + then + echo "Test input directory: input not found."; + + return ${EXIT_IGNORE}; + fi + local RESULT=`ls input/* | tr ' ' '\n' | wc -l`; + + if test ${RESULT} -eq ${EXIT_SUCCESS}; + then + echo "No files or directories found in the test input directory: input"; + + return ${EXIT_IGNORE}; + fi + + local TEST_PROFILE_DIRECTORY=$(get_test_profile_directory "input" "pypff"); + + local IGNORE_LIST=$(read_ignore_list "${TEST_PROFILE_DIRECTORY}"); + + RESULT=${EXIT_SUCCESS}; + + for TEST_SET_INPUT_DIRECTORY in input/*; + do + if ! test -d "${TEST_SET_INPUT_DIRECTORY}"; + then + continue; + fi + if check_for_directory_in_ignore_list "${TEST_SET_INPUT_DIRECTORY}" "${IGNORE_LIST}"; + then + continue; + fi + + local TEST_SET_DIRECTORY=$(get_test_set_directory "${TEST_PROFILE_DIRECTORY}" "${TEST_SET_INPUT_DIRECTORY}"); + + local OLDIFS=${IFS}; + + # IFS="\n"; is not supported by all platforms. + IFS=" +"; + + if test -f "${TEST_SET_DIRECTORY}/files"; + then + for INPUT_FILE in `cat ${TEST_SET_DIRECTORY}/files | sed "s?^?${TEST_SET_INPUT_DIRECTORY}/?"`; + do + run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "${TEST_DESCRIPTION}" "default" "${OPTION_SETS}" "${TEST_SCRIPT}" "${INPUT_FILE}"; + RESULT=$?; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi + done + else + for INPUT_FILE in `ls -1 ${TEST_SET_INPUT_DIRECTORY}/${INPUT_GLOB}`; + do + run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "${TEST_DESCRIPTION}" "default" "${OPTION_SETS}" "${TEST_SCRIPT}" "${INPUT_FILE}"; + RESULT=$?; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi + done + fi + IFS=${OLDIFS}; + + if test ${RESULT} -ne ${EXIT_SUCCESS}; + then + break; + fi + done return ${RESULT}; } @@ -81,8 +150,14 @@ fi for TEST_FUNCTION in ${TEST_FUNCTIONS_WITH_INPUT}; do - test_python_function_with_input "${TEST_FUNCTION}"; - RESULT=$?; + if test -d "input"; + then + test_python_function_with_input "${TEST_FUNCTION}"; + RESULT=$?; + else + test_python_function "${TEST_FUNCTION}"; + RESULT=$?; + fi if test ${RESULT} -ne ${EXIT_SUCCESS}; then diff --git a/tests/test_runner.sh b/tests/test_runner.sh index b9f7d61f..e6eb880d 100644 --- a/tests/test_runner.sh +++ b/tests/test_runner.sh @@ -1,7 +1,7 @@ #!/bin/bash # Bash functions to run an executable for testing. # -# Version: 20170827 +# Version: 20180727 # # When CHECK_WITH_ASAN is set to a non-empty value the test executable # is run with asan, otherwise it is run without. @@ -82,7 +82,7 @@ assert_availability_binaries() check_for_directory_in_ignore_list() { local INPUT_DIRECTORY=$1; - local IGNORE_LIST=$@; + local IGNORE_LIST=$2; local INPUT_BASENAME=`basename ${INPUT_DIRECTORY}`; @@ -388,7 +388,7 @@ run_test_with_arguments() local TEST_DESCRIPTION=$1; local TEST_EXECUTABLE=$2; shift 2; - local ARGUMENTS=$@; + local ARGUMENTS=("$@"); if ! test -f "${TEST_EXECUTABLE}"; then @@ -468,7 +468,7 @@ run_test_with_arguments() exit ${EXIT_FAILURE}; fi - LIBASAN=`${LDCONFIG} -p | grep libasan | sed 's/^.* => //'`; + LIBASAN=`${LDCONFIG} -p | grep libasan | sed 's/^.* => //' | sort | tail -n 1`; if ! test -f ${LIBASAN}; then @@ -708,7 +708,7 @@ run_test_with_input_and_arguments() local TEST_EXECUTABLE=$1; local INPUT_FILE=$2; shift 2; - local ARGUMENTS=$@; + local ARGUMENTS=("$@"); if ! test -f "${TEST_EXECUTABLE}"; then @@ -789,7 +789,7 @@ run_test_with_input_and_arguments() exit ${EXIT_FAILURE}; fi - LIBASAN=`${LDCONFIG} -p | grep libasan | sed 's/^.* => //'`; + LIBASAN=`${LDCONFIG} -p | grep libasan | sed 's/^.* => //' | sort | tail -n 1`; if ! test -f ${LIBASAN}; then @@ -1022,7 +1022,7 @@ run_test_on_input_file() local TEST_EXECUTABLE=$5; local INPUT_FILE=$6; shift 6; - local ARGUMENTS=$@; + local ARGUMENTS=("$@"); local INPUT_NAME=`basename "${INPUT_FILE}"`; local OPTIONS=(); @@ -1044,7 +1044,7 @@ run_test_on_input_file() if test "${TEST_MODE}" = "with_callback"; then - test_callback "${TMPDIR}" "${TEST_SET_DIRECTORY}" "${TEST_OUTPUT}" "${TEST_EXECUTABLE}" "${TEST_INPUT}" ${ARGUMENTS[@]} ${OPTIONS[@]}; + test_callback "${TMPDIR}" "${TEST_SET_DIRECTORY}" "${TEST_OUTPUT}" "${TEST_EXECUTABLE}" "${TEST_INPUT}" ${ARGUMENTS[@]} "${OPTIONS[@]}"; RESULT=$?; elif test "${TEST_MODE}" = "with_stdout_reference"; @@ -1061,7 +1061,7 @@ run_test_on_input_file() local INPUT_FILE_FULL_PATH=$( readlink_f "${INPUT_FILE}" ); local TEST_LOG="${TEST_OUTPUT}.log"; - (cd ${TMPDIR} && run_test_with_input_and_arguments "${TEST_EXECUTABLE}" "${INPUT_FILE_FULL_PATH}" ${ARGUMENTS[@]} ${OPTIONS[@]} | sed '1,2d' > "${TEST_LOG}"); + (cd ${TMPDIR} && run_test_with_input_and_arguments "${TEST_EXECUTABLE}" "${INPUT_FILE_FULL_PATH}" ${ARGUMENTS[@]} "${OPTIONS[@]}" | sed '1,2d' > "${TEST_LOG}"); RESULT=$?; local TEST_RESULTS="${TMPDIR}/${TEST_LOG}"; @@ -1080,7 +1080,7 @@ run_test_on_input_file() fi else - run_test_with_input_and_arguments "${TEST_EXECUTABLE}" "${INPUT_FILE}" ${ARGUMENTS[@]} ${OPTIONS[@]}; + run_test_with_input_and_arguments "${TEST_EXECUTABLE}" "${INPUT_FILE}" ${ARGUMENTS[@]} "${OPTIONS[@]}"; RESULT=$?; fi @@ -1131,7 +1131,7 @@ run_test_on_input_file_with_options() local TEST_EXECUTABLE=$5; local INPUT_FILE=$6; shift 6; - local ARGUMENTS=$@; + local ARGUMENTS=("$@"); local RESULT=${EXIT_SUCCESS}; local TESTED_WITH_OPTIONS=0; @@ -1163,122 +1163,3 @@ run_test_on_input_file_with_options() return ${RESULT}; } -# Runs the test on the input directory. -# -# Arguments: -# a string containing the name of the test profile -# a string containing the description of the test -# a string containing the test mode, supported tests modes are: -# default: the test executable should be be run without any test -# conditions. -# with_callback: the test executable should be run and the callback -# function should be called afterwards. The name of the -# callback function is "test_callback". -# with_stdout_reference: the test executable should be run and its output -# to stdout, except for the first 2 lines, should -# be compared to a reference file, if available. -# Note the globals override the test mode. -# a string containing the name of the option sets -# a string containing the path of the test executable -# a string containing the path of the test input directory -# a string containing the input glob -# an array containing the arguments for the test executable -# -# Returns: -# an integer containg the exit status of the test executable -# -run_test_on_input_directory() -{ - local TEST_PROFILE=$1; - local TEST_DESCRIPTION=$2; - local TEST_MODE=$3; - local OPTION_SETS=$4; - local TEST_EXECUTABLE=$5; - local TEST_INPUT_DIRECTORY=$6; - local INPUT_GLOB=$7; - shift 7; - local ARGUMENTS=$@; - - assert_availability_binaries; - - if ! test "${TEST_MODE}" = "default" && test "${TEST_MODE}" != "with_callback" && ! test "${TEST_MODE}" = "with_stdout_reference"; - then - echo "Unsupported test mode: ${TEST_MODE}"; - echo ""; - - return ${EXIT_FAILURE}; - fi - - if ! test -f "${TEST_EXECUTABLE}"; - then - echo "Missing test executable: ${TEST_EXECUTABLE}"; - echo ""; - - return ${EXIT_FAILURE}; - fi - - if ! test -d "${TEST_INPUT_DIRECTORY}"; - then - echo "Test input directory: ${TEST_INPUT_DIRECTORY} not found."; - - return ${EXIT_IGNORE}; - fi - local RESULT=`ls ${TEST_INPUT_DIRECTORY}/* | tr ' ' '\n' | wc -l`; - - if test ${RESULT} -eq ${EXIT_SUCCESS}; - then - echo "No files or directories found in the test input directory: ${TEST_INPUT_DIRECTORY}"; - - return ${EXIT_IGNORE}; - fi - - local TEST_PROFILE_DIRECTORY=$(get_test_profile_directory "${TEST_INPUT_DIRECTORY}" "${TEST_PROFILE}"); - - local IGNORE_LIST=$(read_ignore_list "${TEST_PROFILE_DIRECTORY}"); - - RESULT=${EXIT_SUCCESS}; - - for TEST_SET_INPUT_DIRECTORY in ${TEST_INPUT_DIRECTORY}/*; - do - if ! test -d "${TEST_SET_INPUT_DIRECTORY}"; - then - continue; - fi - if check_for_directory_in_ignore_list "${TEST_SET_INPUT_DIRECTORY}" "${IGNORE_LIST}"; - then - continue; - fi - - local TEST_SET_DIRECTORY=$(get_test_set_directory "${TEST_PROFILE_DIRECTORY}" "${TEST_SET_INPUT_DIRECTORY}"); - - local INPUT_FILES=""; - if test -f "${TEST_SET_DIRECTORY}/files"; - then - while read -r INPUT_FILE; - do - run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "${TEST_DESCRIPTION}" "${TEST_MODE}" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "${INPUT_FILE}" ${ARGUMENTS[@]}; - RESULT=$?; - - if test ${RESULT} -ne ${EXIT_SUCCESS}; - then - return ${RESULT}; - fi - done < <(cat ${TEST_SET_DIRECTORY}/files | sed "s?^?${TEST_SET_INPUT_DIRECTORY}/?"); - else - while read -r INPUT_FILE; - do - run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "${TEST_DESCRIPTION}" "${TEST_MODE}" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "${INPUT_FILE}" ${ARGUMENTS[@]}; - RESULT=$?; - - if test ${RESULT} -ne ${EXIT_SUCCESS}; - then - return ${RESULT}; - fi - done < <(ls -1 ${TEST_SET_INPUT_DIRECTORY}/${INPUT_GLOB}); - fi - - done - - return ${RESULT}; -} -