Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libfshfs for openSUSE:Factory checked in at 2026-09-22 15:53:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libfshfs (Old) and /work/SRC/openSUSE:Factory/.libfshfs.new.383539 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libfshfs" Tue Sep 22 15:53:31 2026 rev:23 rq:1379651 version:20260922 Changes: -------- --- /work/SRC/openSUSE:Factory/libfshfs/libfshfs.changes 2026-08-27 18:55:28.456164306 +0200 +++ /work/SRC/openSUSE:Factory/.libfshfs.new.383539/libfshfs.changes 2026-09-22 15:55:11.371116401 +0200 @@ -1,0 +2,6 @@ +Tue Sep 22 10:05:27 UTC 2026 - Jan Engelhardt <[email protected]> + +- Update to release 20260922 + * Plugged memory leaks + +------------------------------------------------------------------- Old: ---- libfshfs-experimental-20260826.tar.gz libfshfs-experimental-20260826.tar.gz.asc New: ---- libfshfs-experimental-20260922.tar.gz libfshfs-experimental-20260922.tar.gz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libfshfs.spec ++++++ --- /var/tmp/diff_new_pack.8T9mAg/_old 2026-09-22 15:55:12.720171977 +0200 +++ /var/tmp/diff_new_pack.8T9mAg/_new 2026-09-22 15:55:12.721172019 +0200 @@ -21,9 +21,9 @@ %define lname libfshfs1 Name: libfshfs -Version: 20260826 +Version: 20260922 Release: 0 -Summary: Library and tools to access the Mac OS Hierarchical File System (HFS) +Summary: Library and tools for reading Mac OS Hierarchical File Systems License: GFDL-1.3-or-later AND LGPL-3.0-or-later Group: Productivity/File utilities URL: https://github.com/libyal/libfshfs @@ -57,30 +57,11 @@ # Various notes: https://en.opensuse.org/libyal %description -Read-only supported HFS formats: - -* HFS+, Mac OS 10.3 and later (Unicode 3.2 case-insensitive) -* HFSX, Mac OS 10.3 and later (Unicode 3.2 case-sensitive) - -Unsupported HFS formats: - -* (traditional) HFS -* HFS+, Mac OS 8.1 through 10.2 (Unicode 2.1 case-insensitive) -* HFSX, Mac OS 8.1 through 10.2 (Unicode 2.1 case-sensitive) - -Supported HFS format features: - -* ZLIB (DEFLATE) compression -* LZVN compression -* extended attributes - -Unsupported HFS format features: - -* LZFSE compression, compression methods 11 and 12 -* "uncompressed", compression methods 1, 9 and 10 +A library and tools for read access to Mac OS Hierarchical File +Systems. %package -n %lname -Summary: Library and tools to access the Mac OS Hierarchical File System (HFS) +Summary: Library for reading Mac OS Hierarchical File Systems (HFS) License: LGPL-3.0-or-later Group: System/Libraries @@ -108,7 +89,7 @@ * "uncompressed", compression methods 1, 9 and 10 %package tools -Summary: Tools to access the Mac OS Hierarchical File System (HFS) +Summary: Tools for reading Mac OS Hierarchical File Systems (HFS) License: LGPL-3.0-or-later Group: Productivity/File utilities Requires: %lname = %version ++++++ _scmsync.obsinfo ++++++ --- /var/tmp/diff_new_pack.8T9mAg/_old 2026-09-22 15:55:12.796175109 +0200 +++ /var/tmp/diff_new_pack.8T9mAg/_new 2026-09-22 15:55:12.805175479 +0200 @@ -1,5 +1,5 @@ -mtime: 1787769890 -commit: 9c8e67f1ab274dc1c1c2ec08a12325219dbf4ea026a623a9e0295b7f3e4d08a4 +mtime: 1790071551 +commit: a5819a496309dd48863a71ade57adb94a53fdb24139c808db9b15968c89ba3b9 url: https://src.opensuse.org/security-forensics/libfshfs revision: master ++++++ build.specials.obscpio ++++++ ++++++ build.specials.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.gitignore new/.gitignore --- old/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/.gitignore 2026-09-22 12:05:51.000000000 +0200 @@ -0,0 +1 @@ +.osc ++++++ libfshfs-experimental-20260826.tar.gz -> libfshfs-experimental-20260922.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/common/config.h new/libfshfs-20260922/common/config.h --- old/libfshfs-20260826/common/config.h 2026-08-26 15:35:42.000000000 +0200 +++ new/libfshfs-20260922/common/config.h 2026-09-22 08:06:38.000000000 +0200 @@ -629,7 +629,7 @@ #define PACKAGE_NAME "libfshfs" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libfshfs 20260826" +#define PACKAGE_STRING "libfshfs 20260922" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "libfshfs" @@ -638,7 +638,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "20260826" +#define PACKAGE_VERSION "20260922" /* The size of 'int', as computed by sizeof. */ #define SIZEOF_INT 4 @@ -667,7 +667,7 @@ /* #undef TM_IN_SYS_TIME */ /* Version number of package */ -#define VERSION "20260826" +#define VERSION "20260922" /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef _FILE_OFFSET_BITS */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/configure new/libfshfs-20260922/configure --- old/libfshfs-20260826/configure 2026-08-26 15:35:34.000000000 +0200 +++ new/libfshfs-20260922/configure 2026-09-22 08:06:30.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.72 for libfshfs 20260826. +# Generated by GNU Autoconf 2.72 for libfshfs 20260922. # # Report bugs to <https://github.com/libyal/libfshfs/issues>. # @@ -614,8 +614,8 @@ # Identity of this package. PACKAGE_NAME='libfshfs' PACKAGE_TARNAME='libfshfs' -PACKAGE_VERSION='20260826' -PACKAGE_STRING='libfshfs 20260826' +PACKAGE_VERSION='20260922' +PACKAGE_STRING='libfshfs 20260922' PACKAGE_BUGREPORT='https://github.com/libyal/libfshfs/issues' PACKAGE_URL='' @@ -1727,7 +1727,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -'configure' configures libfshfs 20260826 to adapt to many kinds of systems. +'configure' configures libfshfs 20260922 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1798,7 +1798,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libfshfs 20260826:";; + short | recursive ) echo "Configuration of libfshfs 20260922:";; esac cat <<\_ACEOF @@ -2087,7 +2087,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libfshfs configure 20260826 +libfshfs configure 20260922 generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -2829,7 +2829,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libfshfs $as_me 20260826, which was +It was created by libfshfs $as_me 20260922, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -4526,7 +4526,7 @@ # Define the identity of the package. PACKAGE='libfshfs' - VERSION='20260826' + VERSION='20260922' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -73313,7 +73313,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libfshfs $as_me 20260826, which was +This file was extended by libfshfs $as_me 20260922, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -73381,7 +73381,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -libfshfs config.status 20260826 +libfshfs config.status 20260922 configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/configure.ac new/libfshfs-20260922/configure.ac --- old/libfshfs-20260826/configure.ac 2026-08-26 15:26:30.000000000 +0200 +++ new/libfshfs-20260922/configure.ac 2026-09-22 07:37:52.000000000 +0200 @@ -2,7 +2,7 @@ AC_INIT( [libfshfs], - [20260826], + [20260922], [https://github.com/libyal/libfshfs/issues]) AC_CONFIG_SRCDIR( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/dpkg/changelog new/libfshfs-20260922/dpkg/changelog --- old/libfshfs-20260826/dpkg/changelog 2026-08-26 15:35:42.000000000 +0200 +++ new/libfshfs-20260922/dpkg/changelog 2026-09-22 08:06:38.000000000 +0200 @@ -1,5 +1,5 @@ -libfshfs (20260826-1) unstable; urgency=low +libfshfs (20260922-1) unstable; urgency=low * Auto-generated - -- Joachim Metz <[email protected]> Wed, 26 Aug 2026 15:35:42 +0200 + -- Joachim Metz <[email protected]> Tue, 22 Sep 2026 08:06:37 +0200 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/include/libfshfs/definitions.h new/libfshfs-20260922/include/libfshfs/definitions.h --- old/libfshfs-20260826/include/libfshfs/definitions.h 2026-08-26 15:35:42.000000000 +0200 +++ new/libfshfs-20260922/include/libfshfs/definitions.h 2026-09-22 08:06:38.000000000 +0200 @@ -24,11 +24,11 @@ #include <libfshfs/types.h> -#define LIBFSHFS_VERSION 20260826 +#define LIBFSHFS_VERSION 20260922 /* The version string */ -#define LIBFSHFS_VERSION_STRING "20260826" +#define LIBFSHFS_VERSION_STRING "20260922" /* The file access * bit 1 set to 1 for read access diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/libfshfs/libfshfs.rc new/libfshfs-20260922/libfshfs/libfshfs.rc --- old/libfshfs-20260826/libfshfs/libfshfs.rc 2026-08-26 15:35:42.000000000 +0200 +++ new/libfshfs-20260922/libfshfs/libfshfs.rc 2026-09-22 08:06:38.000000000 +0200 @@ -22,12 +22,12 @@ BLOCK "040904E4" BEGIN VALUE "FileDescription", "Library to access the Hierarchical File System (HFS) format\0" - VALUE "FileVersion", "20260826" "\0" + VALUE "FileVersion", "20260922" "\0" VALUE "InternalName", "libfshfs.dll\0" VALUE "LegalCopyright", "(C) 2009-2026, Joachim Metz <[email protected]>\0" VALUE "OriginalFilename", "libfshfs.dll\0" VALUE "ProductName", "libfshfs\0" - VALUE "ProductVersion", "20260826" "\0" + VALUE "ProductVersion", "20260922" "\0" VALUE "Comments", "For more information visit https://github.com/libyal/libfshfs/\0" END END diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/libfshfs/libfshfs_compressed_data_handle.c new/libfshfs-20260922/libfshfs/libfshfs_compressed_data_handle.c --- old/libfshfs-20260826/libfshfs/libfshfs_compressed_data_handle.c 2026-08-26 15:23:20.000000000 +0200 +++ new/libfshfs-20260922/libfshfs/libfshfs_compressed_data_handle.c 2026-09-22 07:27:13.000000000 +0200 @@ -195,6 +195,7 @@ libcerror_error_t **error ) { static char *function = "libfshfs_compressed_data_handle_free"; + int result = 1; if( data_handle == NULL ) { @@ -224,12 +225,25 @@ memory_free( ( *data_handle )->compressed_block_offsets ); } + if( libfdata_stream_free( + &( ( *data_handle )->compressed_data_stream ), + error ) != 1 ) + { + libcerror_error_set( + error, + LIBCERROR_ERROR_DOMAIN_RUNTIME, + LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, + "%s: unable to free compressed data stream.", + function ); + + result = -1; + } memory_free( *data_handle ); *data_handle = NULL; } - return( 1 ); + return( result ); } /* Determines the compressed block offsets @@ -240,22 +254,23 @@ libbfio_handle_t *file_io_handle, libcerror_error_t **error ) { - static char *function = "libfshfs_compressed_data_handle_get_compressed_block_offsets"; - size64_t compressed_data_size = 0; - size_t compressed_block_descriptor_size = 0; - size_t read_size = 0; - size_t segment_data_offset = 0; - ssize_t read_count = 0; - uint32_t compressed_block_index = 0; - uint32_t compressed_block_offset = 0; - uint32_t compressed_descriptors_offset = 0; - uint32_t compressed_footer_offset = 0; - uint32_t compressed_footer_size = 0; - uint32_t previous_compressed_block_offset = 0; - int compare_result = 0; + static char *function = "libfshfs_compressed_data_handle_get_compressed_block_offsets"; + size64_t compressed_data_size = 0; + size_t compressed_block_descriptor_size = 0; + size_t read_size = 0; + size_t segment_data_offset = 0; + ssize_t read_count = 0; + uint32_t compressed_block_index = 0; + uint32_t compressed_block_offset = 0; + uint32_t compressed_descriptors_offset = 0; + uint32_t compressed_footer_offset = 0; + uint32_t compressed_footer_size = 0; + uint32_t maximum_number_of_compressed_blocks = 0; + uint32_t previous_compressed_block_offset = 0; + int compare_result = 0; #if defined( HAVE_DEBUG_OUTPUT ) - uint32_t value_32bit = 0; + uint32_t value_32bit = 0; #endif if( data_handle == NULL ) @@ -439,7 +454,8 @@ &( data_handle->compressed_segment_data[ 260 ] ), data_handle->number_of_compressed_blocks ); - if( data_handle->number_of_compressed_blocks > ( (uint32_t) UINT32_MAX / 8 ) ) + if( ( data_handle->number_of_compressed_blocks == 0 ) + || ( data_handle->number_of_compressed_blocks > ( (uint32_t) UINT32_MAX / 8 ) ) ) { libcerror_error_set( error, @@ -498,7 +514,13 @@ data_handle->number_of_compressed_blocks ); } #endif - if( (size_t) data_handle->number_of_compressed_blocks > ( (size_t) ( MEMORY_MAXIMUM_ALLOCATION_SIZE / 4 ) - 1 ) ) + maximum_number_of_compressed_blocks = MEMORY_MAXIMUM_ALLOCATION_SIZE; + + if( compressed_block_descriptor_size != 0 ) + { + maximum_number_of_compressed_blocks /= compressed_block_descriptor_size; + } + if( data_handle->number_of_compressed_blocks > ( maximum_number_of_compressed_blocks - 1 ) ) { libcerror_error_set( error, @@ -532,6 +554,17 @@ { read_size = ( (size_t) data_handle->number_of_compressed_blocks - 1 ) * compressed_block_descriptor_size; + if( read_size > ( LIBFSHFS_COMPRESSED_DATA_HANDLE_BLOCK_SIZE + 1 ) - segment_data_offset ) + { + libcerror_error_set( + error, + LIBCERROR_ERROR_DOMAIN_RUNTIME, + LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, + "%s: invalid compressed block descriptors data size value out of bounds.", + function ); + + goto on_error; + } read_count = libfdata_stream_read_buffer_at_offset( data_handle->compressed_data_stream, (intptr_t *) file_io_handle, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/libfshfs/libfshfs_definitions.h new/libfshfs-20260922/libfshfs/libfshfs_definitions.h --- old/libfshfs-20260826/libfshfs/libfshfs_definitions.h 2026-08-26 15:35:42.000000000 +0200 +++ new/libfshfs-20260922/libfshfs/libfshfs_definitions.h 2026-09-22 08:06:38.000000000 +0200 @@ -37,11 +37,11 @@ * for local use of libfshfs */ #else -#define LIBFSHFS_VERSION 20260826 +#define LIBFSHFS_VERSION 20260922 /* The version string */ -#define LIBFSHFS_VERSION_STRING "20260826" +#define LIBFSHFS_VERSION_STRING "20260922" /* The file access * bit 1 set to 1 for read access diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/libfshfs/libfshfs_file_entry.c new/libfshfs-20260922/libfshfs/libfshfs_file_entry.c --- old/libfshfs-20260826/libfshfs/libfshfs_file_entry.c 2026-08-26 15:23:20.000000000 +0200 +++ new/libfshfs-20260922/libfshfs/libfshfs_file_entry.c 2026-09-22 07:26:46.000000000 +0200 @@ -2436,14 +2436,10 @@ *major_device_number = ( device_identifier >> 8 ) & 0x000000ffUL; *minor_device_number = device_identifier & 0x000000ffUL; } - else if( ( device_identifier & 0x00ffff00UL ) == 0 ) - { - *major_device_number = ( device_identifier >> 24 ) & 0x000000ffUL; - *minor_device_number = device_identifier & 0x000000ffUL; - } else { - result = 0; + *major_device_number = ( device_identifier >> 24 ) & 0x000000ffUL; + *minor_device_number = device_identifier & 0x00ffffffUL; } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/libfshfs.spec new/libfshfs-20260922/libfshfs.spec --- old/libfshfs-20260826/libfshfs.spec 2026-08-26 15:35:42.000000000 +0200 +++ new/libfshfs-20260922/libfshfs.spec 2026-09-22 08:06:38.000000000 +0200 @@ -1,5 +1,5 @@ Name: libfshfs -Version: 20260826 +Version: 20260922 Release: 1 Summary: Library to access the Hierarchical File System (HFS) format Group: System Environment/Libraries @@ -95,6 +95,6 @@ %{_mandir}/man1/* %changelog -* Wed Aug 26 2026 Joachim Metz <[email protected]> 20260826-1 +* Tue Sep 22 2026 Joachim Metz <[email protected]> 20260922-1 - Auto-generated diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/pyproject.toml new/libfshfs-20260922/pyproject.toml --- old/libfshfs-20260826/pyproject.toml 2026-08-26 15:35:42.000000000 +0200 +++ new/libfshfs-20260922/pyproject.toml 2026-09-22 08:06:38.000000000 +0200 @@ -4,7 +4,7 @@ [project] name = "libfshfs-python" -version = "20260826" +version = "20260922" description = "Python bindings for libfshfs" maintainers = [ { name = "Joachim Metz", email = "[email protected]" }, @@ -23,6 +23,11 @@ Homepage = "https://github.com/libyal/libfshfs" Repository = "https://github.com/libyal/libfshfs" +[tool.black] +line-length = 88 +target-version = ["py310"] +include = "\\.pyi?$" + [tool.setuptools] py-modules = ["_build"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/pyproject.toml.in new/libfshfs-20260922/pyproject.toml.in --- old/libfshfs-20260826/pyproject.toml.in 2026-08-26 15:23:19.000000000 +0200 +++ new/libfshfs-20260922/pyproject.toml.in 2026-09-18 13:30:33.000000000 +0200 @@ -23,6 +23,11 @@ Homepage = "https://github.com/libyal/libfshfs" Repository = "https://github.com/libyal/libfshfs" +[tool.black] +line-length = 88 +target-version = ["py310"] +include = "\\.pyi?$" + [tool.setuptools] py-modules = ["_build"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/tests/fshfs_test_compressed_data_handle.c new/libfshfs-20260922/tests/fshfs_test_compressed_data_handle.c --- old/libfshfs-20260826/tests/fshfs_test_compressed_data_handle.c 2026-08-26 15:24:58.000000000 +0200 +++ new/libfshfs-20260922/tests/fshfs_test_compressed_data_handle.c 2026-09-22 07:37:22.000000000 +0200 @@ -121,6 +121,8 @@ "error", error ); + compressed_allocation_block_stream = NULL; + result = libfshfs_compressed_data_handle_free( &compressed_data_handle, &error ); @@ -138,6 +140,27 @@ "error", error ); + /* Initialize test + */ + result = libfshfs_allocation_block_stream_initialize_from_data( + &compressed_allocation_block_stream, + fshfs_test_compressed_data_handle_lzvn_chunk_compressed_data1, + 35, + &error ); + + FSHFS_TEST_ASSERT_EQUAL_INT( + "result", + result, + 1 ); + + FSHFS_TEST_ASSERT_IS_NOT_NULL( + "compressed_allocation_block_stream", + compressed_allocation_block_stream ); + + FSHFS_TEST_ASSERT_IS_NULL( + "error", + error ); + /* Test error cases */ result = libfshfs_compressed_data_handle_initialize( @@ -463,6 +486,8 @@ "error", error ); + compressed_allocation_block_stream = NULL; + /* Test regular cases */ result = libfshfs_compressed_data_handle_get_compressed_block_offsets( @@ -498,23 +523,6 @@ "error", error ); - result = libfdata_stream_free( - &compressed_allocation_block_stream, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NULL( - "compressed_allocation_block_stream", - compressed_allocation_block_stream ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", - error ); - /* Initialize test */ result = libfshfs_allocation_block_stream_initialize_from_data( @@ -556,6 +564,8 @@ "error", error ); + compressed_allocation_block_stream = NULL; + /* Test regular cases */ result = libfshfs_compressed_data_handle_get_compressed_block_offsets( @@ -591,23 +601,6 @@ "error", error ); - result = libfdata_stream_free( - &compressed_allocation_block_stream, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NULL( - "compressed_allocation_block_stream", - compressed_allocation_block_stream ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", - error ); - /* Initialize test */ result = libfshfs_allocation_block_stream_initialize_from_data( @@ -649,6 +642,8 @@ "error", error ); + compressed_allocation_block_stream = NULL; + /* Test regular cases */ result = libfshfs_compressed_data_handle_get_compressed_block_offsets( @@ -684,23 +679,6 @@ "error", error ); - result = libfdata_stream_free( - &compressed_allocation_block_stream, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NULL( - "compressed_allocation_block_stream", - compressed_allocation_block_stream ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", - error ); - /* Initialize test */ result = libfshfs_allocation_block_stream_initialize_from_data( @@ -742,6 +720,8 @@ "error", error ); + compressed_allocation_block_stream = NULL; + /* Test error cases */ result = libfshfs_compressed_data_handle_get_compressed_block_offsets( @@ -780,23 +760,6 @@ "error", error ); - result = libfdata_stream_free( - &compressed_allocation_block_stream, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NULL( - "compressed_allocation_block_stream", - compressed_allocation_block_stream ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", - error ); - return( 1 ); on_error: @@ -878,6 +841,8 @@ "error", error ); + compressed_allocation_block_stream = NULL; + /* Test regular cases */ read_count = libfshfs_compressed_data_handle_read_segment_data( @@ -929,23 +894,6 @@ "error", error ); - result = libfdata_stream_free( - &compressed_allocation_block_stream, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NULL( - "compressed_allocation_block_stream", - compressed_allocation_block_stream ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", - error ); - /* Initialize test */ result = libfshfs_allocation_block_stream_initialize_from_data( @@ -987,6 +935,8 @@ "error", error ); + compressed_allocation_block_stream = NULL; + /* Test regular cases */ read_count = libfshfs_compressed_data_handle_read_segment_data( @@ -1038,23 +988,6 @@ "error", error ); - result = libfdata_stream_free( - &compressed_allocation_block_stream, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NULL( - "compressed_allocation_block_stream", - compressed_allocation_block_stream ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", - error ); - /* Initialize test */ result = libfshfs_allocation_block_stream_initialize_from_data( @@ -1096,6 +1029,8 @@ "error", error ); + compressed_allocation_block_stream = NULL; + /* Test regular cases */ read_count = libfshfs_compressed_data_handle_read_segment_data( @@ -1147,64 +1082,6 @@ "error", error ); - result = libfdata_stream_free( - &compressed_allocation_block_stream, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NULL( - "compressed_allocation_block_stream", - compressed_allocation_block_stream ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", - error ); - - /* Initialize test - */ - result = libfshfs_allocation_block_stream_initialize_from_data( - &compressed_allocation_block_stream, - fshfs_test_compressed_data_handle_lzvn_chunk_compressed_data1, - 35, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NOT_NULL( - "compressed_allocation_block_stream", - compressed_allocation_block_stream ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", - error ); - - result = libfshfs_compressed_data_handle_initialize( - &compressed_data_handle, - compressed_allocation_block_stream, - 16, - LIBFSHFS_COMPRESSION_METHOD_LZVN, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NOT_NULL( - "compressed_data_handle", - compressed_data_handle ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", - error ); - /* Test error cases */ read_count = libfshfs_compressed_data_handle_read_segment_data( @@ -1318,23 +1195,6 @@ "error", error ); - result = libfdata_stream_free( - &compressed_allocation_block_stream, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NULL( - "compressed_allocation_block_stream", - compressed_allocation_block_stream ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", - error ); - return( 1 ); on_error: @@ -1411,6 +1271,8 @@ "error", error ); + compressed_allocation_block_stream = NULL; + /* Test regular cases */ offset = libfshfs_compressed_data_handle_seek_segment_offset( @@ -1509,23 +1371,6 @@ FSHFS_TEST_ASSERT_IS_NULL( "error", - error ); - - result = libfdata_stream_free( - &compressed_allocation_block_stream, - &error ); - - FSHFS_TEST_ASSERT_EQUAL_INT( - "result", - result, - 1 ); - - FSHFS_TEST_ASSERT_IS_NULL( - "compressed_allocation_block_stream", - compressed_allocation_block_stream ); - - FSHFS_TEST_ASSERT_IS_NULL( - "error", error ); return( 1 ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/tests/generate_test_inputs.sh new/libfshfs-20260922/tests/generate_test_inputs.sh --- old/libfshfs-20260826/tests/generate_test_inputs.sh 2026-08-26 15:23:21.000000000 +0200 +++ new/libfshfs-20260922/tests/generate_test_inputs.sh 2026-09-18 13:30:36.000000000 +0200 @@ -1,7 +1,7 @@ #!/bin/sh # Script to generate test_inputs.at # -# Version: 20260617 +# Version: 20260914 ignore_list_add() { if ! ignore_list_contains "$1"; then @@ -48,7 +48,7 @@ FILE="${INPUT}/.${TEST_PROFILE}/${TEST_SET}/${TEST_FILENAME}.${OPTION_SET}" if test -f "${FILE}"; then # The original format of the options file contains all options on the first line. - OPTIONS=`head -n 1 "${FILE}" | sed 's/[\r\n]*$//'` + OPTIONS=$(head -n 1 "${FILE}" | sed 's/[\r\n]*$//') # The newer format of the options file has a distinct header. if test "${OPTIONS}" = "# libyal test data options"; then @@ -158,7 +158,8 @@ CURRENT_SECTION="" while IFS= read -r LINE || test -n "${LINE}"; do - LINE="${LINE%"${LINE##*[!$'\r']}"}" + CR=$(printf '\r') + LINE="${LINE%"${LINE##*[!"${CR}"]}"}" case "${LINE}" in \[*\]) @@ -170,11 +171,11 @@ if test "${CURRENT_SECTION}" = "tests"; then case "${LINE}" in input_glob:*) - INPUT_GLOB=`printf '%s' "${LINE#*:}" | tr -d '" '` + INPUT_GLOB=$(printf '%s' "${LINE#*:}" | tr -d '" ') ;; option_sets:*) - OPTION_SETS=`printf '%s' "${LINE#*:}" | tr -d '[]" ' | tr ',' '|'` + OPTION_SETS=$(printf '%s' "${LINE#*:}" | tr -d '[]" ' | tr ',' '|') ;; esac fi @@ -204,7 +205,7 @@ read_ignore_list "${INPUT}/.${TEST_PROFILE}" for TEST_SET in "${INPUT}"/*; do - TEST_SET=`basename "${TEST_SET}"` + TEST_SET=$(basename "${TEST_SET}") if test ! -d "${INPUT}/${TEST_SET}"; then echo "Skipping '${TEST_SET}' not a directory" @@ -224,7 +225,7 @@ else GLOB_FILE="${INPUT}/.${TEST_PROFILE}/glob" if test -f "${GLOB_FILE}"; then - TEST_FILES_GLOB=`head -n 1 "${GLOB_FILE}" | sed 's/[\r\n]*$//'` + TEST_FILES_GLOB=$(head -n 1 "${GLOB_FILE}" | sed 's/[\r\n]*$//') else TEST_FILES_GLOB="${INPUT_GLOB}" fi @@ -235,7 +236,7 @@ continue fi while test_files_pop; test -n "${TEST_FILE}"; do - TEST_FILENAME=`basename "${TEST_FILE}"` + TEST_FILENAME=$(basename "${TEST_FILE}") if test ${GLOB_FILES} -eq 0 && test ! -f "${TEST_FILE}"; then echo "Skipping missing file '${TEST_FILENAME}' defined in '${TEST_SET}/files'" @@ -244,12 +245,12 @@ TEST_FILE="${TEST_FILE#*input/}" # Escape [ and ] as @<:@ and @:>@ - TEST_FILE=`echo "${TEST_FILE}" | sed 's/\[/@<:@/g;s/\]/@:>@/g'` + TEST_FILE=$(echo "${TEST_FILE}" | sed 's/\[/@<:@/g;s/\]/@:>@/g') OPTIONS_PER_PROFILE="" OPTIONS_FILE="${INPUT}/.${TEST_PROFILE}/options" if test -f "${OPTIONS_FILE}"; then - OPTIONS_PER_PROFILE=`head -n 1 "${OPTIONS_FILE}" | sed 's/[\r\n]*$//'` + OPTIONS_PER_PROFILE=$(head -n 1 "${OPTIONS_FILE}" | sed 's/[\r\n]*$//') fi TEST_WITH_OPTIONS=0 @@ -294,8 +295,8 @@ else ENTRIES="${ENTRY}" fi - COUNTER=`expr "${COUNTER}" + 1` + COUNTER=$((COUNTER + 1)) done echo "" >> "${AT_FILE}" -echo -n "m4_define([test_inputs_${TEST_PROFILE}], [[${ENTRIES}]])" >> "${AT_FILE}" +printf "m4_define([test_inputs_%s], [[%s]])" "${TEST_PROFILE}" "${ENTRIES}" >> "${AT_FILE}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/tests/package.m4 new/libfshfs-20260922/tests/package.m4 --- old/libfshfs-20260826/tests/package.m4 2026-08-26 15:29:06.000000000 +0200 +++ new/libfshfs-20260922/tests/package.m4 2026-09-22 07:40:18.000000000 +0200 @@ -1,5 +1,5 @@ m4_define([AT_PACKAGE_NAME], [libfshfs]) m4_define([AT_PACKAGE_TARNAME], [libfshfs]) -m4_define([AT_PACKAGE_VERSION], [20260826]) -m4_define([AT_PACKAGE_STRING], [libfshfs 20260826]) +m4_define([AT_PACKAGE_VERSION], [20260922]) +m4_define([AT_PACKAGE_STRING], [libfshfs 20260922]) m4_define([AT_PACKAGE_BUGREPORT], [https://github.com/libyal/libfshfs/issues]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/tests/pyfshfs_test_support.py new/libfshfs-20260922/tests/pyfshfs_test_support.py --- old/libfshfs-20260826/tests/pyfshfs_test_support.py 2026-08-26 15:24:58.000000000 +0200 +++ new/libfshfs-20260922/tests/pyfshfs_test_support.py 2026-09-18 13:32:11.000000000 +0200 @@ -28,84 +28,89 @@ class SupportFunctionsTests(unittest.TestCase): - """Tests the support functions.""" + """Tests the support functions.""" - def test_get_version(self): - """Tests the get_version function.""" - version = pyfshfs.get_version() - self.assertIsNotNone(version) + def test_get_version(self): + """Tests the get_version function.""" + version = pyfshfs.get_version() + self.assertIsNotNone(version) - def test_check_volume_signature(self): - """Tests the check_volume_signature function.""" - test_source = getattr(unittest, "source", None) - if not test_source: - raise unittest.SkipTest("missing source") + def test_check_volume_signature(self): + """Tests the check_volume_signature function.""" + test_source = getattr(unittest, "source", None) + if not test_source: + raise unittest.SkipTest("missing source") - result = pyfshfs.check_volume_signature(test_source) - self.assertTrue(result) + result = pyfshfs.check_volume_signature(test_source) + self.assertTrue(result) - def test_check_volume_signature_file_object(self): - """Tests the check_volume_signature_file_object function.""" - test_source = getattr(unittest, "source", None) - if not test_source: - raise unittest.SkipTest("missing source") + def test_check_volume_signature_file_object(self): + """Tests the check_volume_signature_file_object function.""" + test_source = getattr(unittest, "source", None) + if not test_source: + raise unittest.SkipTest("missing source") - if not os.path.isfile(test_source): - raise unittest.SkipTest("source not a regular file") + if not os.path.isfile(test_source): + raise unittest.SkipTest("source not a regular file") - with open(test_source, "rb") as file_object: - result = pyfshfs.check_volume_signature_file_object(file_object) - self.assertTrue(result) + with open(test_source, "rb") as file_object: + result = pyfshfs.check_volume_signature_file_object(file_object) + self.assertTrue(result) - def test_open(self): - """Tests the open function.""" - test_source = getattr(unittest, "source", None) - if not test_source: - raise unittest.SkipTest("missing source") + def test_open(self): + """Tests the open function.""" + test_source = getattr(unittest, "source", None) + if not test_source: + raise unittest.SkipTest("missing source") - fshfs_volume = pyfshfs.open(test_source) - self.assertIsNotNone(fshfs_volume) + fshfs_volume = pyfshfs.open(test_source) + self.assertIsNotNone(fshfs_volume) - fshfs_volume.close() + fshfs_volume.close() - with self.assertRaises(TypeError): - pyfshfs.open(None) + with self.assertRaises(TypeError): + pyfshfs.open(None) - with self.assertRaises(ValueError): - pyfshfs.open(test_source, mode="w") + with self.assertRaises(ValueError): + pyfshfs.open(test_source, mode="w") - def test_open_file_object(self): - """Tests the open_file_object function.""" - test_source = getattr(unittest, "source", None) - if not test_source: - raise unittest.SkipTest("missing source") + def test_open_file_object(self): + """Tests the open_file_object function.""" + test_source = getattr(unittest, "source", None) + if not test_source: + raise unittest.SkipTest("missing source") - if not os.path.isfile(test_source): - raise unittest.SkipTest("source not a regular file") + if not os.path.isfile(test_source): + raise unittest.SkipTest("source not a regular file") - with open(test_source, "rb") as file_object: - fshfs_volume = pyfshfs.open_file_object(file_object) - self.assertIsNotNone(fshfs_volume) + with open(test_source, "rb") as file_object: + fshfs_volume = pyfshfs.open_file_object(file_object) + self.assertIsNotNone(fshfs_volume) - fshfs_volume.close() + fshfs_volume.close() - with self.assertRaises(TypeError): - pyfshfs.open_file_object(None) + with self.assertRaises(TypeError): + pyfshfs.open_file_object(None) - with self.assertRaises(ValueError): - pyfshfs.open_file_object(file_object, mode="w") + with self.assertRaises(ValueError): + pyfshfs.open_file_object(file_object, mode="w") if __name__ == "__main__": - argument_parser = argparse.ArgumentParser() + argument_parser = argparse.ArgumentParser() - argument_parser.add_argument( - "source", nargs="?", action="store", metavar="PATH", - default=None, help="path of the source file.") + argument_parser.add_argument( + "source", + nargs="?", + action="store", + metavar="PATH", + default=None, + help="path of the source file.", + ) - options, unknown_options = argument_parser.parse_known_args() - unknown_options.insert(0, sys.argv[0]) + options, unknown_options = argument_parser.parse_known_args() + unknown_options.insert(0, sys.argv[0]) - setattr(unittest, "source", options.source) + setattr(unittest, "source", options.source) - unittest.main(argv=unknown_options, verbosity=2) + unittest.main(argv=unknown_options, verbosity=2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfshfs-20260826/tests/pyfshfs_test_volume.py new/libfshfs-20260922/tests/pyfshfs_test_volume.py --- old/libfshfs-20260826/tests/pyfshfs_test_volume.py 2026-08-26 15:24:58.000000000 +0200 +++ new/libfshfs-20260922/tests/pyfshfs_test_volume.py 2026-09-18 13:32:11.000000000 +0200 @@ -28,289 +28,303 @@ class DataRangeFileObject(object): - """File-like object that maps an in-file data range.""" + """File-like object that maps an in-file data range.""" - def __init__(self, path, range_offset, range_size): - """Initializes a file-like object. + def __init__(self, path, range_offset, range_size): + """Initializes a file-like object. - Args: - path (str): path of the file that contains the data range. - range_offset (int): offset where the data range starts. - range_size (int): size of the data range starts, or None to indicate - the range should continue to the end of the parent file-like object. - """ - super(DataRangeFileObject, self).__init__() - self._current_offset = 0 - self._file_object = open(path, "rb") - self._range_offset = range_offset - self._range_size = range_size - - def __enter__(self): - """Enters a with statement.""" - return self - - def __exit__(self, unused_type, unused_value, unused_traceback): - """Exits a with statement.""" - return - - def close(self): - """Closes the file-like object.""" - if self._file_object: - self._file_object.close() - self._file_object = None - - def get_offset(self): - """Retrieves the current offset into the file-like object. - - Returns: - int: current offset in the data range. - """ - return self._current_offset - - def get_size(self): - """Retrieves the size of the file-like object. - - Returns: - int: size of the data range. - """ - return self._range_size - - def read(self, size=None): - """Reads a byte string from the file-like object at the current offset. - - The function will read a byte string of the specified size or - all of the remaining data if no size was specified. - - Args: - size (Optional[int]): number of bytes to read, where None is all - remaining data. - - Returns: - bytes: data read. - - Raises: - IOError: if the read failed. - """ - if (self._range_offset < 0 or - (self._range_size is not None and self._range_size < 0)): - raise IOError("Invalid data range.") - - if self._current_offset < 0: - raise IOError( - "Invalid current offset: {0:d} value less than zero.".format( - self._current_offset)) - - if (self._range_size is not None and - self._current_offset >= self._range_size): - return b"" - - if size is None: - size = self._range_size - if self._range_size is not None and self._current_offset + size > self._range_size: - size = self._range_size - self._current_offset - - self._file_object.seek( - self._range_offset + self._current_offset, os.SEEK_SET) - - data = self._file_object.read(size) - - self._current_offset += len(data) - - return data - - def seek(self, offset, whence=os.SEEK_SET): - """Seeks to an offset within the file-like object. - - Args: - offset (int): offset to seek to. - whence (Optional(int)): value that indicates whether offset is an absolute - or relative position within the file. - - Raises: - IOError: if the seek failed. - """ - if self._current_offset < 0: - raise IOError( - "Invalid current offset: {0:d} value less than zero.".format( - self._current_offset)) - - if whence == os.SEEK_CUR: - offset += self._current_offset - elif whence == os.SEEK_END: - offset += self._range_size - elif whence != os.SEEK_SET: - raise IOError("Unsupported whence.") - if offset < 0: - raise IOError("Invalid offset value less than zero.") + Args: + path (str): path of the file that contains the data range. + range_offset (int): offset where the data range starts. + range_size (int): size of the data range starts, or None to indicate + the range should continue to the end of the parent file-like object. + """ + super(DataRangeFileObject, self).__init__() + self._current_offset = 0 + self._file_object = open(path, "rb") + self._range_offset = range_offset + self._range_size = range_size + + def __enter__(self): + """Enters a with statement.""" + return self + + def __exit__(self, unused_type, unused_value, unused_traceback): + """Exits a with statement.""" + return + + def close(self): + """Closes the file-like object.""" + if self._file_object: + self._file_object.close() + self._file_object = None + + def get_offset(self): + """Retrieves the current offset into the file-like object. + + Returns: + int: current offset in the data range. + """ + return self._current_offset + + def get_size(self): + """Retrieves the size of the file-like object. + + Returns: + int: size of the data range. + """ + return self._range_size + + def read(self, size=None): + """Reads a byte string from the file-like object at the current offset. + + The function will read a byte string of the specified size or + all of the remaining data if no size was specified. + + Args: + size (Optional[int]): number of bytes to read, where None is all + remaining data. + + Returns: + bytes: data read. + + Raises: + IOError: if the read failed. + """ + if self._range_offset < 0 or ( + self._range_size is not None and self._range_size < 0 + ): + raise IOError("Invalid data range.") + + if self._current_offset < 0: + raise IOError( + "Invalid current offset: {0:d} value less than zero.".format( + self._current_offset + ) + ) + + if self._range_size is not None and self._current_offset >= self._range_size: + return b"" + + if size is None: + size = self._range_size + if ( + self._range_size is not None + and self._current_offset + size > self._range_size + ): + size = self._range_size - self._current_offset + + self._file_object.seek(self._range_offset + self._current_offset, os.SEEK_SET) + + data = self._file_object.read(size) + + self._current_offset += len(data) + + return data + + def seek(self, offset, whence=os.SEEK_SET): + """Seeks to an offset within the file-like object. + + Args: + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. + + Raises: + IOError: if the seek failed. + """ + if self._current_offset < 0: + raise IOError( + "Invalid current offset: {0:d} value less than zero.".format( + self._current_offset + ) + ) + + if whence == os.SEEK_CUR: + offset += self._current_offset + elif whence == os.SEEK_END: + offset += self._range_size + elif whence != os.SEEK_SET: + raise IOError("Unsupported whence.") + if offset < 0: + raise IOError("Invalid offset value less than zero.") - self._current_offset = offset + self._current_offset = offset class VolumeTypeTests(unittest.TestCase): - """Tests the volume type.""" + """Tests the volume type.""" - def test_signal_abort(self): - """Tests the signal_abort function.""" - fshfs_volume = pyfshfs.volume() + def test_signal_abort(self): + """Tests the signal_abort function.""" + fshfs_volume = pyfshfs.volume() - fshfs_volume.signal_abort() + fshfs_volume.signal_abort() - def test_open(self): - """Tests the open function.""" - test_source = getattr(unittest, "source", None) - if not test_source: - raise unittest.SkipTest("missing source") + def test_open(self): + """Tests the open function.""" + test_source = getattr(unittest, "source", None) + if not test_source: + raise unittest.SkipTest("missing source") - test_offset = getattr(unittest, "offset", None) - if test_offset: - raise unittest.SkipTest("source defines offset") + test_offset = getattr(unittest, "offset", None) + if test_offset: + raise unittest.SkipTest("source defines offset") - fshfs_volume = pyfshfs.volume() + fshfs_volume = pyfshfs.volume() - fshfs_volume.open(test_source) + fshfs_volume.open(test_source) - with self.assertRaises(IOError): - fshfs_volume.open(test_source) + with self.assertRaises(IOError): + fshfs_volume.open(test_source) - fshfs_volume.close() + fshfs_volume.close() - with self.assertRaises(TypeError): - fshfs_volume.open(None) + with self.assertRaises(TypeError): + fshfs_volume.open(None) - with self.assertRaises(ValueError): - fshfs_volume.open(test_source, mode="w") + with self.assertRaises(ValueError): + fshfs_volume.open(test_source, mode="w") - def test_open_file_object(self): - """Tests the open_file_object function.""" - test_source = getattr(unittest, "source", None) - if not test_source: - raise unittest.SkipTest("missing source") + def test_open_file_object(self): + """Tests the open_file_object function.""" + test_source = getattr(unittest, "source", None) + if not test_source: + raise unittest.SkipTest("missing source") - if not os.path.isfile(test_source): - raise unittest.SkipTest("source not a regular file") + if not os.path.isfile(test_source): + raise unittest.SkipTest("source not a regular file") - test_offset = getattr(unittest, "offset", None) + test_offset = getattr(unittest, "offset", None) - with DataRangeFileObject( - test_source, test_offset or 0, None) as file_object: + with DataRangeFileObject(test_source, test_offset or 0, None) as file_object: - fshfs_volume = pyfshfs.volume() - fshfs_volume.open_file_object(file_object) + fshfs_volume = pyfshfs.volume() + fshfs_volume.open_file_object(file_object) - with self.assertRaises(IOError): - fshfs_volume.open_file_object(file_object) + with self.assertRaises(IOError): + fshfs_volume.open_file_object(file_object) - fshfs_volume.close() + fshfs_volume.close() - with self.assertRaises(TypeError): - fshfs_volume.open_file_object(None) + with self.assertRaises(TypeError): + fshfs_volume.open_file_object(None) - with self.assertRaises(ValueError): - fshfs_volume.open_file_object(file_object, mode="w") + with self.assertRaises(ValueError): + fshfs_volume.open_file_object(file_object, mode="w") - def test_close(self): - """Tests the close function.""" - test_source = getattr(unittest, "source", None) - if not test_source: - raise unittest.SkipTest("missing source") + def test_close(self): + """Tests the close function.""" + test_source = getattr(unittest, "source", None) + if not test_source: + raise unittest.SkipTest("missing source") - fshfs_volume = pyfshfs.volume() + fshfs_volume = pyfshfs.volume() - with self.assertRaises(IOError): - fshfs_volume.close() + with self.assertRaises(IOError): + fshfs_volume.close() - def test_open_close(self): - """Tests the open and close functions.""" - test_source = getattr(unittest, "source", None) - if not test_source: - return + def test_open_close(self): + """Tests the open and close functions.""" + test_source = getattr(unittest, "source", None) + if not test_source: + return - test_offset = getattr(unittest, "offset", None) - if test_offset: - raise unittest.SkipTest("source defines offset") + test_offset = getattr(unittest, "offset", None) + if test_offset: + raise unittest.SkipTest("source defines offset") - fshfs_volume = pyfshfs.volume() + fshfs_volume = pyfshfs.volume() - # Test open and close. - fshfs_volume.open(test_source) - fshfs_volume.close() + # Test open and close. + fshfs_volume.open(test_source) + fshfs_volume.close() - # Test open and close a second time to validate clean up on close. - fshfs_volume.open(test_source) - fshfs_volume.close() + # Test open and close a second time to validate clean up on close. + fshfs_volume.open(test_source) + fshfs_volume.close() - if os.path.isfile(test_source): - with open(test_source, "rb") as file_object: + if os.path.isfile(test_source): + with open(test_source, "rb") as file_object: - # Test open_file_object and close. - fshfs_volume.open_file_object(file_object) - fshfs_volume.close() + # Test open_file_object and close. + fshfs_volume.open_file_object(file_object) + fshfs_volume.close() - # Test open_file_object and close a second time to validate clean up on close. - fshfs_volume.open_file_object(file_object) - fshfs_volume.close() + # Test open_file_object and close a second time to validate clean up on close. + fshfs_volume.open_file_object(file_object) + fshfs_volume.close() - # Test open_file_object and close and dereferencing file_object. - fshfs_volume.open_file_object(file_object) - del file_object - fshfs_volume.close() + # Test open_file_object and close and dereferencing file_object. + fshfs_volume.open_file_object(file_object) + del file_object + fshfs_volume.close() - def test_get_name(self): - """Tests the get_name function and name property.""" - test_source = getattr(unittest, "source", None) - if not test_source: - raise unittest.SkipTest("missing source") + def test_get_name(self): + """Tests the get_name function and name property.""" + test_source = getattr(unittest, "source", None) + if not test_source: + raise unittest.SkipTest("missing source") - test_offset = getattr(unittest, "offset", None) + test_offset = getattr(unittest, "offset", None) - with DataRangeFileObject( - test_source, test_offset or 0, None) as file_object: + with DataRangeFileObject(test_source, test_offset or 0, None) as file_object: - fshfs_volume = pyfshfs.volume() - fshfs_volume.open_file_object(file_object) + fshfs_volume = pyfshfs.volume() + fshfs_volume.open_file_object(file_object) - name = fshfs_volume.get_name() - self.assertIsNotNone(name) + name = fshfs_volume.get_name() + self.assertIsNotNone(name) - self.assertIsNotNone(fshfs_volume.name) + self.assertIsNotNone(fshfs_volume.name) - fshfs_volume.close() + fshfs_volume.close() - def test_get_root_directory(self): - """Tests the get_root_directory function.""" - test_source = getattr(unittest, "source", None) - if not test_source: - raise unittest.SkipTest("missing source") + def test_get_root_directory(self): + """Tests the get_root_directory function.""" + test_source = getattr(unittest, "source", None) + if not test_source: + raise unittest.SkipTest("missing source") - test_offset = getattr(unittest, "offset", None) + test_offset = getattr(unittest, "offset", None) - with DataRangeFileObject( - test_source, test_offset or 0, None) as file_object: + with DataRangeFileObject(test_source, test_offset or 0, None) as file_object: - fshfs_volume = pyfshfs.volume() - fshfs_volume.open_file_object(file_object) + fshfs_volume = pyfshfs.volume() + fshfs_volume.open_file_object(file_object) - root_directory = fshfs_volume.get_root_directory() - self.assertIsNotNone(root_directory) + root_directory = fshfs_volume.get_root_directory() + self.assertIsNotNone(root_directory) - fshfs_volume.close() + fshfs_volume.close() if __name__ == "__main__": - argument_parser = argparse.ArgumentParser() - - argument_parser.add_argument( - "-o", "--offset", dest="offset", action="store", default=None, - type=int, help="offset of the source file.") + argument_parser = argparse.ArgumentParser() - argument_parser.add_argument( - "source", nargs="?", action="store", metavar="PATH", - default=None, help="path of the source file.") + argument_parser.add_argument( + "-o", + "--offset", + dest="offset", + action="store", + default=None, + type=int, + help="offset of the source file.", + ) + + argument_parser.add_argument( + "source", + nargs="?", + action="store", + metavar="PATH", + default=None, + help="path of the source file.", + ) - options, unknown_options = argument_parser.parse_known_args() - unknown_options.insert(0, sys.argv[0]) + options, unknown_options = argument_parser.parse_known_args() + unknown_options.insert(0, sys.argv[0]) - setattr(unittest, "offset", options.offset) - setattr(unittest, "source", options.source) + setattr(unittest, "offset", options.offset) + setattr(unittest, "source", options.source) - unittest.main(argv=unknown_options, verbosity=2) + unittest.main(argv=unknown_options, verbosity=2)
