Browse Source

Applied updates

pull/69/head
Joachim Metz 2 years ago
parent
commit
fecb691267
No known key found for this signature in database GPG Key ID: D9625E5D7AD0177E
35 changed files with 1116 additions and 340 deletions
  1. +203
    -19
      .travis.yml
  2. +1
    -1
      appveyor.yml
  3. +150
    -0
      build.ps1
  4. +13
    -1
      common/types.h.in
  5. +6
    -13
      configure.ac
  6. +1
    -1
      libpff.ini
  7. +2
    -1
      libpff/Makefile.am
  8. +0
    -7
      libpff/libpff_extern.h
  9. +6
    -2
      m4/common.m4
  10. +11
    -11
      m4/libcpath.m4
  11. +2
    -2
      m4/libfcache.m4
  12. +2
    -2
      m4/libuna.m4
  13. +56
    -50
      m4/python.m4
  14. +2
    -2
      m4/tests.m4
  15. +10
    -9
      m4/types.m4
  16. +0
    -7
      pfftools/pfftools_libpff.h
  17. +2
    -1
      pypff-python2/Makefile.am
  18. +2
    -1
      pypff-python3/Makefile.am
  19. +2
    -1
      pypff/Makefile.am
  20. +1
    -8
      pypff/pypff_libpff.h
  21. +29
    -7
      runtests.sh
  22. +14
    -20
      setup.py
  23. +3
    -2
      synclibs.sh
  24. +2
    -2
      syncsharedlibs.sh
  25. +0
    -1
      tests/pff_test_functions.c
  26. +131
    -1
      tests/pff_test_io_handle.c
  27. +0
    -7
      tests/pff_test_libpff.h
  28. +28
    -0
      tests/pff_test_macros.h
  29. +123
    -10
      tests/test_library.ps1
  30. +72
    -3
      tests/test_library.sh
  31. +72
    -3
      tests/test_pffexport.sh
  32. +7
    -7
      tests/test_pffinfo.ps1
  33. +72
    -3
      tests/test_pffinfo.sh
  34. +80
    -5
      tests/test_python_module.sh
  35. +11
    -130
      tests/test_runner.sh

+ 203
- 19
.travis.yml View File

@@ -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

+ 1
- 1
appveyor.yml View File

@@ -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" )


+ 150
- 0
build.ps1 View File

@@ -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}

+ 13
- 1
common/types.h.in View File

@@ -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 )


+ 6
- 13
configure.ac View File

@@ -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
]);


+ 1
- 1
libpff.ini View File

@@ -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="


+ 2
- 1
libpff/Makefile.am View File

@@ -18,7 +18,8 @@ AM_CPPFLAGS = \
@LIBFWNT_CPPFLAGS@ \
@LIBFMAPI_CPPFLAGS@ \
@ZLIB_CPPFLAGS@ \
@PTHREAD_CPPFLAGS@
@PTHREAD_CPPFLAGS@ \
@LIBPFF_DLL_EXPORT@

lib_LTLIBRARIES = libpff.la



+ 0
- 7
libpff/libpff_extern.h View File

@@ -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 <libpff/extern.h>

#define LIBPFF_EXTERN_VARIABLE LIBPFF_EXTERN


+ 6
- 2
m4/common.m4 View File

@@ -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


+ 11
- 11
m4/libcpath.m4 View File

@@ -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<library> 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])
])


+ 2
- 2
m4/libfcache.m4 View File

@@ -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<library> arguments


+ 2
- 2
m4/libuna.m4 View File

@@ -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<library> 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])
])


+ 56
- 50
m4/python.m4 View File

@@ -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}"])
])
])
])
])


+ 2
- 2
m4/tests.m4 View File

@@ -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,


+ 10
- 9
m4/types.m4 View File

@@ -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])])


+ 0
- 7
pfftools/pfftools_libpff.h View File

@@ -24,13 +24,6 @@

#include <common.h>

/* 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 <libpff.h>

#endif /* !defined( _PFFTOOLS_LIBPFF_H ) */


+ 2
- 1
pypff-python2/Makefile.am View File

@@ -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)



+ 2
- 1
pypff-python3/Makefile.am View File

@@ -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)



+ 2
- 1
pypff/Makefile.am View File

@@ -8,7 +8,8 @@ AM_CFLAGS = \
@LIBUNA_CPPFLAGS@ \
@LIBCFILE_CPPFLAGS@ \
@LIBCPATH_CPPFLAGS@ \
@LIBBFIO_CPPFLAGS@
@LIBBFIO_CPPFLAGS@ \
@LIBPFF_DLL_IMPORT@

pyexec_LTLIBRARIES = pypff.la



+ 1
- 8
pypff/pypff_libpff.h View File

@@ -24,14 +24,7 @@

#include <common.h>

/* 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 <libpff.h>

#endif
#endif /* !defined( _PYPFF_LIBPFF_H ) */


+ 29
- 7
runtests.sh View File

@@ -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=$?;


+ 14
- 20
setup.py View File

@@ -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 @@ class custom_build_ext(build_ext):
"""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 @@ class custom_build_ext(build_ext):

# 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 = [


+ 3
- 2
synclibs.sh View File

@@ -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};



+ 2
- 2
syncsharedlibs.sh View File

@@ -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.";



+ 0
- 1
tests/pff_test_functions.c View File

@@ -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 )


+ 131
- 1
tests/pff_test_io_handle.c View File

@@ -270,6 +270,134 @@ on_error:
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 */



+ 0
- 7
tests/pff_test_libpff.h View File

@@ -24,13 +24,6 @@

#include <common.h>

/* 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 <libpff.h>

#endif /* !defined( _PFF_TEST_LIBPFF_H ) */


+ 28
- 0
tests/pff_test_macros.h View File

@@ -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 ) \
{ \


+ 123
- 10
tests/test_library.ps1 View File

@@ -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


+ 72
- 3
tests/test_library.sh View File

@@ -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};
}


+ 72
- 3
tests/test_pffexport.sh View File

@@ -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};


+ 7
- 7
tests/test_pffinfo.ps1 View File

@@ -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}


+ 72
- 3
tests/test_pffinfo.sh View File

@@ -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};


+ 80
- 5
tests/test_python_module.sh View File

@@ -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