diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b0fb9c0..a876b31 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -71,7 +71,9 @@ jobs:
- uses: actions/checkout@v2
- name: Install build dependencies
run: |
- sudo apt-get -y install autoconf automake autopoint build-essential git libfuse-dev libssl-dev libtool pkg-config zlib1g-dev python-dev python3-dev
+ sudo add-apt-repository universe &&
+ sudo apt-get update &&
+ sudo apt-get -y install autoconf automake autopoint build-essential git libfuse-dev libssl-dev libtool pkg-config zlib1g-dev python2-dev python3-dev python-dev-is-python3
- name: Download test data
run: |
if test -x "synctestdata.sh"; then ./synctestdata.sh; fi
@@ -106,7 +108,9 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install build dependencies
run: |
- sudo apt-get -y install autoconf automake autopoint build-essential git libfuse-dev libssl-dev libtool pkg-config zlib1g-dev python-dev python3-dev
+ sudo add-apt-repository universe &&
+ sudo apt-get update &&
+ sudo apt-get -y install autoconf automake autopoint build-essential git libfuse-dev libssl-dev libtool pkg-config zlib1g-dev python2-dev python3-dev python-dev-is-python3
- name: Building from source
env:
CC: ${{ matrix.compiler }}
diff --git a/.gitignore b/.gitignore
index 31339f0..7c13cce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -177,6 +177,9 @@ stamp-h[1-9]
/tests/fsapfs_test_snapshot_metadata_tree
/tests/fsapfs_test_space_manager
/tests/fsapfs_test_support
+/tests/fsapfs_test_tools_info_handle
+/tests/fsapfs_test_tools_output
+/tests/fsapfs_test_tools_signal
/tests/fsapfs_test_volume
/tests/fsapfs_test_volume_key_bag
/tests/fsapfs_test_volume_superblock
diff --git a/configure.ac b/configure.ac
index 7b28cfa..172af7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_PREREQ( 2.59 )
AC_INIT(
[libfsapfs],
- [20210106],
+ [20210313],
[joachim.metz@gmail.com])
AC_CONFIG_SRCDIR(
diff --git a/msvscpp/Makefile.am b/msvscpp/Makefile.am
index 3c19d0d..8fc1739 100644
--- a/msvscpp/Makefile.am
+++ b/msvscpp/Makefile.am
@@ -47,6 +47,9 @@ MSVSCPP_FILES = \
fsapfs_test_snapshot_metadata_tree/fsapfs_test_snapshot_metadata_tree.vcproj \
fsapfs_test_space_manager/fsapfs_test_space_manager.vcproj \
fsapfs_test_support/fsapfs_test_support.vcproj \
+ fsapfs_test_tools_info_handle/fsapfs_test_tools_info_handle.vcproj \
+ fsapfs_test_tools_output/fsapfs_test_tools_output.vcproj \
+ fsapfs_test_tools_signal/fsapfs_test_tools_signal.vcproj \
fsapfs_test_volume/fsapfs_test_volume.vcproj \
fsapfs_test_volume_key_bag/fsapfs_test_volume_key_bag.vcproj \
fsapfs_test_volume_superblock/fsapfs_test_volume_superblock.vcproj \
diff --git a/msvscpp/fsapfs_test_tools_info_handle/fsapfs_test_tools_info_handle.vcproj b/msvscpp/fsapfs_test_tools_info_handle/fsapfs_test_tools_info_handle.vcproj
new file mode 100644
index 0000000..64c2252
--- /dev/null
+++ b/msvscpp/fsapfs_test_tools_info_handle/fsapfs_test_tools_info_handle.vcproj
@@ -0,0 +1,234 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/msvscpp/fsapfs_test_tools_output/fsapfs_test_tools_output.vcproj b/msvscpp/fsapfs_test_tools_output/fsapfs_test_tools_output.vcproj
new file mode 100644
index 0000000..cd32cd4
--- /dev/null
+++ b/msvscpp/fsapfs_test_tools_output/fsapfs_test_tools_output.vcproj
@@ -0,0 +1,218 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/msvscpp/fsapfs_test_tools_signal/fsapfs_test_tools_signal.vcproj b/msvscpp/fsapfs_test_tools_signal/fsapfs_test_tools_signal.vcproj
new file mode 100644
index 0000000..a52911a
--- /dev/null
+++ b/msvscpp/fsapfs_test_tools_signal/fsapfs_test_tools_signal.vcproj
@@ -0,0 +1,218 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/msvscpp/libfsapfs.sln b/msvscpp/libfsapfs.sln
index 5ccb30b..9f4f91e 100644
--- a/msvscpp/libfsapfs.sln
+++ b/msvscpp/libfsapfs.sln
@@ -420,6 +420,35 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fsapfs_test_support", "fsap
{F480F61D-4950-4603-9F6F-F95ECC64A31C} = {F480F61D-4950-4603-9F6F-F95ECC64A31C}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fsapfs_test_tools_info_handle", "fsapfs_test_tools_info_handle\fsapfs_test_tools_info_handle.vcproj", "{81A45752-6E7A-4069-8D5D-9E56F60BA93C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {15FA188C-ED14-4CE9-B61C-02EBA70A76C9} = {15FA188C-ED14-4CE9-B61C-02EBA70A76C9}
+ {17B4F915-722A-4F8D-AD95-4D1ADD82F3D1} = {17B4F915-722A-4F8D-AD95-4D1ADD82F3D1}
+ {9BA406EC-23C0-4A43-A97B-ACDA0D131DB4} = {9BA406EC-23C0-4A43-A97B-ACDA0D131DB4}
+ {ABB04F9A-768A-4F12-9751-65A0E2F81229} = {ABB04F9A-768A-4F12-9751-65A0E2F81229}
+ {D9CF8B05-7395-4338-BAC5-124E72335F21} = {D9CF8B05-7395-4338-BAC5-124E72335F21}
+ {ABF4D2D6-8EFB-4A8E-815C-C831C9CA3EF2} = {ABF4D2D6-8EFB-4A8E-815C-C831C9CA3EF2}
+ {75064AFE-F331-40B7-AB9C-F0040C889610} = {75064AFE-F331-40B7-AB9C-F0040C889610}
+ {4B0DA96F-94B6-4904-9701-3A9371E8914E} = {4B0DA96F-94B6-4904-9701-3A9371E8914E}
+ {8AA44886-07A3-430D-90E0-F622A051A571} = {8AA44886-07A3-430D-90E0-F622A051A571}
+ {670BD730-824A-4304-81D7-DF5B5AE5340C} = {670BD730-824A-4304-81D7-DF5B5AE5340C}
+ {3EAA2B38-404A-4EE2-B675-8E39E41CEBAA} = {3EAA2B38-404A-4EE2-B675-8E39E41CEBAA}
+ {66956CAB-8580-4D29-AFA4-49E9934D9E42} = {66956CAB-8580-4D29-AFA4-49E9934D9E42}
+ {F480F61D-4950-4603-9F6F-F95ECC64A31C} = {F480F61D-4950-4603-9F6F-F95ECC64A31C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fsapfs_test_tools_output", "fsapfs_test_tools_output\fsapfs_test_tools_output.vcproj", "{7BFDB415-A65D-46ED-8D16-434B9615BEE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ {66956CAB-8580-4D29-AFA4-49E9934D9E42} = {66956CAB-8580-4D29-AFA4-49E9934D9E42}
+ {F480F61D-4950-4603-9F6F-F95ECC64A31C} = {F480F61D-4950-4603-9F6F-F95ECC64A31C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fsapfs_test_tools_signal", "fsapfs_test_tools_signal\fsapfs_test_tools_signal.vcproj", "{1D827BFD-84AE-43BB-B0E0-DBD163D2798E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {66956CAB-8580-4D29-AFA4-49E9934D9E42} = {66956CAB-8580-4D29-AFA4-49E9934D9E42}
+ {F480F61D-4950-4603-9F6F-F95ECC64A31C} = {F480F61D-4950-4603-9F6F-F95ECC64A31C}
+ EndProjectSection
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fsapfs_test_volume", "fsapfs_test_volume\fsapfs_test_volume.vcproj", "{13978574-75C7-4EFC-9440-F9FBC38DD907}"
ProjectSection(ProjectDependencies) = postProject
{ABB04F9A-768A-4F12-9751-65A0E2F81229} = {ABB04F9A-768A-4F12-9751-65A0E2F81229}
@@ -823,6 +852,18 @@ Global
{D69E0261-FD4E-4E82-BC60-67E67C9DD8F7}.Release|Win32.Build.0 = Release|Win32
{D69E0261-FD4E-4E82-BC60-67E67C9DD8F7}.VSDebug|Win32.ActiveCfg = VSDebug|Win32
{D69E0261-FD4E-4E82-BC60-67E67C9DD8F7}.VSDebug|Win32.Build.0 = VSDebug|Win32
+ {81A45752-6E7A-4069-8D5D-9E56F60BA93C}.Release|Win32.ActiveCfg = Release|Win32
+ {81A45752-6E7A-4069-8D5D-9E56F60BA93C}.Release|Win32.Build.0 = Release|Win32
+ {81A45752-6E7A-4069-8D5D-9E56F60BA93C}.VSDebug|Win32.ActiveCfg = VSDebug|Win32
+ {81A45752-6E7A-4069-8D5D-9E56F60BA93C}.VSDebug|Win32.Build.0 = VSDebug|Win32
+ {7BFDB415-A65D-46ED-8D16-434B9615BEE6}.Release|Win32.ActiveCfg = Release|Win32
+ {7BFDB415-A65D-46ED-8D16-434B9615BEE6}.Release|Win32.Build.0 = Release|Win32
+ {7BFDB415-A65D-46ED-8D16-434B9615BEE6}.VSDebug|Win32.ActiveCfg = VSDebug|Win32
+ {7BFDB415-A65D-46ED-8D16-434B9615BEE6}.VSDebug|Win32.Build.0 = VSDebug|Win32
+ {1D827BFD-84AE-43BB-B0E0-DBD163D2798E}.Release|Win32.ActiveCfg = Release|Win32
+ {1D827BFD-84AE-43BB-B0E0-DBD163D2798E}.Release|Win32.Build.0 = Release|Win32
+ {1D827BFD-84AE-43BB-B0E0-DBD163D2798E}.VSDebug|Win32.ActiveCfg = VSDebug|Win32
+ {1D827BFD-84AE-43BB-B0E0-DBD163D2798E}.VSDebug|Win32.Build.0 = VSDebug|Win32
{13978574-75C7-4EFC-9440-F9FBC38DD907}.Release|Win32.ActiveCfg = Release|Win32
{13978574-75C7-4EFC-9440-F9FBC38DD907}.Release|Win32.Build.0 = Release|Win32
{13978574-75C7-4EFC-9440-F9FBC38DD907}.VSDebug|Win32.ActiveCfg = VSDebug|Win32
diff --git a/synctestdata.sh b/synctestdata.sh
index 104ac55..521bcfc 100755
--- a/synctestdata.sh
+++ b/synctestdata.sh
@@ -11,7 +11,7 @@ mkdir -p "${TEST_INPUT_DIRECTORY}/${TEST_SET}";
for TEST_FILE in ${TEST_FILES};
do
- URL="https://github.com/log2timeline/dfvfs/blob/master/test_data/${TEST_FILE}?raw=true";
+ URL="https://github.com/log2timeline/dfvfs/blob/main/test_data/${TEST_FILE}?raw=true";
curl -L -o "${TEST_INPUT_DIRECTORY}/${TEST_SET}/${TEST_FILE}" ${URL};
done
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dc070c6..17f24e6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,5 @@
+AUTOMAKE_OPTIONS = subdir-objects
+
AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/common \
@@ -29,12 +31,14 @@ endif
TESTS = \
test_library.sh \
+ test_tools.sh \
test_fsapfsinfo.sh \
test_fsapfsinfo_bodyfile.sh \
$(TESTS_PYFSAPFS)
check_SCRIPTS = \
pyfsapfs_test_support.py \
+ test_tools.sh \
test_fsapfsinfo.sh \
test_fsapfsinfo_bodyfile.sh \
test_library.sh \
@@ -94,6 +98,9 @@ check_PROGRAMS = \
fsapfs_test_snapshot_metadata_tree \
fsapfs_test_space_manager \
fsapfs_test_support \
+ fsapfs_test_tools_info_handle \
+ fsapfs_test_tools_output \
+ fsapfs_test_tools_signal \
fsapfs_test_volume \
fsapfs_test_volume_key_bag \
fsapfs_test_volume_superblock
@@ -833,6 +840,54 @@ fsapfs_test_support_LDADD = \
../libfsapfs/libfsapfs.la \
@LIBCERROR_LIBADD@
+fsapfs_test_tools_info_handle_SOURCES = \
+ ../fsapfstools/digest_hash.c ../fsapfstools/digest_hash.h \
+ ../fsapfstools/info_handle.c ../fsapfstools/info_handle.h \
+ fsapfs_test_libcerror.h \
+ fsapfs_test_macros.h \
+ fsapfs_test_memory.c fsapfs_test_memory.h \
+ fsapfs_test_tools_info_handle.c \
+ fsapfs_test_unused.h
+
+fsapfs_test_tools_info_handle_LDADD = \
+ @LIBHMAC_LIBADD@ \
+ @LIBFGUID_LIBADD@ \
+ @LIBFDATETIME_LIBADD@ \
+ @LIBBFIO_LIBADD@ \
+ @LIBCPATH_LIBADD@ \
+ @LIBCFILE_LIBADD@ \
+ @LIBUNA_LIBADD@ \
+ @LIBCSPLIT_LIBADD@ \
+ @LIBCNOTIFY_LIBADD@ \
+ @LIBCLOCALE_LIBADD@ \
+ @LIBCDATA_LIBADD@ \
+ ../libfsapfs/libfsapfs.la \
+ @LIBCERROR_LIBADD@ \
+ @LIBCRYPTO_LIBADD@ \
+ @LIBDL_LIBADD@
+
+fsapfs_test_tools_output_SOURCES = \
+ ../fsapfstools/fsapfstools_output.c ../fsapfstools/fsapfstools_output.h \
+ fsapfs_test_libcerror.h \
+ fsapfs_test_macros.h \
+ fsapfs_test_tools_output.c \
+ fsapfs_test_unused.h
+
+fsapfs_test_tools_output_LDADD = \
+ ../libfsapfs/libfsapfs.la \
+ @LIBCERROR_LIBADD@
+
+fsapfs_test_tools_signal_SOURCES = \
+ ../fsapfstools/fsapfstools_signal.c ../fsapfstools/fsapfstools_signal.h \
+ fsapfs_test_libcerror.h \
+ fsapfs_test_macros.h \
+ fsapfs_test_tools_signal.c \
+ fsapfs_test_unused.h
+
+fsapfs_test_tools_signal_LDADD = \
+ ../libfsapfs/libfsapfs.la \
+ @LIBCERROR_LIBADD@
+
fsapfs_test_volume_SOURCES = \
fsapfs_test_functions.c fsapfs_test_functions.h \
fsapfs_test_getopt.c fsapfs_test_getopt.h \
diff --git a/tests/fsapfs_test_deflate.c b/tests/fsapfs_test_deflate.c
index cbcc8c3..8e1fcc3 100644
--- a/tests/fsapfs_test_deflate.c
+++ b/tests/fsapfs_test_deflate.c
@@ -2702,7 +2702,11 @@ int main(
return( EXIT_SUCCESS );
+#if defined( __GNUC__ ) && !defined( LIBFSAPFS_DLL_IMPORT )
+
on_error:
return( EXIT_FAILURE );
+
+#endif /* defined( __GNUC__ ) && !defined( LIBFSAPFS_DLL_IMPORT ) */
}
diff --git a/tests/fsapfs_test_memory.h b/tests/fsapfs_test_memory.h
index 1b5e052..bdad5ae 100644
--- a/tests/fsapfs_test_memory.h
+++ b/tests/fsapfs_test_memory.h
@@ -28,7 +28,7 @@
extern "C" {
#endif
-#if defined( HAVE_GNU_DL_DLSYM ) && defined( __GNUC__ ) && !defined( LIBFSAPFS_DLL_IMPORT ) && !defined( __arm__ ) && !defined( __clang__ ) && !defined( __CYGWIN__ ) && !defined( __hppa__ ) && !defined( __mips__ ) && !defined( __sparc__ ) && !defined( HAVE_ASAN )
+#if defined( HAVE_GNU_DL_DLSYM ) && defined( __GNUC__ ) && !defined( LIBFSAPFS_DLL_IMPORT ) && !defined( __arm__ ) && !defined( __clang__ ) && !defined( __CYGWIN__ ) && !defined( __hppa__ ) && !defined( __mips__ ) && !defined( __riscv ) && !defined( __sparc__ ) && !defined( HAVE_ASAN )
#define HAVE_FSAPFS_TEST_MEMORY 1
#endif
diff --git a/tests/fsapfs_test_tools_info_handle.c b/tests/fsapfs_test_tools_info_handle.c
new file mode 100644
index 0000000..ddcab17
--- /dev/null
+++ b/tests/fsapfs_test_tools_info_handle.c
@@ -0,0 +1,304 @@
+/*
+ * Tools info_handle type test program
+ *
+ * Copyright (C) 2018-2021, Joachim Metz
+ *
+ * Refer to AUTHORS for acknowledgements.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include
+#include
+#include
+
+#if defined( HAVE_STDLIB_H ) || defined( WINAPI )
+#include
+#endif
+
+#include "fsapfs_test_libcerror.h"
+#include "fsapfs_test_macros.h"
+#include "fsapfs_test_memory.h"
+#include "fsapfs_test_unused.h"
+
+#include "../fsapfstools/info_handle.h"
+
+/* Tests the info_handle_initialize function
+ * Returns 1 if successful or 0 if not
+ */
+int fsapfs_test_tools_info_handle_initialize(
+ void )
+{
+ info_handle_t *info_handle = NULL;
+ libcerror_error_t *error = NULL;
+ int result = 0;
+
+#if defined( HAVE_FSAPFS_TEST_MEMORY )
+ int number_of_malloc_fail_tests = 1;
+ int number_of_memset_fail_tests = 1;
+ int test_number = 0;
+#endif
+
+ /* Test regular cases
+ */
+ result = info_handle_initialize(
+ &info_handle,
+ 0,
+ &error );
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ 1 );
+
+ FSAPFS_TEST_ASSERT_IS_NOT_NULL(
+ "info_handle",
+ info_handle );
+
+ FSAPFS_TEST_ASSERT_IS_NULL(
+ "error",
+ error );
+
+ result = info_handle_free(
+ &info_handle,
+ &error );
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ 1 );
+
+ FSAPFS_TEST_ASSERT_IS_NULL(
+ "info_handle",
+ info_handle );
+
+ FSAPFS_TEST_ASSERT_IS_NULL(
+ "error",
+ error );
+
+ /* Test error cases
+ */
+ result = info_handle_initialize(
+ NULL,
+ 0,
+ &error );
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ -1 );
+
+ FSAPFS_TEST_ASSERT_IS_NOT_NULL(
+ "error",
+ error );
+
+ libcerror_error_free(
+ &error );
+
+ info_handle = (info_handle_t *) 0x12345678UL;
+
+ result = info_handle_initialize(
+ &info_handle,
+ 0,
+ &error );
+
+ info_handle = NULL;
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ -1 );
+
+ FSAPFS_TEST_ASSERT_IS_NOT_NULL(
+ "error",
+ error );
+
+ libcerror_error_free(
+ &error );
+
+#if defined( HAVE_FSAPFS_TEST_MEMORY )
+
+ for( test_number = 0;
+ test_number < number_of_malloc_fail_tests;
+ test_number++ )
+ {
+ /* Test info_handle_initialize with malloc failing
+ */
+ fsapfs_test_malloc_attempts_before_fail = test_number;
+
+ result = info_handle_initialize(
+ &info_handle,
+ 0,
+ &error );
+
+ if( fsapfs_test_malloc_attempts_before_fail != -1 )
+ {
+ fsapfs_test_malloc_attempts_before_fail = -1;
+
+ if( info_handle != NULL )
+ {
+ info_handle_free(
+ &info_handle,
+ NULL );
+ }
+ }
+ else
+ {
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ -1 );
+
+ FSAPFS_TEST_ASSERT_IS_NULL(
+ "info_handle",
+ info_handle );
+
+ FSAPFS_TEST_ASSERT_IS_NOT_NULL(
+ "error",
+ error );
+
+ libcerror_error_free(
+ &error );
+ }
+ }
+ for( test_number = 0;
+ test_number < number_of_memset_fail_tests;
+ test_number++ )
+ {
+ /* Test info_handle_initialize with memset failing
+ */
+ fsapfs_test_memset_attempts_before_fail = test_number;
+
+ result = info_handle_initialize(
+ &info_handle,
+ 0,
+ &error );
+
+ if( fsapfs_test_memset_attempts_before_fail != -1 )
+ {
+ fsapfs_test_memset_attempts_before_fail = -1;
+
+ if( info_handle != NULL )
+ {
+ info_handle_free(
+ &info_handle,
+ NULL );
+ }
+ }
+ else
+ {
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ -1 );
+
+ FSAPFS_TEST_ASSERT_IS_NULL(
+ "info_handle",
+ info_handle );
+
+ FSAPFS_TEST_ASSERT_IS_NOT_NULL(
+ "error",
+ error );
+
+ libcerror_error_free(
+ &error );
+ }
+ }
+#endif /* defined( HAVE_FSAPFS_TEST_MEMORY ) */
+
+ return( 1 );
+
+on_error:
+ if( error != NULL )
+ {
+ libcerror_error_free(
+ &error );
+ }
+ if( info_handle != NULL )
+ {
+ info_handle_free(
+ &info_handle,
+ NULL );
+ }
+ return( 0 );
+}
+
+/* Tests the info_handle_free function
+ * Returns 1 if successful or 0 if not
+ */
+int fsapfs_test_tools_info_handle_free(
+ void )
+{
+ libcerror_error_t *error = NULL;
+ int result = 0;
+
+ /* Test error cases
+ */
+ result = info_handle_free(
+ NULL,
+ &error );
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ -1 );
+
+ FSAPFS_TEST_ASSERT_IS_NOT_NULL(
+ "error",
+ error );
+
+ libcerror_error_free(
+ &error );
+
+ return( 1 );
+
+on_error:
+ if( error != NULL )
+ {
+ libcerror_error_free(
+ &error );
+ }
+ return( 0 );
+}
+
+/* The main program
+ */
+#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
+int wmain(
+ int argc FSAPFS_TEST_ATTRIBUTE_UNUSED,
+ wchar_t * const argv[] FSAPFS_TEST_ATTRIBUTE_UNUSED )
+#else
+int main(
+ int argc FSAPFS_TEST_ATTRIBUTE_UNUSED,
+ char * const argv[] FSAPFS_TEST_ATTRIBUTE_UNUSED )
+#endif
+{
+ FSAPFS_TEST_UNREFERENCED_PARAMETER( argc )
+ FSAPFS_TEST_UNREFERENCED_PARAMETER( argv )
+
+ FSAPFS_TEST_RUN(
+ "info_handle_initialize",
+ fsapfs_test_tools_info_handle_initialize );
+
+ FSAPFS_TEST_RUN(
+ "info_handle_free",
+ fsapfs_test_tools_info_handle_free );
+
+ return( EXIT_SUCCESS );
+
+on_error:
+ return( EXIT_FAILURE );
+}
+
diff --git a/tests/fsapfs_test_tools_output.c b/tests/fsapfs_test_tools_output.c
new file mode 100644
index 0000000..ab4e538
--- /dev/null
+++ b/tests/fsapfs_test_tools_output.c
@@ -0,0 +1,105 @@
+/*
+ * Tools output functions test program
+ *
+ * Copyright (C) 2018-2021, Joachim Metz
+ *
+ * Refer to AUTHORS for acknowledgements.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include
+#include
+
+#include
+
+#if defined( HAVE_IO_H ) || defined( WINAPI )
+#include
+#endif
+
+#if defined( HAVE_STDLIB_H ) || defined( WINAPI )
+#include
+#endif
+
+#include "fsapfs_test_libcerror.h"
+#include "fsapfs_test_macros.h"
+#include "fsapfs_test_unused.h"
+
+#include "../fsapfstools/fsapfstools_output.h"
+
+/* Tests the fsapfstools_output_initialize function
+ * Returns 1 if successful or 0 if not
+ */
+int fsapfs_test_tools_output_initialize(
+ void )
+{
+ libcerror_error_t *error = NULL;
+ int result = 0;
+
+ result = fsapfstools_output_initialize(
+ _IONBF,
+ &error );
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ 1 );
+
+ FSAPFS_TEST_ASSERT_IS_NULL(
+ "error",
+ error );
+
+ return( 1 );
+
+on_error:
+ if( error != NULL )
+ {
+ libcerror_error_free(
+ &error );
+ }
+ return( 0 );
+}
+
+/* The main program
+ */
+#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
+int wmain(
+ int argc FSAPFS_TEST_ATTRIBUTE_UNUSED,
+ wchar_t * const argv[] FSAPFS_TEST_ATTRIBUTE_UNUSED )
+#else
+int main(
+ int argc FSAPFS_TEST_ATTRIBUTE_UNUSED,
+ char * const argv[] FSAPFS_TEST_ATTRIBUTE_UNUSED )
+#endif
+{
+ FSAPFS_TEST_UNREFERENCED_PARAMETER( argc )
+ FSAPFS_TEST_UNREFERENCED_PARAMETER( argv )
+
+ FSAPFS_TEST_RUN(
+ "fsapfstools_output_initialize",
+ fsapfs_test_tools_output_initialize )
+
+ /* TODO add tests for fsapfstools_output_copyright_fprint */
+
+ /* TODO add tests for fsapfstools_output_version_fprint */
+
+ /* TODO add tests for fsapfstools_output_version_detailed_fprint */
+
+ return( EXIT_SUCCESS );
+
+on_error:
+ return( EXIT_FAILURE );
+}
+
diff --git a/tests/fsapfs_test_tools_signal.c b/tests/fsapfs_test_tools_signal.c
new file mode 100644
index 0000000..1c3a985
--- /dev/null
+++ b/tests/fsapfs_test_tools_signal.c
@@ -0,0 +1,213 @@
+/*
+ * Tools signal functions test program
+ *
+ * Copyright (C) 2018-2021, Joachim Metz
+ *
+ * Refer to AUTHORS for acknowledgements.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include
+#include
+
+#if defined( HAVE_STDLIB_H ) || defined( WINAPI )
+#include
+#endif
+
+#include "fsapfs_test_libcerror.h"
+#include "fsapfs_test_macros.h"
+#include "fsapfs_test_unused.h"
+
+#include "../fsapfstools/fsapfstools_signal.h"
+
+void fsapfs_test_tools_signal_handler_function(
+ fsapfstools_signal_t signal FSAPFS_TEST_ATTRIBUTE_UNUSED )
+{
+ FSAPFS_TEST_UNREFERENCED_PARAMETER( signal )
+}
+
+#if defined( WINAPI )
+
+/* Tests the fsapfstools_signal_handler function
+ * Returns 1 if successful or 0 if not
+ */
+int fsapfs_test_tools_signal_handler(
+ void )
+{
+ BOOL result = 0;
+
+ /* Test regular cases
+ */
+ result = fsapfstools_signal_handler(
+ CTRL_C_EVENT );
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ (int) TRUE );
+
+ result = fsapfstools_signal_handler(
+ CTRL_LOGOFF_EVENT );
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ (int) FALSE );
+
+ return( 1 );
+
+on_error:
+ return( 0 );
+}
+
+#if defined( _MSC_VER )
+
+ /* TODO add tests for fsapfstools_signal_initialize_memory_debug */
+
+#endif /* defined( _MSC_VER ) */
+
+#endif /* defined( WINAPI ) */
+
+/* Tests the fsapfstools_signal_attach function
+ * Returns 1 if successful or 0 if not
+ */
+int fsapfs_test_tools_signal_attach(
+ void )
+{
+ libcerror_error_t *error = NULL;
+ int result = 0;
+
+ /* Test regular cases
+ */
+ result = fsapfstools_signal_attach(
+ fsapfs_test_tools_signal_handler_function,
+ &error );
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ 1 );
+
+ FSAPFS_TEST_ASSERT_IS_NULL(
+ "error",
+ error );
+
+ /* Test error cases
+ */
+ result = fsapfstools_signal_attach(
+ NULL,
+ &error );
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ -1 );
+
+ FSAPFS_TEST_ASSERT_IS_NOT_NULL(
+ "error",
+ error );
+
+ libcerror_error_free(
+ &error );
+
+ return( 1 );
+
+on_error:
+ if( error != NULL )
+ {
+ libcerror_error_free(
+ &error );
+ }
+ return( 0 );
+}
+
+/* Tests the fsapfstools_signal_detach function
+ * Returns 1 if successful or 0 if not
+ */
+int fsapfs_test_tools_signal_detach(
+ void )
+{
+ libcerror_error_t *error = NULL;
+ int result = 0;
+
+ /* Test regular cases
+ */
+ result = fsapfstools_signal_detach(
+ &error );
+
+ FSAPFS_TEST_ASSERT_EQUAL_INT(
+ "result",
+ result,
+ 1 );
+
+ FSAPFS_TEST_ASSERT_IS_NULL(
+ "error",
+ error );
+
+ return( 1 );
+
+on_error:
+ if( error != NULL )
+ {
+ libcerror_error_free(
+ &error );
+ }
+ return( 0 );
+}
+
+/* The main program
+ */
+#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
+int wmain(
+ int argc FSAPFS_TEST_ATTRIBUTE_UNUSED,
+ wchar_t * const argv[] FSAPFS_TEST_ATTRIBUTE_UNUSED )
+#else
+int main(
+ int argc FSAPFS_TEST_ATTRIBUTE_UNUSED,
+ char * const argv[] FSAPFS_TEST_ATTRIBUTE_UNUSED )
+#endif
+{
+ FSAPFS_TEST_UNREFERENCED_PARAMETER( argc )
+ FSAPFS_TEST_UNREFERENCED_PARAMETER( argv )
+
+#if defined( WINAPI )
+
+ FSAPFS_TEST_RUN(
+ "fsapfstools_signal_handler",
+ fsapfs_test_tools_signal_handler )
+
+#if defined( _MSC_VER )
+
+ /* TODO add tests for fsapfstools_signal_initialize_memory_debug */
+
+#endif /* defined( _MSC_VER ) */
+
+#endif /* defined( WINAPI ) */
+
+ FSAPFS_TEST_RUN(
+ "fsapfstools_signal_attach",
+ fsapfs_test_tools_signal_attach )
+
+ FSAPFS_TEST_RUN(
+ "fsapfstools_signal_detach",
+ fsapfs_test_tools_signal_detach )
+
+ return( EXIT_SUCCESS );
+
+on_error:
+ return( EXIT_FAILURE );
+}
+
diff --git a/tests/test_tools.sh b/tests/test_tools.sh
new file mode 100755
index 0000000..dee4d2b
--- /dev/null
+++ b/tests/test_tools.sh
@@ -0,0 +1,189 @@
+#!/bin/bash
+# Tests tools functions and types.
+#
+# Version: 20200705
+
+EXIT_SUCCESS=0;
+EXIT_FAILURE=1;
+EXIT_IGNORE=77;
+
+TOOLS_TESTS="info_handle output signal";
+TOOLS_TESTS_WITH_INPUT="";
+OPTION_SETS="";
+
+INPUT_GLOB="*";
+
+run_test()
+{
+ local TEST_NAME=$1;
+
+ local TEST_DESCRIPTION="Testing: ${TEST_NAME}";
+ local TEST_EXECUTABLE="./fsapfs_test_tools_${TEST_NAME}";
+
+ if ! test -x "${TEST_EXECUTABLE}";
+ then
+ TEST_EXECUTABLE="${TEST_EXECUTABLE}.exe";
+ fi
+
+ # TODO: add support for TEST_PROFILE and OPTION_SETS?
+ run_test_with_arguments "${TEST_DESCRIPTION}" "${TEST_EXECUTABLE}";
+ local RESULT=$?;
+
+ return ${RESULT};
+}
+
+run_test_with_input()
+{
+ local TEST_NAME=$1;
+
+ local TEST_DESCRIPTION="Testing: ${TEST_NAME}";
+ local TEST_EXECUTABLE="./fsapfs_test_tools_${TEST_NAME}";
+
+ if ! test -x "${TEST_EXECUTABLE}";
+ then
+ TEST_EXECUTABLE="${TEST_EXECUTABLE}.exe";
+ fi
+
+ if ! test -d "input";
+ then
+ echo "Test input directory 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";
+
+ return ${EXIT_IGNORE};
+ fi
+
+ local TEST_PROFILE_DIRECTORY=$(get_test_profile_directory "input" "fsapfstools");
+
+ 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
+ if test "${OSTYPE}" = "msys";
+ then
+ # A test executable built with MinGW expects a Windows path.
+ INPUT_FILE=`echo ${INPUT_FILE} | sed 's?/?\\\\?g'`;
+ fi
+ 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 -1d ${TEST_SET_INPUT_DIRECTORY}/${INPUT_GLOB}`;
+ do
+ if test "${OSTYPE}" = "msys";
+ then
+ # A test executable built with MinGW expects a Windows path.
+ INPUT_FILE=`echo ${INPUT_FILE} | sed 's?/?\\\\?g'`;
+ fi
+ 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};
+}
+
+if test -n "${SKIP_TOOLS_TESTS}";
+then
+ exit ${EXIT_IGNORE};
+fi
+
+TEST_RUNNER="tests/test_runner.sh";
+
+if ! test -f "${TEST_RUNNER}";
+then
+ TEST_RUNNER="./test_runner.sh";
+fi
+
+if ! test -f "${TEST_RUNNER}";
+then
+ echo "Missing test runner: ${TEST_RUNNER}";
+
+ exit ${EXIT_FAILURE};
+fi
+
+source ${TEST_RUNNER};
+
+RESULT=${EXIT_IGNORE};
+
+for TEST_NAME in ${TOOLS_TESTS};
+do
+ run_test "${TEST_NAME}";
+ RESULT=$?;
+
+ if test ${RESULT} -ne ${EXIT_SUCCESS};
+ then
+ break;
+ fi
+done
+
+if test ${RESULT} -ne ${EXIT_SUCCESS} && test ${RESULT} -ne ${EXIT_IGNORE};
+then
+ exit ${RESULT};
+fi
+
+for TEST_NAME in ${TOOLS_TESTS_WITH_INPUT};
+do
+ if test -d "input";
+ then
+ run_test_with_input "${TEST_NAME}";
+ RESULT=$?;
+ else
+ run_test "${TEST_NAME}";
+ RESULT=$?;
+ fi
+
+ if test ${RESULT} -ne ${EXIT_SUCCESS};
+ then
+ break;
+ fi
+done
+
+exit ${RESULT};
+