From 9a03ce6406817238a4c9b7fc77cc9fbeac8636e1 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 7 Aug 2006 11:49:18 -0500 Subject: [svn-r12549] Description: Add support for entire heap deletion. Platforms tested: FreeBSD 4.11 (sleipnir) Linux/32 2.4 (chicago) Linux/64 2.4 (mir) Mac OS X (amazon) --- src/H5Edefin.h | 221 +- src/H5Einit.h | 757 ++--- src/H5Epubgen.h | 390 +-- src/H5Eterm.h | 225 +- src/H5FS.c | 30 +- src/H5HF.c | 94 +- src/H5HFcache.c | 3 + src/H5HFdblock.c | 68 +- src/H5HFhdr.c | 2 +- src/H5HFiblock.c | 105 +- src/H5HFpkg.h | 7 +- src/H5HFprivate.h | 3 +- src/H5HFspace.c | 35 + src/H5err.txt | 1 + test/fheap.c | 8430 +++++++++++------------------------------------------ 15 files changed, 2789 insertions(+), 7582 deletions(-) diff --git a/src/H5Edefin.h b/src/H5Edefin.h index 9b14486..434b808 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -20,56 +20,45 @@ #define _H5Edefin_H /* Major error IDs */ -hid_t H5E_NONE_MAJOR_g = FAIL; /* No error */ -hid_t H5E_RS_g = FAIL; /* Reference Counted Strings */ -hid_t H5E_CACHE_g = FAIL; /* Object cache */ -hid_t H5E_SLIST_g = FAIL; /* Skip Lists */ -hid_t H5E_STORAGE_g = FAIL; /* Data storage */ -hid_t H5E_ATOM_g = FAIL; /* Object atom */ -hid_t H5E_RESOURCE_g = FAIL; /* Resource unavailable */ -hid_t H5E_FSPACE_g = FAIL; /* Free Space Manager */ -hid_t H5E_OHDR_g = FAIL; /* Object header */ +hid_t H5E_DATASET_g = FAIL; /* Dataset */ hid_t H5E_FUNC_g = FAIL; /* Function entry/exit */ -hid_t H5E_ERROR_g = FAIL; /* Error API */ -hid_t H5E_BTREE_g = FAIL; /* B-Tree node */ -hid_t H5E_ATTR_g = FAIL; /* Attribute */ -hid_t H5E_PLIST_g = FAIL; /* Property lists */ +hid_t H5E_STORAGE_g = FAIL; /* Data storage */ +hid_t H5E_FILE_g = FAIL; /* File accessability */ hid_t H5E_SYM_g = FAIL; /* Symbol table */ -hid_t H5E_ARGS_g = FAIL; /* Invalid arguments to routine */ -hid_t H5E_HEAP_g = FAIL; /* Heap */ +hid_t H5E_VFL_g = FAIL; /* Virtual File Layer */ hid_t H5E_INTERNAL_g = FAIL; /* Internal error (too specific to document in detail) */ -hid_t H5E_FILE_g = FAIL; /* File accessability */ +hid_t H5E_BTREE_g = FAIL; /* B-Tree node */ +hid_t H5E_REFERENCE_g = FAIL; /* References */ +hid_t H5E_DATASPACE_g = FAIL; /* Dataspace */ +hid_t H5E_RESOURCE_g = FAIL; /* Resource unavailable */ +hid_t H5E_PLIST_g = FAIL; /* Property lists */ hid_t H5E_LINK_g = FAIL; /* Links */ hid_t H5E_DATATYPE_g = FAIL; /* Datatype */ -hid_t H5E_TST_g = FAIL; /* Ternary Search Trees */ +hid_t H5E_RS_g = FAIL; /* Reference Counted Strings */ +hid_t H5E_HEAP_g = FAIL; /* Heap */ +hid_t H5E_OHDR_g = FAIL; /* Object header */ +hid_t H5E_ATOM_g = FAIL; /* Object atom */ +hid_t H5E_ATTR_g = FAIL; /* Attribute */ +hid_t H5E_NONE_MAJOR_g = FAIL; /* No error */ hid_t H5E_IO_g = FAIL; /* Low-level I/O */ -hid_t H5E_DATASET_g = FAIL; /* Dataset */ -hid_t H5E_REFERENCE_g = FAIL; /* References */ +hid_t H5E_SLIST_g = FAIL; /* Skip Lists */ hid_t H5E_EFL_g = FAIL; /* External file list */ -hid_t H5E_VFL_g = FAIL; /* Virtual File Layer */ -hid_t H5E_DATASPACE_g = FAIL; /* Dataspace */ +hid_t H5E_TST_g = FAIL; /* Ternary Search Trees */ +hid_t H5E_ARGS_g = FAIL; /* Invalid arguments to routine */ +hid_t H5E_ERROR_g = FAIL; /* Error API */ hid_t H5E_PLINE_g = FAIL; /* Data filters */ +hid_t H5E_FSPACE_g = FAIL; /* Free Space Manager */ +hid_t H5E_CACHE_g = FAIL; /* Object cache */ /* Minor error IDs */ -/* System level errors */ -hid_t H5E_SYSERRSTR_g = FAIL; /* System error message */ - -/* I/O pipeline errors */ -hid_t H5E_NOFILTER_g = FAIL; /* Requested filter is not available */ -hid_t H5E_CALLBACK_g = FAIL; /* Callback failed */ -hid_t H5E_CANAPPLY_g = FAIL; /* Error from filter 'can apply' callback */ -hid_t H5E_SETLOCAL_g = FAIL; /* Error from filter 'set local' callback */ -hid_t H5E_NOENCODER_g = FAIL; /* Filter present but encoding disabled */ - -/* Object header related errors */ -hid_t H5E_LINKCOUNT_g = FAIL; /* Bad object header link count */ -hid_t H5E_VERSION_g = FAIL; /* Wrong version number */ -hid_t H5E_ALIGNMENT_g = FAIL; /* Alignment error */ -hid_t H5E_BADMESG_g = FAIL; /* Unrecognized message */ -hid_t H5E_CANTDELETE_g = FAIL; /* Can't delete message */ -hid_t H5E_BADITER_g = FAIL; /* Iteration failed */ -hid_t H5E_CANTPACK_g = FAIL; /* Can't pack messages */ +/* Generic low-level file I/O errors */ +hid_t H5E_SEEKERROR_g = FAIL; /* Seek failed */ +hid_t H5E_READERROR_g = FAIL; /* Read failed */ +hid_t H5E_WRITEERROR_g = FAIL; /* Write failed */ +hid_t H5E_CLOSEERROR_g = FAIL; /* Close failed */ +hid_t H5E_OVERFLOW_g = FAIL; /* Address overflowed */ +hid_t H5E_FCNTL_g = FAIL; /* File control (fcntl) failed */ /* Resource errors */ hid_t H5E_NOSPACE_g = FAIL; /* No space available for allocation */ @@ -81,27 +70,57 @@ hid_t H5E_CANTLOCK_g = FAIL; /* Unable to lock object */ hid_t H5E_CANTUNLOCK_g = FAIL; /* Unable to unlock object */ hid_t H5E_CANTGC_g = FAIL; /* Unable to garbage collect */ hid_t H5E_CANTGETSIZE_g = FAIL; /* Unable to compute size */ +hid_t H5E_OBJOPEN_g = FAIL; /* Object is already open */ -/* Generic low-level file I/O errors */ -hid_t H5E_SEEKERROR_g = FAIL; /* Seek failed */ -hid_t H5E_READERROR_g = FAIL; /* Read failed */ -hid_t H5E_WRITEERROR_g = FAIL; /* Write failed */ -hid_t H5E_CLOSEERROR_g = FAIL; /* Close failed */ -hid_t H5E_OVERFLOW_g = FAIL; /* Address overflowed */ -hid_t H5E_FCNTL_g = FAIL; /* File control (fcntl) failed */ +/* Heap errors */ +hid_t H5E_CANTRESTORE_g = FAIL; /* Can't restore condition */ +hid_t H5E_CANTCOMPUTE_g = FAIL; /* Can't compute value */ +hid_t H5E_CANTEXTEND_g = FAIL; /* Can't extend heap's space */ +hid_t H5E_CANTATTACH_g = FAIL; /* Can't attach object */ +hid_t H5E_CANTUPDATE_g = FAIL; /* Can't update object */ -/* B-tree related errors */ -hid_t H5E_NOTFOUND_g = FAIL; /* Object not found */ -hid_t H5E_EXISTS_g = FAIL; /* Object already exists */ -hid_t H5E_CANTENCODE_g = FAIL; /* Unable to encode value */ -hid_t H5E_CANTDECODE_g = FAIL; /* Unable to decode value */ -hid_t H5E_CANTSPLIT_g = FAIL; /* Unable to split node */ -hid_t H5E_CANTREDISTRIBUTE_g = FAIL; /* Unable to redistribute records */ -hid_t H5E_CANTSWAP_g = FAIL; /* Unable to swap records */ -hid_t H5E_CANTINSERT_g = FAIL; /* Unable to insert object */ -hid_t H5E_CANTLIST_g = FAIL; /* Unable to list node */ -hid_t H5E_CANTMODIFY_g = FAIL; /* Unable to modify record */ -hid_t H5E_CANTREMOVE_g = FAIL; /* Unable to remove object */ +/* Function entry/exit interface errors */ +hid_t H5E_CANTINIT_g = FAIL; /* Unable to initialize object */ +hid_t H5E_ALREADYINIT_g = FAIL; /* Object already initialized */ +hid_t H5E_CANTRELEASE_g = FAIL; /* Unable to release object */ + +/* Property list errors */ +hid_t H5E_CANTGET_g = FAIL; /* Can't get value */ +hid_t H5E_CANTSET_g = FAIL; /* Can't set value */ +hid_t H5E_DUPCLASS_g = FAIL; /* Duplicate class name in parent class */ + +/* Free space errors */ +hid_t H5E_CANTMERGE_g = FAIL; /* Can't merge objects */ +hid_t H5E_CANTREVIVE_g = FAIL; /* Can't revive object */ +hid_t H5E_CANTSHRINK_g = FAIL; /* Can't shrink container */ + +/* Object header related errors */ +hid_t H5E_LINKCOUNT_g = FAIL; /* Bad object header link count */ +hid_t H5E_VERSION_g = FAIL; /* Wrong version number */ +hid_t H5E_ALIGNMENT_g = FAIL; /* Alignment error */ +hid_t H5E_BADMESG_g = FAIL; /* Unrecognized message */ +hid_t H5E_CANTDELETE_g = FAIL; /* Can't delete message */ +hid_t H5E_BADITER_g = FAIL; /* Iteration failed */ +hid_t H5E_CANTPACK_g = FAIL; /* Can't pack messages */ + +/* System level errors */ +hid_t H5E_SYSERRSTR_g = FAIL; /* System error message */ + +/* I/O pipeline errors */ +hid_t H5E_NOFILTER_g = FAIL; /* Requested filter is not available */ +hid_t H5E_CALLBACK_g = FAIL; /* Callback failed */ +hid_t H5E_CANAPPLY_g = FAIL; /* Error from filter 'can apply' callback */ +hid_t H5E_SETLOCAL_g = FAIL; /* Error from filter 'set local' callback */ +hid_t H5E_NOENCODER_g = FAIL; /* Filter present but encoding disabled */ + +/* Group related errors */ +hid_t H5E_CANTOPENOBJ_g = FAIL; /* Can't open object */ +hid_t H5E_CANTCLOSEOBJ_g = FAIL; /* Can't close object */ +hid_t H5E_COMPLEN_g = FAIL; /* Name component is too long */ +hid_t H5E_PATH_g = FAIL; /* Problem with path to object */ + +/* No error */ +hid_t H5E_NONE_MINOR_g = FAIL; /* No error */ /* File accessability errors */ hid_t H5E_FILEEXISTS_g = FAIL; /* File already exists */ @@ -114,16 +133,6 @@ hid_t H5E_BADFILE_g = FAIL; /* Bad file ID accessed */ hid_t H5E_TRUNCATED_g = FAIL; /* File has been truncated */ hid_t H5E_MOUNT_g = FAIL; /* File mount error */ -/* No error */ -hid_t H5E_NONE_MINOR_g = FAIL; /* No error */ - -/* Heap errors */ -hid_t H5E_CANTRESTORE_g = FAIL; /* Can't restore condition */ -hid_t H5E_CANTCOMPUTE_g = FAIL; /* Can't compute value */ -hid_t H5E_CANTEXTEND_g = FAIL; /* Can't extend heap's space */ -hid_t H5E_CANTATTACH_g = FAIL; /* Can't attach object */ -hid_t H5E_CANTUPDATE_g = FAIL; /* Can't update object */ - /* Object atom related errors */ hid_t H5E_BADATOM_g = FAIL; /* Unable to find atom information (already closed?) */ hid_t H5E_BADGROUP_g = FAIL; /* Unable to find ID group information */ @@ -132,44 +141,6 @@ hid_t H5E_CANTINC_g = FAIL; /* Unable to increment reference count * hid_t H5E_CANTDEC_g = FAIL; /* Unable to decrement reference count */ hid_t H5E_NOIDS_g = FAIL; /* Out of IDs for group */ -/* Group related errors */ -hid_t H5E_CANTOPENOBJ_g = FAIL; /* Can't open object */ -hid_t H5E_CANTCLOSEOBJ_g = FAIL; /* Can't close object */ -hid_t H5E_COMPLEN_g = FAIL; /* Name component is too long */ -hid_t H5E_PATH_g = FAIL; /* Problem with path to object */ - -/* Property list errors */ -hid_t H5E_CANTGET_g = FAIL; /* Can't get value */ -hid_t H5E_CANTSET_g = FAIL; /* Can't set value */ -hid_t H5E_DUPCLASS_g = FAIL; /* Duplicate class name in parent class */ - -/* Function entry/exit interface errors */ -hid_t H5E_CANTINIT_g = FAIL; /* Unable to initialize object */ -hid_t H5E_ALREADYINIT_g = FAIL; /* Object already initialized */ -hid_t H5E_CANTRELEASE_g = FAIL; /* Unable to release object */ - -/* Datatype conversion errors */ -hid_t H5E_CANTCONVERT_g = FAIL; /* Can't convert datatypes */ -hid_t H5E_BADSIZE_g = FAIL; /* Bad size for object */ - -/* Link related errors */ -hid_t H5E_TRAVERSE_g = FAIL; /* Link traversal failure */ -hid_t H5E_NLINKS_g = FAIL; /* Too many soft links in path */ -hid_t H5E_NOTREGISTERED_g = FAIL; /* Link class not registered */ -hid_t H5E_CANTMOVE_g = FAIL; /* Move callback returned error */ - -/* Parallel MPI errors */ -hid_t H5E_MPI_g = FAIL; /* Some MPI function failed */ -hid_t H5E_MPIERRSTR_g = FAIL; /* MPI Error String */ -hid_t H5E_CANTRECV_g = FAIL; /* Can't receive data */ - -/* Argument errors */ -hid_t H5E_UNINITIALIZED_g = FAIL; /* Information is uinitialized */ -hid_t H5E_UNSUPPORTED_g = FAIL; /* Feature is unsupported */ -hid_t H5E_BADTYPE_g = FAIL; /* Inappropriate type */ -hid_t H5E_BADRANGE_g = FAIL; /* Out of range */ -hid_t H5E_BADVALUE_g = FAIL; /* Bad value */ - /* Cache related errors */ hid_t H5E_CANTFLUSH_g = FAIL; /* Unable to flush data from cache */ hid_t H5E_CANTSERIALIZE_g = FAIL; /* Unable to serialize data from cache */ @@ -188,10 +159,16 @@ hid_t H5E_CANTDIRTY_g = FAIL; /* Unable to mark metadata as dirty */ hid_t H5E_CANTEXPUNGE_g = FAIL; /* Unable to expunge a metadata cache entry */ hid_t H5E_CANTRESIZE_g = FAIL; /* Unable to resize a metadata cache entry */ -/* Free space errors */ -hid_t H5E_CANTMERGE_g = FAIL; /* Can't merge objects */ -hid_t H5E_CANTREVIVE_g = FAIL; /* Can't revive object */ -hid_t H5E_CANTSHRINK_g = FAIL; /* Can't shrink container */ +/* Link related errors */ +hid_t H5E_TRAVERSE_g = FAIL; /* Link traversal failure */ +hid_t H5E_NLINKS_g = FAIL; /* Too many soft links in path */ +hid_t H5E_NOTREGISTERED_g = FAIL; /* Link class not registered */ +hid_t H5E_CANTMOVE_g = FAIL; /* Move callback returned error */ + +/* Parallel MPI errors */ +hid_t H5E_MPI_g = FAIL; /* Some MPI function failed */ +hid_t H5E_MPIERRSTR_g = FAIL; /* MPI Error String */ +hid_t H5E_CANTRECV_g = FAIL; /* Can't receive data */ /* Dataspace errors */ hid_t H5E_CANTCLIP_g = FAIL; /* Can't clip hyperslab region */ @@ -201,4 +178,28 @@ hid_t H5E_CANTNEXT_g = FAIL; /* Can't move to next iterator location hid_t H5E_BADSELECT_g = FAIL; /* Invalid selection */ hid_t H5E_CANTCOMPARE_g = FAIL; /* Can't compare objects */ +/* Argument errors */ +hid_t H5E_UNINITIALIZED_g = FAIL; /* Information is uinitialized */ +hid_t H5E_UNSUPPORTED_g = FAIL; /* Feature is unsupported */ +hid_t H5E_BADTYPE_g = FAIL; /* Inappropriate type */ +hid_t H5E_BADRANGE_g = FAIL; /* Out of range */ +hid_t H5E_BADVALUE_g = FAIL; /* Bad value */ + +/* B-tree related errors */ +hid_t H5E_NOTFOUND_g = FAIL; /* Object not found */ +hid_t H5E_EXISTS_g = FAIL; /* Object already exists */ +hid_t H5E_CANTENCODE_g = FAIL; /* Unable to encode value */ +hid_t H5E_CANTDECODE_g = FAIL; /* Unable to decode value */ +hid_t H5E_CANTSPLIT_g = FAIL; /* Unable to split node */ +hid_t H5E_CANTREDISTRIBUTE_g = FAIL; /* Unable to redistribute records */ +hid_t H5E_CANTSWAP_g = FAIL; /* Unable to swap records */ +hid_t H5E_CANTINSERT_g = FAIL; /* Unable to insert object */ +hid_t H5E_CANTLIST_g = FAIL; /* Unable to list node */ +hid_t H5E_CANTMODIFY_g = FAIL; /* Unable to modify record */ +hid_t H5E_CANTREMOVE_g = FAIL; /* Unable to remove object */ + +/* Datatype conversion errors */ +hid_t H5E_CANTCONVERT_g = FAIL; /* Can't convert datatypes */ +hid_t H5E_BADSIZE_g = FAIL; /* Bad size for object */ + #endif /* H5Edefin_H */ diff --git a/src/H5Einit.h b/src/H5Einit.h index c62282e..21aefc5 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -23,226 +23,187 @@ /* Major error codes */ /*********************/ -assert(H5E_NONE_MAJOR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "No error"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NONE_MAJOR_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_RS_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Reference Counted Strings"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_RS_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CACHE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Object cache"))==NULL) +assert(H5E_DATASET_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Dataset"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CACHE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_DATASET_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_SLIST_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Skip Lists"))==NULL) +assert(H5E_FUNC_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Function entry/exit"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_SLIST_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_FUNC_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_STORAGE_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Data storage"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_STORAGE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_ATOM_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Object atom"))==NULL) +assert(H5E_FILE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "File accessability"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_ATOM_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_FILE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_RESOURCE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Resource unavailable"))==NULL) +assert(H5E_SYM_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Symbol table"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_RESOURCE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_SYM_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_FSPACE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Free Space Manager"))==NULL) +assert(H5E_VFL_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Virtual File Layer"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_FSPACE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_VFL_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_OHDR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Object header"))==NULL) +assert(H5E_INTERNAL_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Internal error (too specific to document in detail)"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_OHDR_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_INTERNAL_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_FUNC_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Function entry/exit"))==NULL) +assert(H5E_BTREE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "B-Tree node"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_FUNC_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_BTREE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_ERROR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Error API"))==NULL) +assert(H5E_REFERENCE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "References"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_ERROR_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_REFERENCE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_BTREE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "B-Tree node"))==NULL) +assert(H5E_DATASPACE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Dataspace"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BTREE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_DATASPACE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_ATTR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Attribute"))==NULL) +assert(H5E_RESOURCE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Resource unavailable"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_ATTR_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_RESOURCE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_PLIST_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Property lists"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_PLIST_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_SYM_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Symbol table"))==NULL) +assert(H5E_LINK_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Links"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_SYM_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_LINK_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_ARGS_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Invalid arguments to routine"))==NULL) +assert(H5E_DATATYPE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Datatype"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_ARGS_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_DATATYPE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_RS_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Reference Counted Strings"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_RS_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_HEAP_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Heap"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_HEAP_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_INTERNAL_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Internal error (too specific to document in detail)"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_INTERNAL_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_FILE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "File accessability"))==NULL) +assert(H5E_OHDR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Object header"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_FILE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_OHDR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_LINK_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Links"))==NULL) +assert(H5E_ATOM_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Object atom"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_LINK_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_ATOM_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_DATATYPE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Datatype"))==NULL) +assert(H5E_ATTR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Attribute"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_DATATYPE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_ATTR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_TST_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Ternary Search Trees"))==NULL) +assert(H5E_NONE_MAJOR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "No error"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_TST_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_NONE_MAJOR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_IO_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Low-level I/O"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_IO_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_DATASET_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Dataset"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_DATASET_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_REFERENCE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "References"))==NULL) +assert(H5E_SLIST_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Skip Lists"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_REFERENCE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_SLIST_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_EFL_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "External file list"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_EFL_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_VFL_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Virtual File Layer"))==NULL) +assert(H5E_TST_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Ternary Search Trees"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_VFL_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_TST_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_DATASPACE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Dataspace"))==NULL) +assert(H5E_ARGS_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Invalid arguments to routine"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_DATASPACE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_ARGS_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_ERROR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Error API"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_ERROR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_PLINE_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Data filters"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_PLINE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_FSPACE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Free Space Manager"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_FSPACE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CACHE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Object cache"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CACHE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") /*********************/ /* Minor error codes */ /*********************/ -/* System level errors */ -assert(H5E_SYSERRSTR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "System error message"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_SYSERRSTR_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") - -/* I/O pipeline errors */ -assert(H5E_NOFILTER_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Requested filter is not available"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NOFILTER_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CALLBACK_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Callback failed"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CALLBACK_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANAPPLY_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Error from filter 'can apply' callback"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANAPPLY_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_SETLOCAL_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Error from filter 'set local' callback"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_SETLOCAL_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_NOENCODER_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Filter present but encoding disabled"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NOENCODER_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") - -/* Object header related errors */ -assert(H5E_LINKCOUNT_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Bad object header link count"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_LINKCOUNT_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_VERSION_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Wrong version number"))==NULL) +/* Generic low-level file I/O errors */ +assert(H5E_SEEKERROR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Seek failed"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_VERSION_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_SEEKERROR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_ALIGNMENT_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Alignment error"))==NULL) +assert(H5E_READERROR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Read failed"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_ALIGNMENT_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_READERROR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_BADMESG_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unrecognized message"))==NULL) +assert(H5E_WRITEERROR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Write failed"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BADMESG_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_WRITEERROR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTDELETE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't delete message"))==NULL) +assert(H5E_CLOSEERROR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Close failed"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTDELETE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CLOSEERROR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_BADITER_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Iteration failed"))==NULL) +assert(H5E_OVERFLOW_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Address overflowed"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BADITER_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_OVERFLOW_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTPACK_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't pack messages"))==NULL) +assert(H5E_FCNTL_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "File control (fcntl) failed"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTPACK_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_FCNTL_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") /* Resource errors */ @@ -291,207 +252,159 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to compute size"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_CANTGETSIZE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") - -/* Generic low-level file I/O errors */ -assert(H5E_SEEKERROR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Seek failed"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_SEEKERROR_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_READERROR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Read failed"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_READERROR_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_WRITEERROR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Write failed"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_WRITEERROR_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CLOSEERROR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Close failed"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CLOSEERROR_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_OVERFLOW_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Address overflowed"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_OVERFLOW_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_FCNTL_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "File control (fcntl) failed"))==NULL) +assert(H5E_OBJOPEN_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Object is already open"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_FCNTL_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_OBJOPEN_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -/* B-tree related errors */ -assert(H5E_NOTFOUND_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Object not found"))==NULL) +/* Heap errors */ +assert(H5E_CANTRESTORE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't restore condition"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NOTFOUND_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTRESTORE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_EXISTS_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Object already exists"))==NULL) +assert(H5E_CANTCOMPUTE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't compute value"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_EXISTS_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTCOMPUTE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTENCODE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to encode value"))==NULL) +assert(H5E_CANTEXTEND_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't extend heap's space"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTENCODE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTEXTEND_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTDECODE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to decode value"))==NULL) +assert(H5E_CANTATTACH_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't attach object"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTDECODE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTATTACH_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTSPLIT_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to split node"))==NULL) +assert(H5E_CANTUPDATE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't update object"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTSPLIT_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTUPDATE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTREDISTRIBUTE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to redistribute records"))==NULL) + +/* Function entry/exit interface errors */ +assert(H5E_CANTINIT_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to initialize object"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTREDISTRIBUTE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTINIT_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTSWAP_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to swap records"))==NULL) +assert(H5E_ALREADYINIT_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Object already initialized"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTSWAP_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_ALREADYINIT_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTINSERT_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to insert object"))==NULL) +assert(H5E_CANTRELEASE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to release object"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTINSERT_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTRELEASE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTLIST_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to list node"))==NULL) + +/* Property list errors */ +assert(H5E_CANTGET_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't get value"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTLIST_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTGET_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTMODIFY_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to modify record"))==NULL) +assert(H5E_CANTSET_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't set value"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTMODIFY_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTSET_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTREMOVE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to remove object"))==NULL) +assert(H5E_DUPCLASS_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Duplicate class name in parent class"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTREMOVE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_DUPCLASS_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -/* File accessability errors */ -assert(H5E_FILEEXISTS_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "File already exists"))==NULL) +/* Free space errors */ +assert(H5E_CANTMERGE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't merge objects"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_FILEEXISTS_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTMERGE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_FILEOPEN_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "File already open"))==NULL) +assert(H5E_CANTREVIVE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't revive object"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_FILEOPEN_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTREVIVE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTCREATE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to create file"))==NULL) +assert(H5E_CANTSHRINK_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't shrink container"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTCREATE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTSHRINK_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTOPENFILE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to open file"))==NULL) + +/* Object header related errors */ +assert(H5E_LINKCOUNT_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Bad object header link count"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTOPENFILE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_LINKCOUNT_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTCLOSEFILE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to close file"))==NULL) +assert(H5E_VERSION_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Wrong version number"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTCLOSEFILE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_VERSION_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_NOTHDF5_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Not an HDF5 file"))==NULL) +assert(H5E_ALIGNMENT_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Alignment error"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NOTHDF5_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_ALIGNMENT_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_BADFILE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Bad file ID accessed"))==NULL) +assert(H5E_BADMESG_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unrecognized message"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BADFILE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_BADMESG_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_TRUNCATED_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "File has been truncated"))==NULL) +assert(H5E_CANTDELETE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't delete message"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_TRUNCATED_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTDELETE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_MOUNT_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "File mount error"))==NULL) +assert(H5E_BADITER_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Iteration failed"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_MOUNT_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_BADITER_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") - -/* No error */ -assert(H5E_NONE_MINOR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "No error"))==NULL) +assert(H5E_CANTPACK_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't pack messages"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NONE_MINOR_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTPACK_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -/* Heap errors */ -assert(H5E_CANTRESTORE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't restore condition"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTRESTORE_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTCOMPUTE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't compute value"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTCOMPUTE_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTEXTEND_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't extend heap's space"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTEXTEND_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTATTACH_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't attach object"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTATTACH_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTUPDATE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't update object"))==NULL) +/* System level errors */ +assert(H5E_SYSERRSTR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "System error message"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTUPDATE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_SYSERRSTR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -/* Object atom related errors */ -assert(H5E_BADATOM_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to find atom information (already closed?)"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BADATOM_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_BADGROUP_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to find ID group information"))==NULL) +/* I/O pipeline errors */ +assert(H5E_NOFILTER_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Requested filter is not available"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BADGROUP_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_NOFILTER_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTREGISTER_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to register new atom"))==NULL) +assert(H5E_CALLBACK_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Callback failed"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTREGISTER_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CALLBACK_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTINC_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to increment reference count"))==NULL) +assert(H5E_CANAPPLY_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Error from filter 'can apply' callback"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTINC_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANAPPLY_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTDEC_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to decrement reference count"))==NULL) +assert(H5E_SETLOCAL_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Error from filter 'set local' callback"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTDEC_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_SETLOCAL_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_NOIDS_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Out of IDs for group"))==NULL) +assert(H5E_NOENCODER_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Filter present but encoding disabled"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NOIDS_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_NOENCODER_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") /* Group related errors */ @@ -503,129 +416,103 @@ if((H5E_CANTOPENOBJ_g = H5I_register(H5I_ERROR_MSG, msg))<0) assert(H5E_CANTCLOSEOBJ_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't close object"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTCLOSEOBJ_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_COMPLEN_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Name component is too long"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_COMPLEN_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_PATH_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Problem with path to object"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_PATH_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") - -/* Property list errors */ -assert(H5E_CANTGET_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't get value"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTGET_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTSET_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't set value"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTSET_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_DUPCLASS_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Duplicate class name in parent class"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_DUPCLASS_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") - -/* Function entry/exit interface errors */ -assert(H5E_CANTINIT_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to initialize object"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTINIT_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTCLOSEOBJ_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_ALREADYINIT_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Object already initialized"))==NULL) +assert(H5E_COMPLEN_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Name component is too long"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_ALREADYINIT_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_COMPLEN_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTRELEASE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to release object"))==NULL) +assert(H5E_PATH_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Problem with path to object"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTRELEASE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_PATH_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -/* Datatype conversion errors */ -assert(H5E_CANTCONVERT_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't convert datatypes"))==NULL) +/* No error */ +assert(H5E_NONE_MINOR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "No error"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTCONVERT_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_NONE_MINOR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_BADSIZE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Bad size for object"))==NULL) + +/* File accessability errors */ +assert(H5E_FILEEXISTS_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "File already exists"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BADSIZE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_FILEEXISTS_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") - -/* Link related errors */ -assert(H5E_TRAVERSE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Link traversal failure"))==NULL) +assert(H5E_FILEOPEN_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "File already open"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_TRAVERSE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_FILEOPEN_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_NLINKS_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Too many soft links in path"))==NULL) +assert(H5E_CANTCREATE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to create file"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NLINKS_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTCREATE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_NOTREGISTERED_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Link class not registered"))==NULL) +assert(H5E_CANTOPENFILE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to open file"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NOTREGISTERED_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTOPENFILE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTMOVE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Move callback returned error"))==NULL) +assert(H5E_CANTCLOSEFILE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to close file"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTMOVE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTCLOSEFILE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") - -/* Parallel MPI errors */ -assert(H5E_MPI_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Some MPI function failed"))==NULL) +assert(H5E_NOTHDF5_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Not an HDF5 file"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_MPI_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_NOTHDF5_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_MPIERRSTR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "MPI Error String"))==NULL) +assert(H5E_BADFILE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Bad file ID accessed"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_MPIERRSTR_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_BADFILE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTRECV_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't receive data"))==NULL) +assert(H5E_TRUNCATED_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "File has been truncated"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTRECV_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_TRUNCATED_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_MOUNT_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "File mount error"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_MOUNT_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -/* Argument errors */ -assert(H5E_UNINITIALIZED_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Information is uinitialized"))==NULL) +/* Object atom related errors */ +assert(H5E_BADATOM_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to find atom information (already closed?)"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_UNINITIALIZED_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_BADATOM_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_UNSUPPORTED_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Feature is unsupported"))==NULL) +assert(H5E_BADGROUP_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to find ID group information"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_UNSUPPORTED_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_BADGROUP_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_BADTYPE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Inappropriate type"))==NULL) +assert(H5E_CANTREGISTER_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to register new atom"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BADTYPE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTREGISTER_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_BADRANGE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Out of range"))==NULL) +assert(H5E_CANTINC_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to increment reference count"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BADRANGE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTINC_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_BADVALUE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Bad value"))==NULL) +assert(H5E_CANTDEC_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to decrement reference count"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BADVALUE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_CANTDEC_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_NOIDS_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Out of IDs for group"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_NOIDS_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") /* Cache related errors */ @@ -710,21 +597,43 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to resize a metadata cache entr if((H5E_CANTRESIZE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -/* Free space errors */ -assert(H5E_CANTMERGE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't merge objects"))==NULL) +/* Link related errors */ +assert(H5E_TRAVERSE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Link traversal failure"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTMERGE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_TRAVERSE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTREVIVE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't revive object"))==NULL) +assert(H5E_NLINKS_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Too many soft links in path"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTREVIVE_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_NLINKS_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTSHRINK_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't shrink container"))==NULL) +assert(H5E_NOTREGISTERED_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Link class not registered"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTSHRINK_g = H5I_register(H5I_ERROR_MSG, msg))<0) +if((H5E_NOTREGISTERED_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTMOVE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Move callback returned error"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTMOVE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") + +/* Parallel MPI errors */ +assert(H5E_MPI_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Some MPI function failed"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_MPI_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_MPIERRSTR_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "MPI Error String"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_MPIERRSTR_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTRECV_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't receive data"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTRECV_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") /* Dataspace errors */ @@ -759,4 +668,100 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't compare objects"))==NULL) if((H5E_CANTCOMPARE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +/* Argument errors */ +assert(H5E_UNINITIALIZED_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Information is uinitialized"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_UNINITIALIZED_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_UNSUPPORTED_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Feature is unsupported"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_UNSUPPORTED_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_BADTYPE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Inappropriate type"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_BADTYPE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_BADRANGE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Out of range"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_BADRANGE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_BADVALUE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Bad value"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_BADVALUE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") + +/* B-tree related errors */ +assert(H5E_NOTFOUND_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Object not found"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_NOTFOUND_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_EXISTS_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Object already exists"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_EXISTS_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTENCODE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to encode value"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTENCODE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTDECODE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to decode value"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTDECODE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTSPLIT_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to split node"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTSPLIT_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTREDISTRIBUTE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to redistribute records"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTREDISTRIBUTE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTSWAP_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to swap records"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTSWAP_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTINSERT_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to insert object"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTINSERT_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTLIST_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to list node"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTLIST_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTMODIFY_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to modify record"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTMODIFY_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTREMOVE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to remove object"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTREMOVE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") + +/* Datatype conversion errors */ +assert(H5E_CANTCONVERT_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't convert datatypes"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTCONVERT_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_BADSIZE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Bad size for object"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_BADSIZE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") + #endif /* H5Einit_H */ diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index 7c53b8f..8bb8b3c 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -23,100 +23,82 @@ /* Major error codes */ /*********************/ -#define H5E_NONE_MAJOR (H5OPEN H5E_NONE_MAJOR_g) -#define H5E_RS (H5OPEN H5E_RS_g) -#define H5E_CACHE (H5OPEN H5E_CACHE_g) -#define H5E_SLIST (H5OPEN H5E_SLIST_g) -#define H5E_STORAGE (H5OPEN H5E_STORAGE_g) -#define H5E_ATOM (H5OPEN H5E_ATOM_g) -#define H5E_RESOURCE (H5OPEN H5E_RESOURCE_g) -#define H5E_FSPACE (H5OPEN H5E_FSPACE_g) -#define H5E_OHDR (H5OPEN H5E_OHDR_g) +#define H5E_DATASET (H5OPEN H5E_DATASET_g) #define H5E_FUNC (H5OPEN H5E_FUNC_g) -#define H5E_ERROR (H5OPEN H5E_ERROR_g) -#define H5E_BTREE (H5OPEN H5E_BTREE_g) -#define H5E_ATTR (H5OPEN H5E_ATTR_g) -#define H5E_PLIST (H5OPEN H5E_PLIST_g) +#define H5E_STORAGE (H5OPEN H5E_STORAGE_g) +#define H5E_FILE (H5OPEN H5E_FILE_g) #define H5E_SYM (H5OPEN H5E_SYM_g) -#define H5E_ARGS (H5OPEN H5E_ARGS_g) -#define H5E_HEAP (H5OPEN H5E_HEAP_g) +#define H5E_VFL (H5OPEN H5E_VFL_g) #define H5E_INTERNAL (H5OPEN H5E_INTERNAL_g) -#define H5E_FILE (H5OPEN H5E_FILE_g) +#define H5E_BTREE (H5OPEN H5E_BTREE_g) +#define H5E_REFERENCE (H5OPEN H5E_REFERENCE_g) +#define H5E_DATASPACE (H5OPEN H5E_DATASPACE_g) +#define H5E_RESOURCE (H5OPEN H5E_RESOURCE_g) +#define H5E_PLIST (H5OPEN H5E_PLIST_g) #define H5E_LINK (H5OPEN H5E_LINK_g) #define H5E_DATATYPE (H5OPEN H5E_DATATYPE_g) -#define H5E_TST (H5OPEN H5E_TST_g) +#define H5E_RS (H5OPEN H5E_RS_g) +#define H5E_HEAP (H5OPEN H5E_HEAP_g) +#define H5E_OHDR (H5OPEN H5E_OHDR_g) +#define H5E_ATOM (H5OPEN H5E_ATOM_g) +#define H5E_ATTR (H5OPEN H5E_ATTR_g) +#define H5E_NONE_MAJOR (H5OPEN H5E_NONE_MAJOR_g) #define H5E_IO (H5OPEN H5E_IO_g) -#define H5E_DATASET (H5OPEN H5E_DATASET_g) -#define H5E_REFERENCE (H5OPEN H5E_REFERENCE_g) +#define H5E_SLIST (H5OPEN H5E_SLIST_g) #define H5E_EFL (H5OPEN H5E_EFL_g) -#define H5E_VFL (H5OPEN H5E_VFL_g) -#define H5E_DATASPACE (H5OPEN H5E_DATASPACE_g) +#define H5E_TST (H5OPEN H5E_TST_g) +#define H5E_ARGS (H5OPEN H5E_ARGS_g) +#define H5E_ERROR (H5OPEN H5E_ERROR_g) #define H5E_PLINE (H5OPEN H5E_PLINE_g) -H5_DLLVAR hid_t H5E_NONE_MAJOR_g; /* No error */ -H5_DLLVAR hid_t H5E_RS_g; /* Reference Counted Strings */ -H5_DLLVAR hid_t H5E_CACHE_g; /* Object cache */ -H5_DLLVAR hid_t H5E_SLIST_g; /* Skip Lists */ -H5_DLLVAR hid_t H5E_STORAGE_g; /* Data storage */ -H5_DLLVAR hid_t H5E_ATOM_g; /* Object atom */ -H5_DLLVAR hid_t H5E_RESOURCE_g; /* Resource unavailable */ -H5_DLLVAR hid_t H5E_FSPACE_g; /* Free Space Manager */ -H5_DLLVAR hid_t H5E_OHDR_g; /* Object header */ +#define H5E_FSPACE (H5OPEN H5E_FSPACE_g) +#define H5E_CACHE (H5OPEN H5E_CACHE_g) +H5_DLLVAR hid_t H5E_DATASET_g; /* Dataset */ H5_DLLVAR hid_t H5E_FUNC_g; /* Function entry/exit */ -H5_DLLVAR hid_t H5E_ERROR_g; /* Error API */ -H5_DLLVAR hid_t H5E_BTREE_g; /* B-Tree node */ -H5_DLLVAR hid_t H5E_ATTR_g; /* Attribute */ -H5_DLLVAR hid_t H5E_PLIST_g; /* Property lists */ +H5_DLLVAR hid_t H5E_STORAGE_g; /* Data storage */ +H5_DLLVAR hid_t H5E_FILE_g; /* File accessability */ H5_DLLVAR hid_t H5E_SYM_g; /* Symbol table */ -H5_DLLVAR hid_t H5E_ARGS_g; /* Invalid arguments to routine */ -H5_DLLVAR hid_t H5E_HEAP_g; /* Heap */ +H5_DLLVAR hid_t H5E_VFL_g; /* Virtual File Layer */ H5_DLLVAR hid_t H5E_INTERNAL_g; /* Internal error (too specific to document in detail) */ -H5_DLLVAR hid_t H5E_FILE_g; /* File accessability */ +H5_DLLVAR hid_t H5E_BTREE_g; /* B-Tree node */ +H5_DLLVAR hid_t H5E_REFERENCE_g; /* References */ +H5_DLLVAR hid_t H5E_DATASPACE_g; /* Dataspace */ +H5_DLLVAR hid_t H5E_RESOURCE_g; /* Resource unavailable */ +H5_DLLVAR hid_t H5E_PLIST_g; /* Property lists */ H5_DLLVAR hid_t H5E_LINK_g; /* Links */ H5_DLLVAR hid_t H5E_DATATYPE_g; /* Datatype */ -H5_DLLVAR hid_t H5E_TST_g; /* Ternary Search Trees */ +H5_DLLVAR hid_t H5E_RS_g; /* Reference Counted Strings */ +H5_DLLVAR hid_t H5E_HEAP_g; /* Heap */ +H5_DLLVAR hid_t H5E_OHDR_g; /* Object header */ +H5_DLLVAR hid_t H5E_ATOM_g; /* Object atom */ +H5_DLLVAR hid_t H5E_ATTR_g; /* Attribute */ +H5_DLLVAR hid_t H5E_NONE_MAJOR_g; /* No error */ H5_DLLVAR hid_t H5E_IO_g; /* Low-level I/O */ -H5_DLLVAR hid_t H5E_DATASET_g; /* Dataset */ -H5_DLLVAR hid_t H5E_REFERENCE_g; /* References */ +H5_DLLVAR hid_t H5E_SLIST_g; /* Skip Lists */ H5_DLLVAR hid_t H5E_EFL_g; /* External file list */ -H5_DLLVAR hid_t H5E_VFL_g; /* Virtual File Layer */ -H5_DLLVAR hid_t H5E_DATASPACE_g; /* Dataspace */ +H5_DLLVAR hid_t H5E_TST_g; /* Ternary Search Trees */ +H5_DLLVAR hid_t H5E_ARGS_g; /* Invalid arguments to routine */ +H5_DLLVAR hid_t H5E_ERROR_g; /* Error API */ H5_DLLVAR hid_t H5E_PLINE_g; /* Data filters */ +H5_DLLVAR hid_t H5E_FSPACE_g; /* Free Space Manager */ +H5_DLLVAR hid_t H5E_CACHE_g; /* Object cache */ /*********************/ /* Minor error codes */ /*********************/ -/* System level errors */ -#define H5E_SYSERRSTR (H5OPEN H5E_SYSERRSTR_g) -H5_DLLVAR hid_t H5E_SYSERRSTR_g; /* System error message */ - -/* I/O pipeline errors */ -#define H5E_NOFILTER (H5OPEN H5E_NOFILTER_g) -#define H5E_CALLBACK (H5OPEN H5E_CALLBACK_g) -#define H5E_CANAPPLY (H5OPEN H5E_CANAPPLY_g) -#define H5E_SETLOCAL (H5OPEN H5E_SETLOCAL_g) -#define H5E_NOENCODER (H5OPEN H5E_NOENCODER_g) -H5_DLLVAR hid_t H5E_NOFILTER_g; /* Requested filter is not available */ -H5_DLLVAR hid_t H5E_CALLBACK_g; /* Callback failed */ -H5_DLLVAR hid_t H5E_CANAPPLY_g; /* Error from filter 'can apply' callback */ -H5_DLLVAR hid_t H5E_SETLOCAL_g; /* Error from filter 'set local' callback */ -H5_DLLVAR hid_t H5E_NOENCODER_g; /* Filter present but encoding disabled */ - -/* Object header related errors */ -#define H5E_LINKCOUNT (H5OPEN H5E_LINKCOUNT_g) -#define H5E_VERSION (H5OPEN H5E_VERSION_g) -#define H5E_ALIGNMENT (H5OPEN H5E_ALIGNMENT_g) -#define H5E_BADMESG (H5OPEN H5E_BADMESG_g) -#define H5E_CANTDELETE (H5OPEN H5E_CANTDELETE_g) -#define H5E_BADITER (H5OPEN H5E_BADITER_g) -#define H5E_CANTPACK (H5OPEN H5E_CANTPACK_g) -H5_DLLVAR hid_t H5E_LINKCOUNT_g; /* Bad object header link count */ -H5_DLLVAR hid_t H5E_VERSION_g; /* Wrong version number */ -H5_DLLVAR hid_t H5E_ALIGNMENT_g; /* Alignment error */ -H5_DLLVAR hid_t H5E_BADMESG_g; /* Unrecognized message */ -H5_DLLVAR hid_t H5E_CANTDELETE_g; /* Can't delete message */ -H5_DLLVAR hid_t H5E_BADITER_g; /* Iteration failed */ -H5_DLLVAR hid_t H5E_CANTPACK_g; /* Can't pack messages */ +/* Generic low-level file I/O errors */ +#define H5E_SEEKERROR (H5OPEN H5E_SEEKERROR_g) +#define H5E_READERROR (H5OPEN H5E_READERROR_g) +#define H5E_WRITEERROR (H5OPEN H5E_WRITEERROR_g) +#define H5E_CLOSEERROR (H5OPEN H5E_CLOSEERROR_g) +#define H5E_OVERFLOW (H5OPEN H5E_OVERFLOW_g) +#define H5E_FCNTL (H5OPEN H5E_FCNTL_g) +H5_DLLVAR hid_t H5E_SEEKERROR_g; /* Seek failed */ +H5_DLLVAR hid_t H5E_READERROR_g; /* Read failed */ +H5_DLLVAR hid_t H5E_WRITEERROR_g; /* Write failed */ +H5_DLLVAR hid_t H5E_CLOSEERROR_g; /* Close failed */ +H5_DLLVAR hid_t H5E_OVERFLOW_g; /* Address overflowed */ +H5_DLLVAR hid_t H5E_FCNTL_g; /* File control (fcntl) failed */ /* Resource errors */ #define H5E_NOSPACE (H5OPEN H5E_NOSPACE_g) @@ -128,6 +110,7 @@ H5_DLLVAR hid_t H5E_CANTPACK_g; /* Can't pack messages */ #define H5E_CANTUNLOCK (H5OPEN H5E_CANTUNLOCK_g) #define H5E_CANTGC (H5OPEN H5E_CANTGC_g) #define H5E_CANTGETSIZE (H5OPEN H5E_CANTGETSIZE_g) +#define H5E_OBJOPEN (H5OPEN H5E_OBJOPEN_g) H5_DLLVAR hid_t H5E_NOSPACE_g; /* No space available for allocation */ H5_DLLVAR hid_t H5E_CANTALLOC_g; /* Can't allocate space */ H5_DLLVAR hid_t H5E_CANTCOPY_g; /* Unable to copy object */ @@ -137,44 +120,89 @@ H5_DLLVAR hid_t H5E_CANTLOCK_g; /* Unable to lock object */ H5_DLLVAR hid_t H5E_CANTUNLOCK_g; /* Unable to unlock object */ H5_DLLVAR hid_t H5E_CANTGC_g; /* Unable to garbage collect */ H5_DLLVAR hid_t H5E_CANTGETSIZE_g; /* Unable to compute size */ +H5_DLLVAR hid_t H5E_OBJOPEN_g; /* Object is already open */ -/* Generic low-level file I/O errors */ -#define H5E_SEEKERROR (H5OPEN H5E_SEEKERROR_g) -#define H5E_READERROR (H5OPEN H5E_READERROR_g) -#define H5E_WRITEERROR (H5OPEN H5E_WRITEERROR_g) -#define H5E_CLOSEERROR (H5OPEN H5E_CLOSEERROR_g) -#define H5E_OVERFLOW (H5OPEN H5E_OVERFLOW_g) -#define H5E_FCNTL (H5OPEN H5E_FCNTL_g) -H5_DLLVAR hid_t H5E_SEEKERROR_g; /* Seek failed */ -H5_DLLVAR hid_t H5E_READERROR_g; /* Read failed */ -H5_DLLVAR hid_t H5E_WRITEERROR_g; /* Write failed */ -H5_DLLVAR hid_t H5E_CLOSEERROR_g; /* Close failed */ -H5_DLLVAR hid_t H5E_OVERFLOW_g; /* Address overflowed */ -H5_DLLVAR hid_t H5E_FCNTL_g; /* File control (fcntl) failed */ +/* Heap errors */ +#define H5E_CANTRESTORE (H5OPEN H5E_CANTRESTORE_g) +#define H5E_CANTCOMPUTE (H5OPEN H5E_CANTCOMPUTE_g) +#define H5E_CANTEXTEND (H5OPEN H5E_CANTEXTEND_g) +#define H5E_CANTATTACH (H5OPEN H5E_CANTATTACH_g) +#define H5E_CANTUPDATE (H5OPEN H5E_CANTUPDATE_g) +H5_DLLVAR hid_t H5E_CANTRESTORE_g; /* Can't restore condition */ +H5_DLLVAR hid_t H5E_CANTCOMPUTE_g; /* Can't compute value */ +H5_DLLVAR hid_t H5E_CANTEXTEND_g; /* Can't extend heap's space */ +H5_DLLVAR hid_t H5E_CANTATTACH_g; /* Can't attach object */ +H5_DLLVAR hid_t H5E_CANTUPDATE_g; /* Can't update object */ -/* B-tree related errors */ -#define H5E_NOTFOUND (H5OPEN H5E_NOTFOUND_g) -#define H5E_EXISTS (H5OPEN H5E_EXISTS_g) -#define H5E_CANTENCODE (H5OPEN H5E_CANTENCODE_g) -#define H5E_CANTDECODE (H5OPEN H5E_CANTDECODE_g) -#define H5E_CANTSPLIT (H5OPEN H5E_CANTSPLIT_g) -#define H5E_CANTREDISTRIBUTE (H5OPEN H5E_CANTREDISTRIBUTE_g) -#define H5E_CANTSWAP (H5OPEN H5E_CANTSWAP_g) -#define H5E_CANTINSERT (H5OPEN H5E_CANTINSERT_g) -#define H5E_CANTLIST (H5OPEN H5E_CANTLIST_g) -#define H5E_CANTMODIFY (H5OPEN H5E_CANTMODIFY_g) -#define H5E_CANTREMOVE (H5OPEN H5E_CANTREMOVE_g) -H5_DLLVAR hid_t H5E_NOTFOUND_g; /* Object not found */ -H5_DLLVAR hid_t H5E_EXISTS_g; /* Object already exists */ -H5_DLLVAR hid_t H5E_CANTENCODE_g; /* Unable to encode value */ -H5_DLLVAR hid_t H5E_CANTDECODE_g; /* Unable to decode value */ -H5_DLLVAR hid_t H5E_CANTSPLIT_g; /* Unable to split node */ -H5_DLLVAR hid_t H5E_CANTREDISTRIBUTE_g; /* Unable to redistribute records */ -H5_DLLVAR hid_t H5E_CANTSWAP_g; /* Unable to swap records */ -H5_DLLVAR hid_t H5E_CANTINSERT_g; /* Unable to insert object */ -H5_DLLVAR hid_t H5E_CANTLIST_g; /* Unable to list node */ -H5_DLLVAR hid_t H5E_CANTMODIFY_g; /* Unable to modify record */ -H5_DLLVAR hid_t H5E_CANTREMOVE_g; /* Unable to remove object */ +/* Function entry/exit interface errors */ +#define H5E_CANTINIT (H5OPEN H5E_CANTINIT_g) +#define H5E_ALREADYINIT (H5OPEN H5E_ALREADYINIT_g) +#define H5E_CANTRELEASE (H5OPEN H5E_CANTRELEASE_g) +H5_DLLVAR hid_t H5E_CANTINIT_g; /* Unable to initialize object */ +H5_DLLVAR hid_t H5E_ALREADYINIT_g; /* Object already initialized */ +H5_DLLVAR hid_t H5E_CANTRELEASE_g; /* Unable to release object */ + +/* Property list errors */ +#define H5E_CANTGET (H5OPEN H5E_CANTGET_g) +#define H5E_CANTSET (H5OPEN H5E_CANTSET_g) +#define H5E_DUPCLASS (H5OPEN H5E_DUPCLASS_g) +H5_DLLVAR hid_t H5E_CANTGET_g; /* Can't get value */ +H5_DLLVAR hid_t H5E_CANTSET_g; /* Can't set value */ +H5_DLLVAR hid_t H5E_DUPCLASS_g; /* Duplicate class name in parent class */ + +/* Free space errors */ +#define H5E_CANTMERGE (H5OPEN H5E_CANTMERGE_g) +#define H5E_CANTREVIVE (H5OPEN H5E_CANTREVIVE_g) +#define H5E_CANTSHRINK (H5OPEN H5E_CANTSHRINK_g) +H5_DLLVAR hid_t H5E_CANTMERGE_g; /* Can't merge objects */ +H5_DLLVAR hid_t H5E_CANTREVIVE_g; /* Can't revive object */ +H5_DLLVAR hid_t H5E_CANTSHRINK_g; /* Can't shrink container */ + +/* Object header related errors */ +#define H5E_LINKCOUNT (H5OPEN H5E_LINKCOUNT_g) +#define H5E_VERSION (H5OPEN H5E_VERSION_g) +#define H5E_ALIGNMENT (H5OPEN H5E_ALIGNMENT_g) +#define H5E_BADMESG (H5OPEN H5E_BADMESG_g) +#define H5E_CANTDELETE (H5OPEN H5E_CANTDELETE_g) +#define H5E_BADITER (H5OPEN H5E_BADITER_g) +#define H5E_CANTPACK (H5OPEN H5E_CANTPACK_g) +H5_DLLVAR hid_t H5E_LINKCOUNT_g; /* Bad object header link count */ +H5_DLLVAR hid_t H5E_VERSION_g; /* Wrong version number */ +H5_DLLVAR hid_t H5E_ALIGNMENT_g; /* Alignment error */ +H5_DLLVAR hid_t H5E_BADMESG_g; /* Unrecognized message */ +H5_DLLVAR hid_t H5E_CANTDELETE_g; /* Can't delete message */ +H5_DLLVAR hid_t H5E_BADITER_g; /* Iteration failed */ +H5_DLLVAR hid_t H5E_CANTPACK_g; /* Can't pack messages */ + +/* System level errors */ +#define H5E_SYSERRSTR (H5OPEN H5E_SYSERRSTR_g) +H5_DLLVAR hid_t H5E_SYSERRSTR_g; /* System error message */ + +/* I/O pipeline errors */ +#define H5E_NOFILTER (H5OPEN H5E_NOFILTER_g) +#define H5E_CALLBACK (H5OPEN H5E_CALLBACK_g) +#define H5E_CANAPPLY (H5OPEN H5E_CANAPPLY_g) +#define H5E_SETLOCAL (H5OPEN H5E_SETLOCAL_g) +#define H5E_NOENCODER (H5OPEN H5E_NOENCODER_g) +H5_DLLVAR hid_t H5E_NOFILTER_g; /* Requested filter is not available */ +H5_DLLVAR hid_t H5E_CALLBACK_g; /* Callback failed */ +H5_DLLVAR hid_t H5E_CANAPPLY_g; /* Error from filter 'can apply' callback */ +H5_DLLVAR hid_t H5E_SETLOCAL_g; /* Error from filter 'set local' callback */ +H5_DLLVAR hid_t H5E_NOENCODER_g; /* Filter present but encoding disabled */ + +/* Group related errors */ +#define H5E_CANTOPENOBJ (H5OPEN H5E_CANTOPENOBJ_g) +#define H5E_CANTCLOSEOBJ (H5OPEN H5E_CANTCLOSEOBJ_g) +#define H5E_COMPLEN (H5OPEN H5E_COMPLEN_g) +#define H5E_PATH (H5OPEN H5E_PATH_g) +H5_DLLVAR hid_t H5E_CANTOPENOBJ_g; /* Can't open object */ +H5_DLLVAR hid_t H5E_CANTCLOSEOBJ_g; /* Can't close object */ +H5_DLLVAR hid_t H5E_COMPLEN_g; /* Name component is too long */ +H5_DLLVAR hid_t H5E_PATH_g; /* Problem with path to object */ + +/* No error */ +#define H5E_NONE_MINOR (H5OPEN H5E_NONE_MINOR_g) +H5_DLLVAR hid_t H5E_NONE_MINOR_g; /* No error */ /* File accessability errors */ #define H5E_FILEEXISTS (H5OPEN H5E_FILEEXISTS_g) @@ -196,22 +224,6 @@ H5_DLLVAR hid_t H5E_BADFILE_g; /* Bad file ID accessed */ H5_DLLVAR hid_t H5E_TRUNCATED_g; /* File has been truncated */ H5_DLLVAR hid_t H5E_MOUNT_g; /* File mount error */ -/* No error */ -#define H5E_NONE_MINOR (H5OPEN H5E_NONE_MINOR_g) -H5_DLLVAR hid_t H5E_NONE_MINOR_g; /* No error */ - -/* Heap errors */ -#define H5E_CANTRESTORE (H5OPEN H5E_CANTRESTORE_g) -#define H5E_CANTCOMPUTE (H5OPEN H5E_CANTCOMPUTE_g) -#define H5E_CANTEXTEND (H5OPEN H5E_CANTEXTEND_g) -#define H5E_CANTATTACH (H5OPEN H5E_CANTATTACH_g) -#define H5E_CANTUPDATE (H5OPEN H5E_CANTUPDATE_g) -H5_DLLVAR hid_t H5E_CANTRESTORE_g; /* Can't restore condition */ -H5_DLLVAR hid_t H5E_CANTCOMPUTE_g; /* Can't compute value */ -H5_DLLVAR hid_t H5E_CANTEXTEND_g; /* Can't extend heap's space */ -H5_DLLVAR hid_t H5E_CANTATTACH_g; /* Can't attach object */ -H5_DLLVAR hid_t H5E_CANTUPDATE_g; /* Can't update object */ - /* Object atom related errors */ #define H5E_BADATOM (H5OPEN H5E_BADATOM_g) #define H5E_BADGROUP (H5OPEN H5E_BADGROUP_g) @@ -226,68 +238,6 @@ H5_DLLVAR hid_t H5E_CANTINC_g; /* Unable to increment reference count */ H5_DLLVAR hid_t H5E_CANTDEC_g; /* Unable to decrement reference count */ H5_DLLVAR hid_t H5E_NOIDS_g; /* Out of IDs for group */ -/* Group related errors */ -#define H5E_CANTOPENOBJ (H5OPEN H5E_CANTOPENOBJ_g) -#define H5E_CANTCLOSEOBJ (H5OPEN H5E_CANTCLOSEOBJ_g) -#define H5E_COMPLEN (H5OPEN H5E_COMPLEN_g) -#define H5E_PATH (H5OPEN H5E_PATH_g) -H5_DLLVAR hid_t H5E_CANTOPENOBJ_g; /* Can't open object */ -H5_DLLVAR hid_t H5E_CANTCLOSEOBJ_g; /* Can't close object */ -H5_DLLVAR hid_t H5E_COMPLEN_g; /* Name component is too long */ -H5_DLLVAR hid_t H5E_PATH_g; /* Problem with path to object */ - -/* Property list errors */ -#define H5E_CANTGET (H5OPEN H5E_CANTGET_g) -#define H5E_CANTSET (H5OPEN H5E_CANTSET_g) -#define H5E_DUPCLASS (H5OPEN H5E_DUPCLASS_g) -H5_DLLVAR hid_t H5E_CANTGET_g; /* Can't get value */ -H5_DLLVAR hid_t H5E_CANTSET_g; /* Can't set value */ -H5_DLLVAR hid_t H5E_DUPCLASS_g; /* Duplicate class name in parent class */ - -/* Function entry/exit interface errors */ -#define H5E_CANTINIT (H5OPEN H5E_CANTINIT_g) -#define H5E_ALREADYINIT (H5OPEN H5E_ALREADYINIT_g) -#define H5E_CANTRELEASE (H5OPEN H5E_CANTRELEASE_g) -H5_DLLVAR hid_t H5E_CANTINIT_g; /* Unable to initialize object */ -H5_DLLVAR hid_t H5E_ALREADYINIT_g; /* Object already initialized */ -H5_DLLVAR hid_t H5E_CANTRELEASE_g; /* Unable to release object */ - -/* Datatype conversion errors */ -#define H5E_CANTCONVERT (H5OPEN H5E_CANTCONVERT_g) -#define H5E_BADSIZE (H5OPEN H5E_BADSIZE_g) -H5_DLLVAR hid_t H5E_CANTCONVERT_g; /* Can't convert datatypes */ -H5_DLLVAR hid_t H5E_BADSIZE_g; /* Bad size for object */ - -/* Link related errors */ -#define H5E_TRAVERSE (H5OPEN H5E_TRAVERSE_g) -#define H5E_NLINKS (H5OPEN H5E_NLINKS_g) -#define H5E_NOTREGISTERED (H5OPEN H5E_NOTREGISTERED_g) -#define H5E_CANTMOVE (H5OPEN H5E_CANTMOVE_g) -H5_DLLVAR hid_t H5E_TRAVERSE_g; /* Link traversal failure */ -H5_DLLVAR hid_t H5E_NLINKS_g; /* Too many soft links in path */ -H5_DLLVAR hid_t H5E_NOTREGISTERED_g; /* Link class not registered */ -H5_DLLVAR hid_t H5E_CANTMOVE_g; /* Move callback returned error */ - -/* Parallel MPI errors */ -#define H5E_MPI (H5OPEN H5E_MPI_g) -#define H5E_MPIERRSTR (H5OPEN H5E_MPIERRSTR_g) -#define H5E_CANTRECV (H5OPEN H5E_CANTRECV_g) -H5_DLLVAR hid_t H5E_MPI_g; /* Some MPI function failed */ -H5_DLLVAR hid_t H5E_MPIERRSTR_g; /* MPI Error String */ -H5_DLLVAR hid_t H5E_CANTRECV_g; /* Can't receive data */ - -/* Argument errors */ -#define H5E_UNINITIALIZED (H5OPEN H5E_UNINITIALIZED_g) -#define H5E_UNSUPPORTED (H5OPEN H5E_UNSUPPORTED_g) -#define H5E_BADTYPE (H5OPEN H5E_BADTYPE_g) -#define H5E_BADRANGE (H5OPEN H5E_BADRANGE_g) -#define H5E_BADVALUE (H5OPEN H5E_BADVALUE_g) -H5_DLLVAR hid_t H5E_UNINITIALIZED_g; /* Information is uinitialized */ -H5_DLLVAR hid_t H5E_UNSUPPORTED_g; /* Feature is unsupported */ -H5_DLLVAR hid_t H5E_BADTYPE_g; /* Inappropriate type */ -H5_DLLVAR hid_t H5E_BADRANGE_g; /* Out of range */ -H5_DLLVAR hid_t H5E_BADVALUE_g; /* Bad value */ - /* Cache related errors */ #define H5E_CANTFLUSH (H5OPEN H5E_CANTFLUSH_g) #define H5E_CANTSERIALIZE (H5OPEN H5E_CANTSERIALIZE_g) @@ -322,13 +272,23 @@ H5_DLLVAR hid_t H5E_CANTDIRTY_g; /* Unable to mark metadata as dirty */ H5_DLLVAR hid_t H5E_CANTEXPUNGE_g; /* Unable to expunge a metadata cache entry */ H5_DLLVAR hid_t H5E_CANTRESIZE_g; /* Unable to resize a metadata cache entry */ -/* Free space errors */ -#define H5E_CANTMERGE (H5OPEN H5E_CANTMERGE_g) -#define H5E_CANTREVIVE (H5OPEN H5E_CANTREVIVE_g) -#define H5E_CANTSHRINK (H5OPEN H5E_CANTSHRINK_g) -H5_DLLVAR hid_t H5E_CANTMERGE_g; /* Can't merge objects */ -H5_DLLVAR hid_t H5E_CANTREVIVE_g; /* Can't revive object */ -H5_DLLVAR hid_t H5E_CANTSHRINK_g; /* Can't shrink container */ +/* Link related errors */ +#define H5E_TRAVERSE (H5OPEN H5E_TRAVERSE_g) +#define H5E_NLINKS (H5OPEN H5E_NLINKS_g) +#define H5E_NOTREGISTERED (H5OPEN H5E_NOTREGISTERED_g) +#define H5E_CANTMOVE (H5OPEN H5E_CANTMOVE_g) +H5_DLLVAR hid_t H5E_TRAVERSE_g; /* Link traversal failure */ +H5_DLLVAR hid_t H5E_NLINKS_g; /* Too many soft links in path */ +H5_DLLVAR hid_t H5E_NOTREGISTERED_g; /* Link class not registered */ +H5_DLLVAR hid_t H5E_CANTMOVE_g; /* Move callback returned error */ + +/* Parallel MPI errors */ +#define H5E_MPI (H5OPEN H5E_MPI_g) +#define H5E_MPIERRSTR (H5OPEN H5E_MPIERRSTR_g) +#define H5E_CANTRECV (H5OPEN H5E_CANTRECV_g) +H5_DLLVAR hid_t H5E_MPI_g; /* Some MPI function failed */ +H5_DLLVAR hid_t H5E_MPIERRSTR_g; /* MPI Error String */ +H5_DLLVAR hid_t H5E_CANTRECV_g; /* Can't receive data */ /* Dataspace errors */ #define H5E_CANTCLIP (H5OPEN H5E_CANTCLIP_g) @@ -344,4 +304,46 @@ H5_DLLVAR hid_t H5E_CANTNEXT_g; /* Can't move to next iterator location */ H5_DLLVAR hid_t H5E_BADSELECT_g; /* Invalid selection */ H5_DLLVAR hid_t H5E_CANTCOMPARE_g; /* Can't compare objects */ +/* Argument errors */ +#define H5E_UNINITIALIZED (H5OPEN H5E_UNINITIALIZED_g) +#define H5E_UNSUPPORTED (H5OPEN H5E_UNSUPPORTED_g) +#define H5E_BADTYPE (H5OPEN H5E_BADTYPE_g) +#define H5E_BADRANGE (H5OPEN H5E_BADRANGE_g) +#define H5E_BADVALUE (H5OPEN H5E_BADVALUE_g) +H5_DLLVAR hid_t H5E_UNINITIALIZED_g; /* Information is uinitialized */ +H5_DLLVAR hid_t H5E_UNSUPPORTED_g; /* Feature is unsupported */ +H5_DLLVAR hid_t H5E_BADTYPE_g; /* Inappropriate type */ +H5_DLLVAR hid_t H5E_BADRANGE_g; /* Out of range */ +H5_DLLVAR hid_t H5E_BADVALUE_g; /* Bad value */ + +/* B-tree related errors */ +#define H5E_NOTFOUND (H5OPEN H5E_NOTFOUND_g) +#define H5E_EXISTS (H5OPEN H5E_EXISTS_g) +#define H5E_CANTENCODE (H5OPEN H5E_CANTENCODE_g) +#define H5E_CANTDECODE (H5OPEN H5E_CANTDECODE_g) +#define H5E_CANTSPLIT (H5OPEN H5E_CANTSPLIT_g) +#define H5E_CANTREDISTRIBUTE (H5OPEN H5E_CANTREDISTRIBUTE_g) +#define H5E_CANTSWAP (H5OPEN H5E_CANTSWAP_g) +#define H5E_CANTINSERT (H5OPEN H5E_CANTINSERT_g) +#define H5E_CANTLIST (H5OPEN H5E_CANTLIST_g) +#define H5E_CANTMODIFY (H5OPEN H5E_CANTMODIFY_g) +#define H5E_CANTREMOVE (H5OPEN H5E_CANTREMOVE_g) +H5_DLLVAR hid_t H5E_NOTFOUND_g; /* Object not found */ +H5_DLLVAR hid_t H5E_EXISTS_g; /* Object already exists */ +H5_DLLVAR hid_t H5E_CANTENCODE_g; /* Unable to encode value */ +H5_DLLVAR hid_t H5E_CANTDECODE_g; /* Unable to decode value */ +H5_DLLVAR hid_t H5E_CANTSPLIT_g; /* Unable to split node */ +H5_DLLVAR hid_t H5E_CANTREDISTRIBUTE_g; /* Unable to redistribute records */ +H5_DLLVAR hid_t H5E_CANTSWAP_g; /* Unable to swap records */ +H5_DLLVAR hid_t H5E_CANTINSERT_g; /* Unable to insert object */ +H5_DLLVAR hid_t H5E_CANTLIST_g; /* Unable to list node */ +H5_DLLVAR hid_t H5E_CANTMODIFY_g; /* Unable to modify record */ +H5_DLLVAR hid_t H5E_CANTREMOVE_g; /* Unable to remove object */ + +/* Datatype conversion errors */ +#define H5E_CANTCONVERT (H5OPEN H5E_CANTCONVERT_g) +#define H5E_BADSIZE (H5OPEN H5E_BADSIZE_g) +H5_DLLVAR hid_t H5E_CANTCONVERT_g; /* Can't convert datatypes */ +H5_DLLVAR hid_t H5E_BADSIZE_g; /* Bad size for object */ + #endif /* H5Epubgen_H */ diff --git a/src/H5Eterm.h b/src/H5Eterm.h index 90c1cdf..6fa48dd 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -21,48 +21,80 @@ /* Reset major error IDs */ -H5E_NONE_MAJOR_g= -H5E_RS_g= -H5E_CACHE_g= -H5E_SLIST_g= -H5E_STORAGE_g= -H5E_ATOM_g= -H5E_RESOURCE_g= -H5E_FSPACE_g= -H5E_OHDR_g= +H5E_DATASET_g= H5E_FUNC_g= -H5E_ERROR_g= -H5E_BTREE_g= -H5E_ATTR_g= -H5E_PLIST_g= +H5E_STORAGE_g= +H5E_FILE_g= H5E_SYM_g= -H5E_ARGS_g= -H5E_HEAP_g= +H5E_VFL_g= H5E_INTERNAL_g= -H5E_FILE_g= +H5E_BTREE_g= +H5E_REFERENCE_g= +H5E_DATASPACE_g= +H5E_RESOURCE_g= +H5E_PLIST_g= H5E_LINK_g= H5E_DATATYPE_g= -H5E_TST_g= +H5E_RS_g= +H5E_HEAP_g= +H5E_OHDR_g= +H5E_ATOM_g= +H5E_ATTR_g= +H5E_NONE_MAJOR_g= H5E_IO_g= -H5E_DATASET_g= -H5E_REFERENCE_g= +H5E_SLIST_g= H5E_EFL_g= -H5E_VFL_g= -H5E_DATASPACE_g= -H5E_PLINE_g= (-1); +H5E_TST_g= +H5E_ARGS_g= +H5E_ERROR_g= +H5E_PLINE_g= +H5E_FSPACE_g= +H5E_CACHE_g= (-1); /* Reset minor error IDs */ -/* System level errors */ -H5E_SYSERRSTR_g= +/* Generic low-level file I/O errors */ +H5E_SEEKERROR_g= +H5E_READERROR_g= +H5E_WRITEERROR_g= +H5E_CLOSEERROR_g= +H5E_OVERFLOW_g= +H5E_FCNTL_g= -/* I/O pipeline errors */ -H5E_NOFILTER_g= -H5E_CALLBACK_g= -H5E_CANAPPLY_g= -H5E_SETLOCAL_g= -H5E_NOENCODER_g= +/* Resource errors */ +H5E_NOSPACE_g= +H5E_CANTALLOC_g= +H5E_CANTCOPY_g= +H5E_CANTFREE_g= +H5E_ALREADYEXISTS_g= +H5E_CANTLOCK_g= +H5E_CANTUNLOCK_g= +H5E_CANTGC_g= +H5E_CANTGETSIZE_g= +H5E_OBJOPEN_g= + +/* Heap errors */ +H5E_CANTRESTORE_g= +H5E_CANTCOMPUTE_g= +H5E_CANTEXTEND_g= +H5E_CANTATTACH_g= +H5E_CANTUPDATE_g= + +/* Function entry/exit interface errors */ +H5E_CANTINIT_g= +H5E_ALREADYINIT_g= +H5E_CANTRELEASE_g= + +/* Property list errors */ +H5E_CANTGET_g= +H5E_CANTSET_g= +H5E_DUPCLASS_g= + +/* Free space errors */ +H5E_CANTMERGE_g= +H5E_CANTREVIVE_g= +H5E_CANTSHRINK_g= /* Object header related errors */ H5E_LINKCOUNT_g= @@ -73,37 +105,24 @@ H5E_CANTDELETE_g= H5E_BADITER_g= H5E_CANTPACK_g= -/* Resource errors */ -H5E_NOSPACE_g= -H5E_CANTALLOC_g= -H5E_CANTCOPY_g= -H5E_CANTFREE_g= -H5E_ALREADYEXISTS_g= -H5E_CANTLOCK_g= -H5E_CANTUNLOCK_g= -H5E_CANTGC_g= -H5E_CANTGETSIZE_g= +/* System level errors */ +H5E_SYSERRSTR_g= -/* Generic low-level file I/O errors */ -H5E_SEEKERROR_g= -H5E_READERROR_g= -H5E_WRITEERROR_g= -H5E_CLOSEERROR_g= -H5E_OVERFLOW_g= -H5E_FCNTL_g= +/* I/O pipeline errors */ +H5E_NOFILTER_g= +H5E_CALLBACK_g= +H5E_CANAPPLY_g= +H5E_SETLOCAL_g= +H5E_NOENCODER_g= -/* B-tree related errors */ -H5E_NOTFOUND_g= -H5E_EXISTS_g= -H5E_CANTENCODE_g= -H5E_CANTDECODE_g= -H5E_CANTSPLIT_g= -H5E_CANTREDISTRIBUTE_g= -H5E_CANTSWAP_g= -H5E_CANTINSERT_g= -H5E_CANTLIST_g= -H5E_CANTMODIFY_g= -H5E_CANTREMOVE_g= +/* Group related errors */ +H5E_CANTOPENOBJ_g= +H5E_CANTCLOSEOBJ_g= +H5E_COMPLEN_g= +H5E_PATH_g= + +/* No error */ +H5E_NONE_MINOR_g= /* File accessability errors */ H5E_FILEEXISTS_g= @@ -116,16 +135,6 @@ H5E_BADFILE_g= H5E_TRUNCATED_g= H5E_MOUNT_g= -/* No error */ -H5E_NONE_MINOR_g= - -/* Heap errors */ -H5E_CANTRESTORE_g= -H5E_CANTCOMPUTE_g= -H5E_CANTEXTEND_g= -H5E_CANTATTACH_g= -H5E_CANTUPDATE_g= - /* Object atom related errors */ H5E_BADATOM_g= H5E_BADGROUP_g= @@ -134,44 +143,6 @@ H5E_CANTINC_g= H5E_CANTDEC_g= H5E_NOIDS_g= -/* Group related errors */ -H5E_CANTOPENOBJ_g= -H5E_CANTCLOSEOBJ_g= -H5E_COMPLEN_g= -H5E_PATH_g= - -/* Property list errors */ -H5E_CANTGET_g= -H5E_CANTSET_g= -H5E_DUPCLASS_g= - -/* Function entry/exit interface errors */ -H5E_CANTINIT_g= -H5E_ALREADYINIT_g= -H5E_CANTRELEASE_g= - -/* Datatype conversion errors */ -H5E_CANTCONVERT_g= -H5E_BADSIZE_g= - -/* Link related errors */ -H5E_TRAVERSE_g= -H5E_NLINKS_g= -H5E_NOTREGISTERED_g= -H5E_CANTMOVE_g= - -/* Parallel MPI errors */ -H5E_MPI_g= -H5E_MPIERRSTR_g= -H5E_CANTRECV_g= - -/* Argument errors */ -H5E_UNINITIALIZED_g= -H5E_UNSUPPORTED_g= -H5E_BADTYPE_g= -H5E_BADRANGE_g= -H5E_BADVALUE_g= - /* Cache related errors */ H5E_CANTFLUSH_g= H5E_CANTSERIALIZE_g= @@ -190,10 +161,16 @@ H5E_CANTDIRTY_g= H5E_CANTEXPUNGE_g= H5E_CANTRESIZE_g= -/* Free space errors */ -H5E_CANTMERGE_g= -H5E_CANTREVIVE_g= -H5E_CANTSHRINK_g= +/* Link related errors */ +H5E_TRAVERSE_g= +H5E_NLINKS_g= +H5E_NOTREGISTERED_g= +H5E_CANTMOVE_g= + +/* Parallel MPI errors */ +H5E_MPI_g= +H5E_MPIERRSTR_g= +H5E_CANTRECV_g= /* Dataspace errors */ H5E_CANTCLIP_g= @@ -201,6 +178,30 @@ H5E_CANTCOUNT_g= H5E_CANTSELECT_g= H5E_CANTNEXT_g= H5E_BADSELECT_g= -H5E_CANTCOMPARE_g= (-1); +H5E_CANTCOMPARE_g= + +/* Argument errors */ +H5E_UNINITIALIZED_g= +H5E_UNSUPPORTED_g= +H5E_BADTYPE_g= +H5E_BADRANGE_g= +H5E_BADVALUE_g= + +/* B-tree related errors */ +H5E_NOTFOUND_g= +H5E_EXISTS_g= +H5E_CANTENCODE_g= +H5E_CANTDECODE_g= +H5E_CANTSPLIT_g= +H5E_CANTREDISTRIBUTE_g= +H5E_CANTSWAP_g= +H5E_CANTINSERT_g= +H5E_CANTLIST_g= +H5E_CANTMODIFY_g= +H5E_CANTREMOVE_g= + +/* Datatype conversion errors */ +H5E_CANTCONVERT_g= +H5E_BADSIZE_g= (-1); #endif /* H5Eterm_H */ diff --git a/src/H5FS.c b/src/H5FS.c index 7d77351..e6bb45d 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -283,12 +283,38 @@ HDfprintf(stderr, "%s: Deleting free space manager\n", FUNC); /* Delete serialized section storage, if there are any */ #ifdef QAK -HDfprintf(stderr, "%s: fs_hdr->sect_addr = %a\n", FUNC, fs_hdr->sect_addr); +HDfprintf(stderr, "%s: fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); #endif /* QAK */ if(fspace->serial_sect_count > 0) { + unsigned sinfo_status = 0; /* Free space section info's status in the metadata cache */ + + /* Sanity check */ HDassert(H5F_addr_defined(fspace->sect_addr)); HDassert(fspace->sect_size > 0); - if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, fspace->sect_addr, fspace->alloc_sect_size)<0) + + /* Check the free space section info's status in the metadata cache */ + if(H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for free space section info") + + /* If the free space section info is in the cache, expunge it now */ + if(sinfo_status & H5AC_ES__IN_CACHE) { + /* Sanity checks on direct block */ + HDassert(!(sinfo_status & H5AC_ES__IS_PINNED)); + HDassert(!(sinfo_status & H5AC_ES__IS_PROTECTED)); + +#ifdef QAK +HDfprintf(stderr, "%s: Expunging free space section info from cache\n", FUNC); +#endif /* QAK */ + /* Evict the free space section info from the metadata cache */ + if(H5AC_expunge_entry(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "unable to remove free space section info from cache") +#ifdef QAK +HDfprintf(stderr, "%s: Done expunging free space section info from cache\n", FUNC); +#endif /* QAK */ + } /* end if */ + + /* Release the space in the file */ + if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, fspace->sect_addr, fspace->alloc_sect_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to release free space sections") } /* end if */ diff --git a/src/H5HF.c b/src/H5HF.c index 733df6c..55d3324 100644 --- a/src/H5HF.c +++ b/src/H5HF.c @@ -97,7 +97,7 @@ H5FL_DEFINE_STATIC(H5HF_t); *------------------------------------------------------------------------- */ H5HF_t * -H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_create_t *cparam) +H5HF_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam) { H5HF_t *fh = NULL; /* Pointer to new fractal heap */ H5HF_hdr_t *hdr = NULL; /* The new fractal heap header information */ @@ -191,7 +191,7 @@ H5HF_t * H5HF_open(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr) { H5HF_t *fh = NULL; /* Pointer to new fractal heap */ - H5HF_hdr_t *hdr = NULL; /* The new fractal heap header information */ + H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ H5HF_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5HF_open, NULL) @@ -244,7 +244,7 @@ HDfprintf(stderr, "%s: hdr->rc = %u\n", FUNC, hdr->rc); done: if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header") if(!ret_value) { if(fh) (void)H5HF_close(fh, dxpl_id); @@ -536,7 +536,7 @@ done: /*------------------------------------------------------------------------- * Function: H5HF_close * - * Purpose: Close a fractal heap wrapper + * Purpose: Close a fractal heap * * Return: SUCCEED/FAIL * @@ -608,3 +608,89 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_close() */ + +/*------------------------------------------------------------------------- + * Function: H5HF_delete + * + * Purpose: Delete a fractal heap + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Aug 4 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_delete(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr) +{ + H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(H5HF_delete, FAIL) + + /* + * Check arguments. + */ + HDassert(f); + HDassert(H5F_addr_defined(fh_addr)); + + /* Check if group was already open */ + if(H5FO_opened(f, fh_addr) != NULL) + HGOTO_ERROR(H5E_HEAP, H5E_OBJOPEN, FAIL, "heap still open") + + /* Clear any errors from H5FO_opened() */ + H5E_clear_stack(NULL); + + /* Load the heap header into memory */ +#ifdef QAK +HDfprintf(stderr, "%s: fh_addr = %a\n", FUNC, fh_addr); +#endif /* QAK */ + if(NULL == (hdr = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap header") + + /* Check for free space manager for heap */ + if(H5F_addr_defined(hdr->fs_addr)) { +#ifdef QAK +HDfprintf(stderr, "%s: hdr->fs_addr = %a\n", FUNC, hdr->fs_addr); +#endif /* QAK */ + /* Delete free space manager for heap */ + if(H5HF_space_delete(hdr, dxpl_id) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap free space manager") + } /* end if */ + + /* Check for root direct/indirect block */ + if(H5F_addr_defined(hdr->man_dtable.table_addr)) { +#ifdef QAK +HDfprintf(stderr, "%s: hdr->man_dtable.table_addr = %a\n", FUNC, hdr->man_dtable.table_addr); +#endif /* QAK */ + if(hdr->man_dtable.curr_root_rows == 0) { + /* Delete root direct block */ + if(H5HF_man_dblock_delete(f, dxpl_id, hdr->man_dtable.table_addr, (hsize_t)hdr->man_dtable.cparam.start_block_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap root direct block") + } /* end if */ + else { + /* Delete root indirect block */ + if(H5HF_man_iblock_delete(hdr, dxpl_id, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, 0) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap root indirect block") + } /* end else */ + } /* end if */ + + /* Release header's disk space */ + if(H5MF_xfree(f, H5FD_MEM_FHEAP_HDR, dxpl_id, fh_addr, (hsize_t)H5HF_HEADER_SIZE(hdr)) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap header") + + /* Finished deleting header */ + if(H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__DIRTIED_FLAG|H5AC__DELETED_FLAG) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") + hdr = NULL; + +done: + /* Unprotect the header, if an error occurred */ + if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_delete() */ + diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 15e0605..bd96604 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -779,6 +779,9 @@ H5HF_cache_dblock_dest(H5F_t UNUSED *f, H5HF_direct_t *dblock) * Check arguments. */ HDassert(dblock); +#ifdef QAK +HDfprintf(stderr, "%s: Destroying direct block, dblock = %p\n", FUNC, dblock); +#endif /* QAK */ /* Decrement reference count on shared fractal heap info */ HDassert(dblock->hdr); diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index 00821e9..e6b45ce 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -302,7 +302,7 @@ HDfprintf(stderr, "%s: Reversing iterator\n", FUNC); #ifdef QAK HDfprintf(stderr, "%s: Before releasing direct block's space, dblock_addr = %a\n", FUNC, dblock_addr); #endif /* QAK */ - if(H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_DBLOCK, dxpl_id, dblock_addr, (hsize_t)dblock->size)<0) + if(H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_DBLOCK, dxpl_id, dblock_addr, (hsize_t)dblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap direct block") /* Remove direct block from metadata cache */ @@ -489,3 +489,69 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_dblock_protect() */ + +/*------------------------------------------------------------------------- + * Function: H5HF_man_dblock_delete + * + * Purpose: Delete a managed direct block + * + * Note: This routine does _not_ modify any indirect block that points + * to this direct block, it is assumed that the whole heap is + * being deleted. (H5HF_man_dblock_destroy modifies the indirect + * block) + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Aug 7 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_man_dblock_delete(H5F_t *f, hid_t dxpl_id, haddr_t dblock_addr, + hsize_t dblock_size) +{ + unsigned dblock_status = 0; /* Direct block's status in the metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_man_dblock_delete) +#ifdef QAK +HDfprintf(stderr, "%s: dblock_addr = %a, dblock_size = %Hu\n", FUNC, dblock_addr, dblock_size); +#endif /* QAK */ + + /* + * Check arguments. + */ + HDassert(f); + HDassert(H5F_addr_defined(dblock_addr)); + + /* Check the direct block's status in the metadata cache */ + if(H5AC_get_entry_status(f, dblock_addr, &dblock_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for direct block") + + /* If the direct block is in the cache, expunge it now */ + if(dblock_status & H5AC_ES__IN_CACHE) { + /* Sanity checks on direct block */ + HDassert(!(dblock_status & H5AC_ES__IS_PINNED)); + HDassert(!(dblock_status & H5AC_ES__IS_PROTECTED)); + +#ifdef QAK +HDfprintf(stderr, "%s: Expunging direct block from cache\n", FUNC); +#endif /* QAK */ + /* Evict the direct block from the metadata cache */ + if(H5AC_expunge_entry(f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "unable to remove direct block from cache") +#ifdef QAK +HDfprintf(stderr, "%s: Done expunging direct block from cache\n", FUNC); +#endif /* QAK */ + } /* end if */ + + /* Release direct block's disk space */ + if(H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, dxpl_id, dblock_addr, dblock_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap direct block") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_man_dblock_delete() */ + diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index cbaa817..f9083f8 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -268,7 +268,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_init(H5HF_hdr_t *hdr, haddr_t fh_addr, H5HF_create_t *cparam) +H5HF_hdr_init(H5HF_hdr_t *hdr, haddr_t fh_addr, const H5HF_create_t *cparam) { size_t dblock_overhead; /* Direct block's overhead */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index 4872e08..1b66cd6 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -781,7 +781,7 @@ done: /* Release hold on indirect block */ if(iblock_held) if(H5HF_iblock_decr(iblock) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't decrement reference count on shared indirect block") + HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iblock_alloc_row() */ @@ -1078,7 +1078,7 @@ HDfprintf(stderr, "%s: iblock->block_off = %Hu, iblock->nchildren = %u\n", FUNC, * doesn't invalidate the 'iblock' variable) */ if(H5HF_iblock_decr(iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't decrement reference count on shared indirect block") + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") done: #ifdef QAK @@ -1119,3 +1119,104 @@ H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, haddr_t *chi FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_man_iblock_entry_addr() */ + +/*------------------------------------------------------------------------- + * Function: H5HF_man_iblock_delete + * + * Purpose: Delete a managed indirect block + * + * Note: This routine does _not_ modify any indirect block that points + * to this indirect block, it is assumed that the whole heap is + * being deleted in a top-down fashion. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Aug 7 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_man_iblock_delete(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t iblock_addr, + unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry) +{ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + unsigned row, col; /* Current row & column in indirect block */ + unsigned entry; /* Current entry in row */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iblock_delete) +#ifdef QAK +HDfprintf(stderr, "%s: iblock_addr = %a, iblock_nrows = %u\n", FUNC, iblock_addr, iblock_nrows); +#endif /* QAK */ + + /* + * Check arguments. + */ + HDassert(hdr); + HDassert(H5F_addr_defined(iblock_addr)); + HDassert(iblock_nrows > 0); + + /* Lock indirect block */ + if(NULL == (iblock = H5HF_man_iblock_protect(hdr, dxpl_id, iblock_addr, iblock_nrows, par_iblock, par_entry, H5AC_WRITE))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") + + /* Iterate over rows in this indirect block */ + entry = 0; + for(row = 0; row < iblock->nrows; row++) { + /* Iterate over entries in this row */ + for(col = 0; col < hdr->man_dtable.cparam.width; col++, entry++) { + /* Check for child entry at this position */ + if(H5F_addr_defined(iblock->ents[entry].addr)) { + hsize_t row_block_size; /* The size of blocks in this row */ + + /* Get the row's block size */ + row_block_size = (hsize_t)hdr->man_dtable.row_block_size[row]; + + /* Are we in a direct or indirect block row */ + if(row < hdr->man_dtable.max_direct_rows) { + /* Delete child direct block */ + if(H5HF_man_dblock_delete(hdr->f, dxpl_id, iblock->ents[entry].addr, row_block_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap child direct block") + } /* end if */ + else { + unsigned child_nrows; /* Number of rows in new indirect block */ + + /* Compute # of rows in next child indirect block to use */ + child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, row_block_size); + + /* Delete child indirect block */ + if(H5HF_man_iblock_delete(hdr, dxpl_id, iblock->ents[entry].addr, child_nrows, iblock, entry) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap child indirect block") + } /* end else */ + } /* end if */ + } /* end for */ + } /* end row */ + + /* Release indirect block's disk space */ + if(H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, dxpl_id, iblock_addr, (hsize_t)iblock->size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap indirect block") + +#ifndef NDEBUG +{ + unsigned iblock_status = 0; /* Indirect block's status in the metadata cache */ + + /* Check the indirect block's status in the metadata cache */ + if(H5AC_get_entry_status(hdr->f, iblock_addr, &iblock_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for indirect block") + + /* Check if indirect block is pinned */ + HDassert(!(iblock_status & H5AC_ES__IS_PINNED)); +} +#endif /* NDEBUG */ + + /* Finished deleting indirect block in metadata cache */ + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_IBLOCK, iblock_addr, iblock, H5AC__DIRTIED_FLAG|H5AC__DELETED_FLAG) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + iblock = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_man_iblock_delete() */ + diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index e684ad1..6f3025d 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -408,7 +408,7 @@ H5FL_SEQ_EXTERN(H5HF_indirect_ent_t); /* Routines for managing shared fractal heap header */ H5_DLL H5HF_hdr_t * H5HF_hdr_alloc(H5F_t *f); -H5_DLL herr_t H5HF_hdr_init(H5HF_hdr_t *hdr, haddr_t fh_addr, H5HF_create_t *cparam); +H5_DLL herr_t H5HF_hdr_init(H5HF_hdr_t *hdr, haddr_t fh_addr, const H5HF_create_t *cparam); H5_DLL herr_t H5HF_hdr_finish_init(H5HF_hdr_t *hdr); /* Doubling table routines */ @@ -460,6 +460,9 @@ H5_DLL herr_t H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, H5_DLL herr_t H5HF_man_iblock_detach(H5HF_indirect_t *iblock, hid_t dxpl_id, unsigned entry); H5_DLL herr_t H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, haddr_t *child_addr); +H5_DLL herr_t H5HF_man_iblock_delete(H5HF_hdr_t *hdr, hid_t dxpl_id, + haddr_t iblock_addr, unsigned iblock_nrows, H5HF_indirect_t *par_iblock, + unsigned par_entry); /* Direct block routines */ H5_DLL herr_t H5HF_man_dblock_new(H5HF_hdr_t *fh, hid_t dxpl_id, size_t request, @@ -473,6 +476,8 @@ H5_DLL H5HF_direct_t *H5HF_man_dblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr, size_t dblock_size, H5HF_indirect_t *par_iblock, unsigned par_entry, H5AC_protect_t rw); +H5_DLL herr_t H5HF_man_dblock_delete(H5F_t *f, hid_t dxpl_id, haddr_t dblock_addr, + hsize_t dblock_size); /* Routines for internal operations */ H5_DLL herr_t H5HF_man_locate_block(H5HF_hdr_t *hdr, hid_t dxpl_id, diff --git a/src/H5HFprivate.h b/src/H5HFprivate.h index 4379dee..4490ec2 100644 --- a/src/H5HFprivate.h +++ b/src/H5HFprivate.h @@ -89,7 +89,7 @@ typedef struct H5HF_t H5HF_t; /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL H5HF_t *H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_create_t *cparam); +H5_DLL H5HF_t *H5HF_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam); H5_DLL H5HF_t *H5HF_open(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr); H5_DLL herr_t H5HF_get_id_len(H5HF_t *fh, size_t *id_len_p/*out*/); H5_DLL herr_t H5HF_get_heap_addr(H5HF_t *fh, haddr_t *heap_addr); @@ -100,6 +100,7 @@ H5_DLL herr_t H5HF_read(H5HF_t *fh, hid_t dxpl_id, const void *id, void *obj/*out*/); H5_DLL herr_t H5HF_remove(H5HF_t *fh, hid_t dxpl_id, const void *id); H5_DLL herr_t H5HF_close(H5HF_t *fh, hid_t dxpl_id); +H5_DLL herr_t H5HF_delete(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr); /* Statistics routines */ H5_DLL herr_t H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats); diff --git a/src/H5HFspace.c b/src/H5HFspace.c index cc9f21b..0cc6c12 100644 --- a/src/H5HFspace.c +++ b/src/H5HFspace.c @@ -326,6 +326,41 @@ done: /*------------------------------------------------------------------------- + * Function: H5HF_space_delete + * + * Purpose: Delete the free space manager for the heap + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Aug 7 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_space_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_space_delete) + + /* + * Check arguments. + */ + HDassert(hdr); + + /* Delete the free space manager */ + if(H5FS_delete(hdr->f, dxpl_id, hdr->fs_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't delete to free space manager") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_space_delete() */ + + +/*------------------------------------------------------------------------- * Function: H5HF_space_change_sect_class * * Purpose: Change a section's class diff --git a/src/H5err.txt b/src/H5err.txt index d7b4ac7..5c7ec04 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -115,6 +115,7 @@ MINOR, RESOURCE, H5E_CANTLOCK, Unable to lock object MINOR, RESOURCE, H5E_CANTUNLOCK, Unable to unlock object MINOR, RESOURCE, H5E_CANTGC, Unable to garbage collect MINOR, RESOURCE, H5E_CANTGETSIZE, Unable to compute size +MINOR, RESOURCE, H5E_OBJOPEN, Object is already open # File accessability errors MINOR, FILEACC, H5E_FILEEXISTS, File already exists diff --git a/test/fheap.c b/test/fheap.c index af3d9ca..43cff34 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -30,6 +30,9 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Vprivate.h" /* Vectors and arrays */ +/* Max. testfile name length */ +#define FHEAP_FILENAME_LEN 1024 + /* Object size macros */ #define SMALL_OBJ_SIZE1 10 #define SMALL_OBJ_SIZE2 20 @@ -73,6 +76,7 @@ typedef enum { typedef enum { FHEAP_DEL_FORWARD, /* Delete objects from 0 -> nobjs */ FHEAP_DEL_REVERSE, /* Delete objects from nobjs -> 0 */ + FHEAP_DEL_HEAP, /* Delete entire heap at once */ FHEAP_DEL_NDIRS /* The number of different deletion orders, must be last */ } fheap_test_del_dir_t; @@ -128,6 +132,8 @@ size_t shared_alloc_ids_g = 0; /* # of shared heap IDs allocated in array */ /* Local routines */ static int init_small_cparam(H5HF_create_t *cparam); static int check_stats(const H5HF_t *fh, const fheap_heap_state_t *state); +static int del_objs(H5F_t *f, hid_t dxpl, H5HF_t **fh, fheap_test_param_t *tparam, + fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids); /*------------------------------------------------------------------------- @@ -268,14 +274,14 @@ add_obj(H5HF_t *fh, hid_t dxpl, unsigned obj_off, /* Check free space left in heap */ if(check_stats(fh, state)) - FAIL_STACK_ERROR + TEST_ERROR } /* end if */ /* Read in object */ if(H5HF_read(fh, dxpl, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR if(HDmemcmp(obj, shared_robj_g, obj_size)) - FAIL_STACK_ERROR + TEST_ERROR /* If the heap IDs are to be retained, append them to the list */ if(keep_ids) { @@ -283,11 +289,11 @@ add_obj(H5HF_t *fh, hid_t dxpl, unsigned obj_off, if(keep_ids->num_ids + 1 > keep_ids->alloc_ids) { keep_ids->alloc_ids = MAX(1024, (keep_ids->alloc_ids * 2)); if(NULL == (keep_ids->ids = H5MM_realloc(keep_ids->ids, HEAP_ID_LEN * keep_ids->alloc_ids))) - FAIL_STACK_ERROR + TEST_ERROR if(NULL == (keep_ids->lens = H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids))) - FAIL_STACK_ERROR + TEST_ERROR if(NULL == (keep_ids->offs = H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids))) - FAIL_STACK_ERROR + TEST_ERROR } /* end if */ /* Append the object info onto the array */ @@ -332,11 +338,13 @@ get_del_string(const fheap_test_param_t *tparam) str = HDstrdup("(all - forward)"); else str = HDstrdup("(half, refill, all - forward)"); - else + else if(tparam->del_dir == FHEAP_DEL_REVERSE) if(tparam->drain_half == FHEAP_DEL_DRAIN_ALL) str = HDstrdup("(all - reverse)"); else str = HDstrdup("(half, refill, all - reverse)"); + else + str = HDstrdup("(all - deleting heap)"); return(str); } /* get_del_string() */ @@ -374,6 +382,259 @@ get_fill_size(const fheap_test_param_t *tparam) /*------------------------------------------------------------------------- + * Function: begin_test + * + * Purpose: Perform common "test being" operations + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, August 4, 2006 + * + *------------------------------------------------------------------------- + */ +static int +begin_test(fheap_test_param_t *tparam, const char *base_desc, + fheap_heap_ids_t *keep_ids, size_t *fill_size) +{ + char *del_str = NULL; /* Deletion order description */ + char *test_desc = NULL; /* Test description */ + + /* + * Test filling & removing all (small) objects from root direct block of absolute heap + */ + del_str = get_del_string(tparam); + HDassert(del_str); + test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); + sprintf(test_desc, base_desc, del_str); + TESTING(test_desc); + H5MM_xfree(del_str); + H5MM_xfree(test_desc); + + /* Initialize the heap ID structure */ + HDmemset(keep_ids, 0, sizeof(fheap_heap_ids_t)); + + /* Retrieve "bulk" filling object size */ + if(fill_size) + *fill_size = get_fill_size(tparam); + + /* Success */ + return(0); +} /* end begin_test() */ + + +/*------------------------------------------------------------------------- + * Function: open_heap + * + * Purpose: Perform common "open" operations on file & heap for testing + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, August 4, 2006 + * + *------------------------------------------------------------------------- + */ +static int +open_heap(char *filename, hid_t fapl, hid_t dxpl, const H5HF_create_t *cparam, + const fheap_test_param_t *tparam, hid_t *file, H5F_t **f, H5HF_t **fh, + haddr_t *fh_addr, fheap_heap_state_t *state, off_t *empty_size) +{ + size_t id_len; /* Size of fractal heap IDs */ + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, FHEAP_FILENAME_LEN); + + /* Create the file to work on */ + if((*file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Check for deleting the entire heap */ + if(tparam->del_dir != FHEAP_DEL_HEAP) { + /* Get a pointer to the internal file object */ + if(NULL == (*f = H5I_object(*file))) + FAIL_STACK_ERROR + + /* Create absolute heap */ + if(NULL == (*fh = H5HF_create(*f, dxpl, cparam))) + FAIL_STACK_ERROR + if(H5HF_get_id_len(*fh, &id_len) < 0) + FAIL_STACK_ERROR + if(id_len > HEAP_ID_LEN) + TEST_ERROR + if(H5HF_get_heap_addr(*fh, fh_addr) < 0) + FAIL_STACK_ERROR + if(!H5F_addr_defined(*fh_addr)) + TEST_ERROR + HDmemset(state, 0, sizeof(fheap_heap_state_t)); + if(check_stats(*fh, state)) + TEST_ERROR + + /* Prepare for querying the size of a file with an empty heap */ + + /* Close (empty) heap */ + if(H5HF_close(*fh, dxpl) < 0) + FAIL_STACK_ERROR + } /* end if */ + + /* Close file */ + if(H5Fclose(*file) < 0) + FAIL_STACK_ERROR + + /* Get the size of a file w/empty heap*/ + if((*empty_size = h5_get_file_size(filename)) == 0) + TEST_ERROR + + /* Re-open the file */ + if((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (*f = H5I_object(*file))) + FAIL_STACK_ERROR + + /* Check for deleting the entire heap */ + if(tparam->del_dir == FHEAP_DEL_HEAP) { + /* Create absolute heap */ + if(NULL == (*fh = H5HF_create(*f, dxpl, cparam))) + FAIL_STACK_ERROR + if(H5HF_get_id_len(*fh, &id_len) < 0) + FAIL_STACK_ERROR + if(id_len > HEAP_ID_LEN) + TEST_ERROR + if(H5HF_get_heap_addr(*fh, fh_addr) < 0) + FAIL_STACK_ERROR + if(!H5F_addr_defined(*fh_addr)) + TEST_ERROR + HDmemset(state, 0, sizeof(fheap_heap_state_t)); + if(check_stats(*fh, state)) + TEST_ERROR + } /* end if */ + else { + /* Re-open heap */ + if(NULL == (*fh = H5HF_open(*f, dxpl, *fh_addr))) + FAIL_STACK_ERROR + } /* end else */ + + /* Success */ + return(0); + +error: + return(-1); +} /* end open_heap() */ + + +/*------------------------------------------------------------------------- + * Function: reopen_heap + * + * Purpose: Perform common "re-open" operations on heap for testing + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, August 4, 2006 + * + *------------------------------------------------------------------------- + */ +static int +reopen_heap(H5F_t *f, hid_t dxpl, H5HF_t **fh, haddr_t fh_addr, + const fheap_test_param_t *tparam) +{ + /* Check for closing & re-opening the heap */ + if(tparam->reopen_heap) { + /* Close (empty) heap */ + if(H5HF_close(*fh, dxpl) < 0) + FAIL_STACK_ERROR + + /* Re-open heap */ + if(NULL == (*fh = H5HF_open(f, dxpl, fh_addr))) + FAIL_STACK_ERROR + } /* end if */ + + /* Success */ + return(0); + +error: + return(-1); +} /* end reopen_heap() */ + + +/*------------------------------------------------------------------------- + * Function: close_heap + * + * Purpose: Perform common "close" operations on file & heap for testing + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, August 4, 2006 + * + *------------------------------------------------------------------------- + */ +static int +close_heap(char *filename, hid_t dxpl, fheap_test_param_t *tparam, + hid_t file, H5F_t *f, H5HF_t **fh, haddr_t fh_addr, + fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids, + off_t empty_size) +{ + off_t file_size; /* Size of file currently */ + + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, fh, fh_addr, tparam) < 0) + TEST_ERROR + + /* Check up on heap... */ + if(check_stats(*fh, state)) + TEST_ERROR + + /* Check for deleting the objects in the heap */ + if(tparam->del_dir != FHEAP_DEL_HEAP) { + /* Delete objects inserted (either forward or reverse order) */ + if(del_objs(f, dxpl, fh, tparam, state, keep_ids)) + FAIL_STACK_ERROR + } /* end if */ + + /* Close the fractal heap */ + if(H5HF_close(*fh, dxpl) < 0) + FAIL_STACK_ERROR + *fh = NULL; + + /* Check for deleting the entire heap */ + if(tparam->del_dir == FHEAP_DEL_HEAP) { + /* Delete heap */ + if(H5HF_delete(f, dxpl, fh_addr) < 0) + FAIL_STACK_ERROR + } /* end if */ + + /* Close the file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + /* Get the size of the file */ + if((file_size = h5_get_file_size(filename)) == 0) + TEST_ERROR + + /* Verify the file is correct size */ + if(file_size != empty_size) + TEST_ERROR + + /* Success */ + return(0); + +error: + return(-1); +} /* end close_heap() */ + + +/*------------------------------------------------------------------------- * Function: del_objs_half_refill * * Purpose: Remove half of objects from heap and refill @@ -407,7 +668,7 @@ del_objs_half_refill(H5F_t *f, hid_t dxpl, H5HF_t **fh, fheap_test_param_t *tpar if(H5HF_get_heap_addr(*fh, &fh_addr) < 0) FAIL_STACK_ERROR if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR + TEST_ERROR } /* end if */ /* Remove half of total objects from heap */ @@ -422,15 +683,8 @@ del_objs_half_refill(H5F_t *f, hid_t dxpl, H5HF_t **fh, fheap_test_param_t *tpar FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(*fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (*fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, fh, fh_addr, tparam) < 0) + TEST_ERROR /* Adjust index of object to delete next */ if(tparam->del_dir == FHEAP_DEL_FORWARD) @@ -451,15 +705,8 @@ del_objs_half_refill(H5F_t *f, hid_t dxpl, H5HF_t **fh, fheap_test_param_t *tpar FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(*fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (*fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, fh, fh_addr, tparam) < 0) + TEST_ERROR /* Adjust index of object to delete next */ if(tparam->del_dir == FHEAP_DEL_FORWARD) @@ -507,14 +754,14 @@ del_objs(H5F_t *f, hid_t dxpl, H5HF_t **fh, fheap_test_param_t *tparam, /* Check for first deleting half of objects & then re-inserting them */ if(tparam->drain_half == FHEAP_DEL_DRAIN_HALF) if(del_objs_half_refill(f, dxpl, fh, tparam, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ if(tparam->reopen_heap) { if(H5HF_get_heap_addr(*fh, &fh_addr) < 0) FAIL_STACK_ERROR if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR + TEST_ERROR } /* end if */ /* Remove all objects from heap */ @@ -528,15 +775,8 @@ del_objs(H5F_t *f, hid_t dxpl, H5HF_t **fh, fheap_test_param_t *tparam, FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(*fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (*fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, fh, fh_addr, tparam) < 0) + TEST_ERROR /* Adjust index of object to delete next */ if(tparam->del_dir == FHEAP_DEL_FORWARD) @@ -550,7 +790,7 @@ del_objs(H5F_t *f, hid_t dxpl, H5HF_t **fh, fheap_test_param_t *tparam, /* Check up on heap... */ if(check_stats(*fh, state)) - FAIL_STACK_ERROR + TEST_ERROR /* Operations succeeded */ return(0); @@ -627,11 +867,11 @@ fill_heap(H5HF_t *fh, hid_t dxpl, unsigned block_row, size_t obj_size, if(num_ids > shared_alloc_ids_g) { shared_alloc_ids_g = MAX(1024, (shared_alloc_ids_g * 2)); if(NULL == (shared_ids_g = H5MM_realloc(shared_ids_g, HEAP_ID_LEN * shared_alloc_ids_g))) - FAIL_STACK_ERROR + TEST_ERROR if(NULL == (shared_lens_g = H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g))) - FAIL_STACK_ERROR + TEST_ERROR if(NULL == (shared_offs_g = H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g))) - FAIL_STACK_ERROR + TEST_ERROR curr_id_ptr = &shared_ids_g[(num_ids - 1) * HEAP_ID_LEN]; curr_len_ptr = &shared_lens_g[(num_ids - 1)]; curr_off_ptr = &shared_offs_g[(num_ids - 1)]; @@ -649,7 +889,7 @@ fill_heap(H5HF_t *fh, hid_t dxpl, unsigned block_row, size_t obj_size, /* Check stats for heap */ if(check_stats(fh, state)) - FAIL_STACK_ERROR + TEST_ERROR /* Adjust object & ID pointers */ wobj++; @@ -678,11 +918,11 @@ fill_heap(H5HF_t *fh, hid_t dxpl, unsigned block_row, size_t obj_size, if(num_ids > shared_alloc_ids_g) { shared_alloc_ids_g = MAX(1024, (shared_alloc_ids_g * 2)); if(NULL == (shared_ids_g = H5MM_realloc(shared_ids_g, HEAP_ID_LEN * shared_alloc_ids_g))) - FAIL_STACK_ERROR + TEST_ERROR if(NULL == (shared_lens_g = H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g))) - FAIL_STACK_ERROR + TEST_ERROR if(NULL == (shared_offs_g = H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g))) - FAIL_STACK_ERROR + TEST_ERROR curr_id_ptr = &shared_ids_g[(num_ids - 1) * HEAP_ID_LEN]; curr_len_ptr = &shared_lens_g[(num_ids - 1)]; curr_off_ptr = &shared_offs_g[(num_ids - 1)]; @@ -700,7 +940,7 @@ fill_heap(H5HF_t *fh, hid_t dxpl, unsigned block_row, size_t obj_size, /* Verify that the heap is full */ if(check_stats(fh, state)) - FAIL_STACK_ERROR + TEST_ERROR } /* end if */ else last_obj_len = obj_size; /* Normal sized last object */ @@ -720,7 +960,7 @@ fill_heap(H5HF_t *fh, hid_t dxpl, unsigned block_row, size_t obj_size, /* Check that object is correct */ wobj = &shared_wobj_g[*curr_off_ptr]; if(HDmemcmp(wobj, shared_robj_g, *curr_len_ptr)) - FAIL_STACK_ERROR + TEST_ERROR /* Adjust object & ID pointers */ curr_id_ptr += HEAP_ID_LEN; @@ -734,11 +974,11 @@ fill_heap(H5HF_t *fh, hid_t dxpl, unsigned block_row, size_t obj_size, if(keep_ids->num_ids + num_ids > keep_ids->alloc_ids) { keep_ids->alloc_ids = MAX(1024, (keep_ids->alloc_ids * 2)); if(NULL == (keep_ids->ids = H5MM_realloc(keep_ids->ids, HEAP_ID_LEN * keep_ids->alloc_ids))) - FAIL_STACK_ERROR + TEST_ERROR if(NULL == (keep_ids->lens = H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids))) - FAIL_STACK_ERROR + TEST_ERROR if(NULL == (keep_ids->offs = H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids))) - FAIL_STACK_ERROR + TEST_ERROR } /* end if */ /* Append the IDs onto the array */ @@ -846,7 +1086,7 @@ fill_root_row(H5HF_t *fh, hid_t dxpl, unsigned row, size_t obj_size, /* Fill a direct heap block up */ if(fill_heap(fh, dxpl, row, obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Operations succeeded */ @@ -892,7 +1132,7 @@ fill_partial_row(H5HF_t *fh, hid_t dxpl, unsigned row, unsigned width, /* Fill a direct heap block up */ if(fill_heap(fh, dxpl, row, obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Operations succeeded */ @@ -927,7 +1167,7 @@ fill_row(H5HF_t *fh, hid_t dxpl, unsigned row, size_t obj_size, /* Fill the entire row (with the partial row fill routine) */ if(fill_partial_row(fh, dxpl, row, DTABLE_WIDTH(fh), obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Operations succeeded */ return(0); @@ -968,7 +1208,7 @@ fill_root_direct(H5HF_t *fh, hid_t dxpl, size_t obj_size, /* Loop over rows */ for(row = 0; row < max_dblock_rows; row++) if(fill_root_row(fh, dxpl, row, obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Operations succeeded */ return(0); @@ -1008,7 +1248,7 @@ fill_2nd_indirect(H5HF_t *fh, hid_t dxpl, unsigned pos, size_t obj_size, /* Loop over rows */ for(row = 0; row < max_dblock_rows; row++) if(fill_row(fh, dxpl, row, obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Operations succeeded */ return(0); @@ -1047,7 +1287,7 @@ fill_all_direct(H5HF_t *fh, hid_t dxpl, size_t obj_size, /* Loop over rows */ for(row = 0; row < max_dblock_rows; row++) if(fill_row(fh, dxpl, row, obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Operations succeeded */ return(0); @@ -1086,7 +1326,7 @@ fill_2nd_indirect_row(H5HF_t *fh, hid_t dxpl, unsigned pos, size_t obj_size, /* Loop over row of indirect blocks */ for(u = 0; u < width; u++) if(fill_2nd_indirect(fh, dxpl, pos, obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Operations succeeded */ return(0); @@ -1125,7 +1365,7 @@ fill_all_2nd_indirect_rows(H5HF_t *fh, hid_t dxpl, size_t obj_size, /* Loop over rows of 2nd level deep indirect blocks */ for(u = 0; u < (H5V_log2_of2(width) + 1); u++) if(fill_2nd_indirect_row(fh, dxpl, (u + 1), obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Operations succeeded */ return(0); @@ -1159,12 +1399,12 @@ fill_3rd_indirect(H5HF_t *fh, hid_t dxpl, unsigned pos, size_t obj_size, /* Fill all direct block rows in third level indirect block */ if(fill_all_direct(fh, dxpl, obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill rows of recursive indirect blocks in third level indirect block */ for(u = 0; u < pos; u++) if(fill_2nd_indirect_row(fh, dxpl, (u + 1), obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Operations succeeded */ return(0); @@ -1204,7 +1444,7 @@ fill_3rd_indirect_row(H5HF_t *fh, hid_t dxpl, unsigned pos, size_t obj_size, for(u = 0; u < width; u++) /* Fill third level indirect block */ if(fill_3rd_indirect(fh, dxpl, pos, obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Operations succeeded */ return(0); @@ -1244,7 +1484,7 @@ fill_all_3rd_indirect_rows(H5HF_t *fh, hid_t dxpl, size_t obj_size, for(u = 0; u < (H5V_log2_of2(width) + 1); u++) /* Fill row of 3rd level indirect blocks */ if(fill_3rd_indirect_row(fh, dxpl, (u + 1), obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Operations succeeded */ return(0); @@ -1284,16 +1524,16 @@ fill_4th_indirect_row(H5HF_t *fh, hid_t dxpl, unsigned pos, size_t obj_size, for(u = 0; u < width; u++) { /* Fill all direct block rows in fourth level indirect block */ if(fill_all_direct(fh, dxpl, obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill all rows of 2nd level deep indirect blocks in fourth level indirect block */ if(fill_all_2nd_indirect_rows(fh, dxpl, obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill rows of third level indirect blocks in fourth level indirect block */ for(v = 0; v < pos; v++) if(fill_3rd_indirect_row(fh, dxpl, (v + 1), obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Operations succeeded */ @@ -1334,7 +1574,7 @@ fill_all_4th_indirect_rows(H5HF_t *fh, hid_t dxpl, size_t obj_size, for(u = 0; u < (H5V_log2_of2(width) + 1); u++) { /* Fill row of 4th level indirect blocks */ if(fill_4th_indirect_row(fh, dxpl, (u + 1), obj_size, state, keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Account for root indirect block doubling # of rows again */ /* (From 16 rows to the max. # of rows: 22) */ @@ -1381,10 +1621,13 @@ static int test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam) { hid_t file = -1; /* File ID */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_create_t test_cparam; /* Creation parameters for heap */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Heap address in file */ + off_t empty_size; /* File size, w/o heap */ + off_t file_size; /* File size, after deleting heap */ size_t id_len; /* Size of fractal heap IDs */ fheap_heap_state_t state; /* State of fractal heap */ @@ -1393,11 +1636,23 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam /* Create the file to work on */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Close file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + /* Get the size of a file w/empty heap*/ + if((empty_size = h5_get_file_size(filename)) == 0) TEST_ERROR + /* Re-open the file */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + /* Get a pointer to the internal file object */ if(NULL == (f = H5I_object(file))) - STACK_ERROR + FAIL_STACK_ERROR /* * Test fractal heap creation (w/absolute address mapping) @@ -1408,10 +1663,14 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam if(H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR if(id_len > HEAP_ID_LEN) + TEST_ERROR + if(H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR + if(!H5F_addr_defined(fh_addr)) + TEST_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); if(check_stats(fh, &state)) - FAIL_STACK_ERROR + TEST_ERROR PASSED() /* Query the type of address mapping */ @@ -1420,14 +1679,26 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam if(H5HF_get_cparam_test(fh, &test_cparam) < 0) FAIL_STACK_ERROR if(HDmemcmp(cparam, &test_cparam, sizeof(H5HF_create_t))) - FAIL_STACK_ERROR + TEST_ERROR /* Close the fractal heap */ if(H5HF_close(fh, H5P_DATASET_XFER_DEFAULT) < 0) - TEST_ERROR + FAIL_STACK_ERROR + + /* Delete heap */ + if(H5HF_delete(f, H5P_DATASET_XFER_DEFAULT, fh_addr) < 0) + FAIL_STACK_ERROR /* Close the file */ if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + /* Get the size of the file */ + if((file_size = h5_get_file_size(filename)) == 0) + TEST_ERROR + + /* Verify the file is correct size */ + if(file_size != empty_size) TEST_ERROR /* All tests passed */ @@ -1463,7 +1734,7 @@ static int test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam) { hid_t file = -1; /* File ID */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_create_t test_cparam; /* Creation parameters for heap */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ @@ -1494,18 +1765,18 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam if(H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR + TEST_ERROR if(H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR + TEST_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); if(check_stats(fh, &state)) - FAIL_STACK_ERROR + TEST_ERROR /* Close the fractal heap */ if(H5HF_close(fh, H5P_DATASET_XFER_DEFAULT) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Re-open the heap */ if(NULL == (fh = H5HF_open(f, H5P_DATASET_XFER_DEFAULT, fh_addr))) @@ -1516,15 +1787,15 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam if(H5HF_get_cparam_test(fh, &test_cparam) < 0) FAIL_STACK_ERROR if(HDmemcmp(cparam, &test_cparam, sizeof(H5HF_create_t))) - FAIL_STACK_ERROR + TEST_ERROR /* Close the fractal heap */ if(H5HF_close(fh, H5P_DATASET_XFER_DEFAULT) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Close the file */ if(H5Fclose(file) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* All tests passed */ PASSED() @@ -1561,7 +1832,7 @@ test_abs_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -1573,11 +1844,11 @@ test_abs_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa /* Create the file to work on */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Get a pointer to the internal file object */ if(NULL == (f = H5I_object(file))) - STACK_ERROR + FAIL_STACK_ERROR /* Create absolute heap */ if(NULL == (fh = H5HF_create(f, dxpl, cparam))) @@ -1585,25 +1856,18 @@ test_abs_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa if(H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR + TEST_ERROR if(H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR + TEST_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); if(check_stats(fh, &state)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* * Test inserting first (small) object into absolute heap @@ -1617,15 +1881,8 @@ test_abs_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check for correctly sized heap */ if(check_stats(fh, &state)) @@ -1673,7 +1930,7 @@ test_abs_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -1716,15 +1973,8 @@ test_abs_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert second object */ if(add_obj(fh, dxpl, 20, SMALL_OBJ_SIZE2, &state, NULL)) @@ -1773,7 +2023,7 @@ test_abs_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -1822,15 +2072,8 @@ test_abs_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Close the fractal heap */ if(H5HF_close(fh, dxpl) < 0) @@ -1876,7 +2119,7 @@ test_abs_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -1925,15 +2168,8 @@ test_abs_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force root indirect block creation */ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); @@ -1987,7 +2223,7 @@ test_abs_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -2036,15 +2272,8 @@ test_abs_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill the second direct block heap up (also creates initial root indirect block) */ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); @@ -2099,7 +2328,7 @@ test_abs_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -2156,15 +2385,8 @@ test_abs_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force creation of third direct block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); @@ -2215,7 +2437,7 @@ test_abs_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -2260,15 +2482,8 @@ test_abs_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Close the fractal heap */ if(H5HF_close(fh, dxpl) < 0) @@ -2314,7 +2529,7 @@ test_abs_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -2359,15 +2574,8 @@ test_abs_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force expanding root indirect block to two rows */ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1); @@ -2421,7 +2629,7 @@ test_abs_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -2466,15 +2674,8 @@ test_abs_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill second root indirect row */ if(fill_root_row(fh, dxpl, 1, fill_size, &state, NULL)) @@ -2525,7 +2726,7 @@ test_abs_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -2574,15 +2775,8 @@ test_abs_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force expanding root indirect block to four rows */ /* (Goes to four rows because it's doubling) */ @@ -2640,7 +2834,7 @@ test_abs_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -2687,15 +2881,8 @@ test_abs_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Close the fractal heap */ if(H5HF_close(fh, dxpl) < 0) @@ -2741,7 +2928,7 @@ test_abs_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -2786,15 +2973,8 @@ test_abs_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Close the fractal heap */ if(H5HF_close(fh, dxpl) < 0) @@ -2840,7 +3020,7 @@ test_abs_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_ { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -2885,15 +3065,8 @@ test_abs_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_ FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force creation of first recursive indirect block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); @@ -2945,7 +3118,7 @@ test_abs_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -2996,15 +3169,8 @@ test_abs_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force creation of second direct block in * first recursive indirect block @@ -3058,7 +3224,7 @@ test_abs_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_ { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -3104,15 +3270,8 @@ test_abs_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_ FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill first recursive indirect block */ if(fill_2nd_indirect(fh, dxpl, 1, fill_size, &state, NULL)) @@ -3164,7 +3323,7 @@ test_abs_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -3214,15 +3373,8 @@ test_abs_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force creation of second * recursive indirect block @@ -3278,7 +3430,7 @@ test_abs_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -3328,15 +3480,8 @@ test_abs_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill 2nd recursive indirect block */ if(fill_2nd_indirect(fh, dxpl, 1, fill_size, &state, NULL)) @@ -3389,7 +3534,7 @@ test_abs_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -3435,15 +3580,8 @@ test_abs_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill row of recursive indirect blocks */ if(fill_2nd_indirect_row(fh, dxpl, 1, fill_size, &state, NULL)) @@ -3494,7 +3632,7 @@ test_abs_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -3544,15 +3682,8 @@ test_abs_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force creation of second * recursive indirect block @@ -3606,7 +3737,7 @@ test_abs_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -3652,15 +3783,8 @@ test_abs_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, NULL)) @@ -3712,7 +3836,7 @@ test_abs_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -3762,15 +3886,8 @@ test_abs_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force creation of third level deep * recursive indirect block @@ -3825,7 +3942,7 @@ test_abs_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -3879,15 +3996,8 @@ test_abs_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill row of recursive indirect blocks in third level indirect block */ if(fill_2nd_indirect_row(fh, dxpl, 1, fill_size, &state, NULL)) @@ -3939,7 +4049,7 @@ test_abs_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -3989,15 +4099,8 @@ test_abs_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill 1st row of 3rd level indirect blocks */ if(fill_3rd_indirect_row(fh, dxpl, 1, fill_size, &state, NULL)) @@ -4049,7 +4152,7 @@ test_abs_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -4099,15 +4202,8 @@ test_abs_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ if(fill_all_3rd_indirect_rows(fh, dxpl, fill_size, &state, NULL)) @@ -4160,7 +4256,7 @@ test_abs_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -4214,15 +4310,8 @@ test_abs_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force creation of four level deep * recursive indirect block @@ -4278,7 +4367,7 @@ test_abs_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -4340,15 +4429,8 @@ test_abs_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill first row of 3rd level deep indirect blocks in fourth level indirect block */ if(fill_3rd_indirect_row(fh, dxpl, 1, fill_size, &state, NULL)) @@ -4401,7 +4483,7 @@ test_abs_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -4455,15 +4537,8 @@ test_abs_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill 1st row of 4th level indirect blocks */ if(fill_4th_indirect_row(fh, dxpl, 1, fill_size, &state, NULL)) @@ -4516,7 +4591,7 @@ test_abs_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -4570,15 +4645,8 @@ test_abs_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 4th level indirect blocks */ if(fill_all_4th_indirect_rows(fh, dxpl, fill_size, &state, NULL)) @@ -4634,7 +4702,7 @@ test_abs_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -4681,60 +4749,32 @@ test_abs_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ if(fill_all_3rd_indirect_rows(fh, dxpl, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 4th level indirect blocks */ if(fill_all_4th_indirect_rows(fh, dxpl, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to force creation of five level deep * recursive indirect block @@ -4787,7 +4827,7 @@ test_abs_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -4826,15 +4866,8 @@ test_abs_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* * Test removing bogus IDs from heap @@ -4923,7 +4956,7 @@ test_abs_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -5000,15 +5033,8 @@ test_abs_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.heap_size = DBLOCK_SIZE(fh, 0); @@ -5024,15 +5050,8 @@ test_abs_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.heap_size = 0; @@ -5093,7 +5112,7 @@ test_abs_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -5171,15 +5190,8 @@ test_abs_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.heap_size = DBLOCK_SIZE(fh, 0); @@ -5195,15 +5207,8 @@ test_abs_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.man_free_space -= sizeof(obj); @@ -5216,15 +5221,8 @@ test_abs_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.man_free_space += sizeof(obj); @@ -5237,15 +5235,8 @@ test_abs_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.heap_size = 0; @@ -5307,7 +5298,7 @@ test_abs_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -5385,15 +5376,8 @@ test_abs_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ for(u = 0; u < 4; u++) { @@ -5412,15 +5396,8 @@ test_abs_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.heap_size = 0; @@ -5482,7 +5459,7 @@ test_abs_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -5564,15 +5541,8 @@ test_abs_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ for(u = 0; u < 4; u++) { @@ -5595,15 +5565,8 @@ test_abs_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ /* (Goes to 8 rows because of doubling) */ @@ -5625,15 +5588,8 @@ test_abs_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.man_alloc_size -= DBLOCK_SIZE(fh, 3); @@ -5652,15 +5608,8 @@ test_abs_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ /* (Goes to 4 rows because of halving) */ @@ -5681,15 +5630,8 @@ test_abs_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t } /* end else */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.heap_size = 0; @@ -5755,7 +5697,7 @@ test_abs_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ @@ -5838,15 +5780,8 @@ test_abs_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ for(u = 0; u < 4; u++) { @@ -5869,15 +5804,8 @@ test_abs_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ /* (Goes to 8 rows because of doubling) */ @@ -5901,15 +5829,8 @@ test_abs_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ /* (Goes to 16 rows because of doubling) */ @@ -5931,15 +5852,8 @@ test_abs_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.man_alloc_size -= DBLOCK_SIZE(fh, 3); @@ -5953,15 +5867,8 @@ test_abs_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.man_alloc_size -= DBLOCK_SIZE(fh, 5); @@ -5980,15 +5887,8 @@ test_abs_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ /* (Goes to 8 rows because of halving) */ @@ -6008,15 +5908,8 @@ test_abs_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ /* (Goes to 4 rows because of halving) */ @@ -6037,15 +5930,8 @@ test_abs_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param } /* end else */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ state.heap_size = 0; @@ -6113,138 +5999,45 @@ test_abs_remove_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "removing all objects from root direct block of absolute heap %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, dxpl, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + TEST_ERROR - /* Prepare for querying the size of a file with an empty heap */ - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) + /* Fill the heap up */ + state.heap_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); + state.man_alloc_size = DBLOCK_SIZE(fh, 0); + state.man_free_space = DBLOCK_FREE(fh, 0); + if(fill_heap(fh, dxpl, 0, fill_size, &state, &keep_ids)) TEST_ERROR - /* Close file */ - if(H5Fclose(file)<0) TEST_ERROR; - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR + /* Free resources */ + H5MM_xfree(keep_ids.ids); + H5MM_xfree(keep_ids.lens); + H5MM_xfree(keep_ids.offs); - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Test filling & removing all (small) objects from root direct block of absolute heap - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); - - /* Fill the heap up */ - state.heap_size = DBLOCK_SIZE(fh, 0); - state.man_size = DBLOCK_SIZE(fh, 0); - state.man_alloc_size = DBLOCK_SIZE(fh, 0); - state.man_free_space = DBLOCK_FREE(fh, 0); - if(fill_heap(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close the file */ - if(H5Fclose(file) < 0) - TEST_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) - TEST_ERROR - - /* Verify the file is correct size */ - if(file_size != empty_size) - TEST_ERROR - - /* Free resources */ - H5MM_xfree(keep_ids.ids); - H5MM_xfree(keep_ids.lens); - H5MM_xfree(keep_ids.offs); - - /* All tests passed */ - PASSED() + /* All tests passed */ + PASSED() return(0); @@ -6253,8 +6046,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -6283,90 +6074,24 @@ test_abs_remove_two_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "removing all objects from two direct blocks of absolute heap %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, dxpl, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) TEST_ERROR; - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Test filling & removing all (small) objects from two direct blocks of absolute heap - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Fill the first block in heap */ state.heap_size = DBLOCK_SIZE(fh, 0); @@ -6374,22 +6099,15 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); if(fill_heap(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Check up on heap... */ if(check_stats(fh, &state)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill the second block in heap */ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); @@ -6397,45 +6115,11 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_alloc_size += DBLOCK_SIZE(fh, 0); state.man_free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); if(fill_heap(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) TEST_ERROR - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -6453,8 +6137,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -6483,158 +6165,55 @@ test_abs_remove_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "removing all objects from first row of direct blocks of absolute heap %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, dxpl, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Close file */ - if(H5Fclose(file)<0) TEST_ERROR; - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Fill first row of direct blocks */ + if(fill_root_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR + /* Free resources */ + H5MM_xfree(keep_ids.ids); + H5MM_xfree(keep_ids.lens); + H5MM_xfree(keep_ids.offs); - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR + /* All tests passed */ + PASSED() - /* - * Test filling & removing all (small) objects from first row of direct blocks of absolute heap - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); + return(0); - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); - - /* Fill first row of direct blocks */ - if(fill_root_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - TEST_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - - /* Verify the file is correct size */ - if(file_size != empty_size) - TEST_ERROR - - /* Free resources */ - H5MM_xfree(keep_ids.ids); - H5MM_xfree(keep_ids.lens); - H5MM_xfree(keep_ids.offs); - - /* All tests passed */ - PASSED() - - return(0); - -error: - H5E_BEGIN_TRY { - H5MM_xfree(keep_ids.ids); - H5MM_xfree(keep_ids.lens); - H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); - if(fh) - H5HF_close(fh, dxpl); - H5Fclose(file); - } H5E_END_TRY; - return(1); -} /* test_abs_remove_first_row() */ +error: + H5E_BEGIN_TRY { + H5MM_xfree(keep_ids.ids); + H5MM_xfree(keep_ids.lens); + H5MM_xfree(keep_ids.offs); + if(fh) + H5HF_close(fh, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return(1); +} /* test_abs_remove_first_row() */ /*------------------------------------------------------------------------- @@ -6657,486 +6236,34 @@ test_abs_remove_first_two_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_par { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "removing all objects from first two rows of direct blocks of absolute heap %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, dxpl, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) TEST_ERROR; - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Test filling & removing all (small) objects from first row of direct blocks of absolute heap - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); - - /* Fill first two rows of direct blocks */ - if(fill_root_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - if(fill_root_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - TEST_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - - /* Verify the file is correct size */ - if(file_size != empty_size) - TEST_ERROR - - /* Free resources */ - H5MM_xfree(keep_ids.ids); - H5MM_xfree(keep_ids.lens); - H5MM_xfree(keep_ids.offs); - - /* All tests passed */ - PASSED() - - return(0); - -error: - H5E_BEGIN_TRY { - H5MM_xfree(keep_ids.ids); - H5MM_xfree(keep_ids.lens); - H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); - if(fh) - H5HF_close(fh, dxpl); - H5Fclose(file); - } H5E_END_TRY; - return(1); -} /* test_abs_remove_first_two_rows() */ - - -/*------------------------------------------------------------------------- - * Function: test_abs_remove_first_four_rows - * - * Purpose: Test filling and removing all objects from first four rows of - * direct blocks in heap - * - * Return: Success: 0 - * - * Failure: 1 - * - * Programmer: Quincey Koziol - * Tuesday, June 13, 2006 - * - *------------------------------------------------------------------------- - */ -static int -test_abs_remove_first_four_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) -{ - hid_t file = -1; /* File ID */ - hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from first four rows of direct blocks of absolute heap %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, dxpl, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) TEST_ERROR; - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Test filling & removing all (small) objects from first row of direct blocks of absolute heap - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); - - /* Fill first two rows of direct blocks */ - if(fill_root_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - if(fill_root_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - if(fill_root_row(fh, dxpl, 2, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - if(fill_root_row(fh, dxpl, 3, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - TEST_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - - /* Verify the file is correct size */ - if(file_size != empty_size) - TEST_ERROR - - /* Free resources */ - H5MM_xfree(keep_ids.ids); - H5MM_xfree(keep_ids.lens); - H5MM_xfree(keep_ids.offs); - - /* All tests passed */ - PASSED() - - return(0); - -error: - H5E_BEGIN_TRY { - H5MM_xfree(keep_ids.ids); - H5MM_xfree(keep_ids.lens); - H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); - if(fh) - H5HF_close(fh, dxpl); - H5Fclose(file); - } H5E_END_TRY; - return(1); -} /* test_abs_remove_first_four_rows() */ - - -/*------------------------------------------------------------------------- - * Function: test_abs_remove_all_root_direct - * - * Purpose: Test filling and removing all objects from all direct blocks - * in root indirect block of heap - * - * Return: Success: 0 - * - * Failure: 1 - * - * Programmer: Quincey Koziol - * Tuesday, June 13, 2006 - * - *------------------------------------------------------------------------- - */ -static int -test_abs_remove_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) -{ - hid_t file = -1; /* File ID */ - hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from all direct blocks of root group in absolute heap %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, dxpl, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) TEST_ERROR; - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Test filling & removing all (small) objects from first row of direct blocks of absolute heap - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); - - /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - fh = NULL; - /* Close the file */ - if(H5Fclose(file) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) + + /* Fill first two rows of direct blocks */ + if(fill_root_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) + TEST_ERROR + if(fill_root_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -7154,21 +6281,19 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); } H5E_END_TRY; return(1); -} /* test_abs_remove_all_root_direct() */ +} /* test_abs_remove_first_two_rows() */ /*------------------------------------------------------------------------- - * Function: test_abs_remove_2nd_indirect + * Function: test_abs_remove_first_four_rows * - * Purpose: Test filling and removing all objects up to 2nd level indirect - * blocks of heap + * Purpose: Test filling and removing all objects from first four rows of + * direct blocks in heap * * Return: Success: 0 * @@ -7180,140 +6305,113 @@ error: *------------------------------------------------------------------------- */ static int -test_abs_remove_2nd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_abs_remove_first_four_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from 2nd level indirect blocks of absolute heap %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + const char *base_desc = "removing all objects from first four rows of direct blocks of absolute heap %s"; /* Test description */ - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, dxpl, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Close file */ - if(H5Fclose(file)<0) TEST_ERROR; - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Fill first two rows of direct blocks */ + if(fill_root_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if(fill_root_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) + TEST_ERROR + if(fill_root_row(fh, dxpl, 2, fill_size, &state, &keep_ids)) + TEST_ERROR + if(fill_root_row(fh, dxpl, 3, fill_size, &state, &keep_ids)) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Test filling & removing all (small) objects from first row of direct blocks of absolute heap - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); - /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + TEST_ERROR - /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + /* Free resources */ + H5MM_xfree(keep_ids.ids); + H5MM_xfree(keep_ids.lens); + H5MM_xfree(keep_ids.offs); - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR + /* All tests passed */ + PASSED() - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + return(0); - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR +error: + H5E_BEGIN_TRY { + H5MM_xfree(keep_ids.ids); + H5MM_xfree(keep_ids.lens); + H5MM_xfree(keep_ids.offs); + if(fh) + H5HF_close(fh, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return(1); +} /* test_abs_remove_first_four_rows() */ - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR + +/*------------------------------------------------------------------------- + * Function: test_abs_remove_all_root_direct + * + * Purpose: Test filling and removing all objects from all direct blocks + * in root indirect block of heap + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Tuesday, June 13, 2006 + * + *------------------------------------------------------------------------- + */ +static int +test_abs_remove_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5HF_t *fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + off_t empty_size; /* Size of a file with an empty heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "removing all objects from all direct blocks of root group in absolute heap %s"; /* Test description */ - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - fh = NULL; - /* Close the file */ - if(H5Fclose(file) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) + + /* Fill direct blocks in root indirect block */ + if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -7331,20 +6429,18 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); } H5E_END_TRY; return(1); -} /* test_abs_remove_2nd_indirect() */ +} /* test_abs_remove_all_root_direct() */ /*------------------------------------------------------------------------- - * Function: test_abs_remove_3rd_indirect + * Function: test_abs_remove_2nd_indirect * - * Purpose: Test filling and removing all objects up to 3rd level indirect + * Purpose: Test filling and removing all objects up to 2nd level indirect * blocks of heap * * Return: Success: 0 @@ -7352,164 +6448,124 @@ error: * Failure: 1 * * Programmer: Quincey Koziol - * Monday, July 24, 2006 + * Tuesday, June 13, 2006 * *------------------------------------------------------------------------- */ static int -test_abs_remove_3rd_indirect(hid_t -#ifdef LATER - UNUSED -#endif /* LATER */ - fapl, H5HF_create_t -#ifdef LATER - UNUSED -#endif /* LATER */ - *cparam, fheap_test_param_t *tparam) +test_abs_remove_2nd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { -#ifndef LATER hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from 3rd level indirect blocks of absolute heap %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + const char *base_desc = "removing all objects from 2nd level indirect blocks of absolute heap %s"; /* Test description */ - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + TEST_ERROR - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, dxpl, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - /* Prepare for querying the size of a file with an empty heap */ + /* Fill direct blocks in root indirect block */ + if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) + TEST_ERROR - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) + /* Fill all rows of 2nd level indirect blocks */ + if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) TEST_ERROR - /* Close file */ - if(H5Fclose(file)<0) TEST_ERROR; - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR + /* Free resources */ + H5MM_xfree(keep_ids.ids); + H5MM_xfree(keep_ids.lens); + H5MM_xfree(keep_ids.offs); - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR + /* All tests passed */ + PASSED() + + return(0); + +error: + H5E_BEGIN_TRY { + H5MM_xfree(keep_ids.ids); + H5MM_xfree(keep_ids.lens); + H5MM_xfree(keep_ids.offs); + if(fh) + H5HF_close(fh, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return(1); +} /* test_abs_remove_2nd_indirect() */ - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR -#else /* LATER */ + +/*------------------------------------------------------------------------- + * Function: test_abs_remove_3rd_indirect + * + * Purpose: Test filling and removing all objects up to 3rd level indirect + * blocks of heap + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Monday, July 24, 2006 + * + *------------------------------------------------------------------------- + */ +static int +test_abs_remove_3rd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5HF_t *fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + off_t empty_size; /* Size of a file with an empty heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "removing all objects from 3rd level indirect blocks of absolute heap %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ -#endif /* LATER */ - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + TEST_ERROR -#ifndef LATER - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + TEST_ERROR - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ if(fill_all_3rd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -7519,27 +6575,19 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); /* All tests passed */ PASSED() -#else /* LATER */ - SKIPPED(); - puts(" Takes too long right now"); -#endif /* LATER */ return(0); -#ifndef LATER error: H5E_BEGIN_TRY { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); } H5E_END_TRY; return(1); -#endif /* LATER */ } /* test_abs_remove_3rd_indirect() */ #endif /* QAK */ @@ -7568,89 +6616,24 @@ test_abs_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "inserting object that is too large for starting block, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - obj_size = DBLOCK_SIZE(fh, 0) + 1; state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1); @@ -7663,45 +6646,11 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -7719,8 +6668,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -7750,88 +6697,24 @@ test_abs_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ - size_t obj_size; /* Size of object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "skipping starting block, then adding object back to first block, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); + off_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "skipping starting block, then adding object back to first block, then remove all objects %s"; /* Test description */ + + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + TEST_ERROR + + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + TEST_ERROR - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); /* Insert object too large for starting block size */ obj_size = DBLOCK_SIZE(fh, 0) + 1; @@ -7846,77 +6729,29 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert an object to fill up the heap block just created */ obj_size = DBLOCK_FREE(fh, 2) - obj_size; if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert second "real" object, which should go in earlier direct block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); if(add_obj(fh, dxpl, 20, SMALL_OBJ_SIZE2, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -7934,8 +6769,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -7966,92 +6799,25 @@ test_abs_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "skipping starting block, then adding objects to backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Insert object too large for starting block size */ obj_size = DBLOCK_SIZE(fh, 0) + 1; @@ -8066,94 +6832,39 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert an object to fill up the heap block just created */ obj_size = DBLOCK_FREE(fh, 2) - obj_size; if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add rows of blocks to "backfill" direct blocks that were skipped */ if(fill_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR if(fill_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert another object, which should extend direct blocks, instead of backfill */ state.man_alloc_size += DBLOCK_SIZE(fh, 2); if(add_obj(fh, dxpl, 20, SMALL_OBJ_SIZE2, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8171,8 +6882,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -8203,88 +6912,24 @@ test_abs_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "insert object to initial block, then add object too large for starting direct blocks, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); /* Insert small object, to create root direct block */ state.heap_size = DBLOCK_SIZE(fh, 0); @@ -8292,18 +6937,11 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped blocks that are too small to hold the second object @@ -8320,45 +6958,11 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8376,8 +6980,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -8411,93 +7013,26 @@ test_abs_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "insert object to initial block, then add object too large for starting direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Insert small object, to create root direct block */ state.heap_size = DBLOCK_SIZE(fh, 0); @@ -8505,18 +7040,11 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped blocks that are too small to hold the second object @@ -8533,50 +7061,29 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert an object to fill up the (smaller) heap block just created */ obj_size = DBLOCK_FREE(fh, 0) - SMALL_OBJ_SIZE1; if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill remainder of 2 * start size block */ obj_size = DBLOCK_FREE(fh, 2) - (DBLOCK_SIZE(fh, 0) + 1); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert objects to fill remaining rows of the starting block size */ @@ -8584,66 +7091,25 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); for(v = 0; v < (cparam->managed.width - 1); v++) { state.man_alloc_size += DBLOCK_SIZE(fh, 0); if(fill_heap(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Fill second row of direct blocks */ if(fill_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to create new 2 * start size direct block */ state.man_alloc_size += DBLOCK_SIZE(fh, 2); if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8661,8 +7127,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -8681,110 +7145,43 @@ error: * of skipped blocks). * * Then add more objects to fill up remainder of partial direct - * block and all the skipped blocks, and one more object (to - * start next "normal" block). - * - * Return: Success: 0 - * - * Failure: 1 - * - * Programmer: Quincey Koziol - * Monday, April 3, 2006 - * - *------------------------------------------------------------------------- - */ -static int -test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) -{ - hid_t file = -1; /* File ID */ - hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "skipping blocks with indirect root, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - unsigned u; /* Local index variable */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR + * block and all the skipped blocks, and one more object (to + * start next "normal" block). + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Monday, April 3, 2006 + * + *------------------------------------------------------------------------- + */ +static int +test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5HF_t *fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + off_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "skipping blocks with indirect root, then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u; /* Local index variable */ - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Fill initial direct block */ state.heap_size = DBLOCK_SIZE(fh, 0); @@ -8792,18 +7189,11 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); if(fill_heap(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert small object, to create root indirect block */ state.heap_size += (cparam->managed.width - 1) * DBLOCK_SIZE(fh, 0); @@ -8811,18 +7201,11 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_alloc_size += DBLOCK_SIZE(fh, 0); state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped blocks that are too small to hold the large object @@ -8839,142 +7222,66 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 3); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert an object to fill up the (smaller) heap block just created */ obj_size = DBLOCK_FREE(fh, 0) - SMALL_OBJ_SIZE1; if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill remainder of 4 * start size block */ obj_size = DBLOCK_FREE(fh, 3) - (DBLOCK_SIZE(fh, 2) + 1); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert objects to fill remaining heaps in first row */ for(u = 0; u < (cparam->managed.width - 2); u++) { /* Fill a direct heap block up */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); if(fill_heap(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert objects to fill remaining heaps in second row */ if(fill_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert objects to fill remaining heaps in third row */ if(fill_row(fh, dxpl, 2, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to create new 4 * start size direct block */ state.man_alloc_size += DBLOCK_SIZE(fh, 3); if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8992,8 +7299,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -9028,107 +7333,33 @@ test_abs_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling first row, then skipping rows, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Fill first row of direct blocks */ if(fill_root_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped blocks that are too small to hold the large object @@ -9145,107 +7376,45 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 3); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill remainder of 4 * start size block */ obj_size = DBLOCK_FREE(fh, 3) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR + TEST_ERROR - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert objects to fill remaining heaps in second row */ if(fill_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert objects to fill remaining heaps in third row */ if(fill_row(fh, dxpl, 2, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to create new 4 * start size direct block */ state.man_alloc_size += DBLOCK_SIZE(fh, 3); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -9263,8 +7432,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -9296,91 +7463,27 @@ test_abs_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_direct_rows; /* Number of rows (of direct blocks) in root indirect block */ unsigned row; /* Current row */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "skipping direct blocks to last row and skipping two rows of root indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); /* Compute # direct block rows in root indirect block */ num_direct_rows = DTABLE_MAX_DROWS(fh); @@ -9399,7 +7502,7 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); obj_size = DBLOCK_SIZE(fh, row - 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, row - 1); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Compute heap size & free space when all direct blocks allocated */ do { @@ -9417,19 +7520,12 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); for(v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, num_direct_rows - 1); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Compute heap size & free space when root indirect block doubles again */ do { @@ -9445,45 +7541,11 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); obj_size = DBLOCK_SIZE(fh, num_direct_rows - 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, num_direct_rows - 1); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -9501,8 +7563,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -9533,107 +7593,33 @@ test_abs_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks and skipping blocks in non-root indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped blocks that are too small to hold the large object @@ -9641,110 +7627,48 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); obj_size = DBLOCK_SIZE(fh, 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add rows of blocks to "backfill" direct blocks that were skipped */ if(fill_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR if(fill_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR + TEST_ERROR - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert an object to fill up the (biggest) heap block created */ obj_size = DBLOCK_FREE(fh, 3) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill direct block heaps with 2 * initial block size in nested indirect block */ if(fill_row(fh, dxpl, 2, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert one more object, to create new 4 * start size direct block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -9762,8 +7686,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -9795,113 +7717,39 @@ test_abs_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_ { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ unsigned row; /* Current row in indirect block */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks and skipping row of non-root indirect blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u; /* Local index variable */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -9910,101 +7758,45 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of direct blocks that are smaller than large object's block size */ for(row = 0; row < num_first_indirect_rows; row++) { /* Fill rows of direct blocks in skipped indirect blocks */ for(u = 0; u < cparam->managed.width; u++) if(fill_row(fh, dxpl, row, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill row of direct blocks in largest (i.e. non-skipped) indirect block */ if(fill_row(fh, dxpl, row, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -10022,8 +7814,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -10056,129 +7846,48 @@ test_abs_fill_2nd_direct_less_one_wrap_start_block_add_skipped(hid_t fapl, H5HF_ { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, except last one, and insert object too large for 2nd level indirect blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - unsigned u; /* Local index variables */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, except last one, and insert object too large for 2nd level indirect blocks, then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u; /* Local index variables */ - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + TEST_ERROR - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + TEST_ERROR - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill first row (except one) of 2nd level indirect blocks */ for(u = 0; u < cparam->managed.width - 1; u++) /* Fill all rows of 2nd level indirect blocks in root block */ if(fill_2nd_indirect(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) TEST_ERROR - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -10190,34 +7899,20 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in 2nd level indirect block's direct blocks * (and rows of next 2nd level indirect block's direct blocks) @@ -10225,67 +7920,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); for(u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in skipped 2nd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in current 2nd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -10303,8 +7957,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -10340,113 +7992,39 @@ test_abs_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped(hid_t fapl, H5 { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ unsigned row; /* Current row in indirect block */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks and skipping row of non-root indirect blocks, then skip row of direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u; /* Local index variable */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -10458,34 +8036,20 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object too large for initial block size in skipped indirect blocks */ obj_size = DBLOCK_SIZE(fh, 3) + 1; @@ -10494,18 +8058,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, 4); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (medium) block just created */ obj_size = DBLOCK_FREE(fh, 4) - obj_size; @@ -10513,106 +8070,51 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Finish off blocks in row of medium block size (just to make row filling easier below) */ obj_size = DBLOCK_FREE(fh, 4); for(u = 1; u < cparam->managed.width; u++) { state.man_alloc_size += DBLOCK_SIZE(fh, 4); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of direct blocks that are smaller than large object's block size */ for(row = 0; row < num_first_indirect_rows; row++) { /* Fill rows of direct blocks in skipped indirect blocks */ for(u = 0; u < cparam->managed.width; u++) if(fill_row(fh, dxpl, row, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Fill row of direct blocks in largest (i.e. non-skipped) indirect block */ - /* (Skip the row of blocks filled above) */ - if(row != 4) - if(fill_row(fh, dxpl, row, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - } /* end while */ - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Add one more object, to create another "large" block */ - obj_size = SMALL_OBJ_SIZE1; - state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; + /* Fill row of direct blocks in largest (i.e. non-skipped) indirect block */ + /* (Skip the row of blocks filled above) */ + if(row != 4) + if(fill_row(fh, dxpl, row, fill_size, &state, &keep_ids)) + TEST_ERROR + } /* end while */ - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) + /* Add one more object, to create another "large" block */ + obj_size = SMALL_OBJ_SIZE1; + state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); + if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -10630,8 +8132,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -10662,95 +8162,28 @@ test_abs_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ unsigned max_dblock_rows; /* Max. # of rows (of direct blocks) in the root indirect block */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks and skipping two rows of root indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u, v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); @@ -10758,18 +8191,11 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped blocks that are too small to hold the large object @@ -10777,139 +8203,70 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); obj_size = DBLOCK_SIZE(fh, max_dblock_rows - 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 1); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert an object to fill up the (biggest) heap block created */ obj_size = DBLOCK_FREE(fh, max_dblock_rows - 1) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in indirect block's direct blocks */ for(u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in first row of skipped 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block rows in second row of skipped 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in used 2nd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows in second row of skipped 2nd level indirect blocks (and used 2nd level block) */ /* Direct block rows in skipped 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, num_first_indirect_rows, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) TEST_ERROR - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Direct block row in used 2nd level indirect block */ if(fill_row(fh, dxpl, num_first_indirect_rows, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 1); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -10927,8 +8284,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -10961,114 +8316,40 @@ test_abs_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(hid_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ unsigned max_dblock_rows; /* Max. # of rows (of direct blocks) in the root indirect block */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks and skipping two rows of root indirect block, skip one row of root indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u, v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); - + /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); max_dblock_rows = DTABLE_MAX_DROWS(fh); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of two rows of indirect blocks and * range of skipped blocks that are too small to hold the large object @@ -11076,34 +8357,20 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); obj_size = DBLOCK_SIZE(fh, max_dblock_rows - 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 1); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert an object to fill up the (biggest) heap block created */ obj_size = DBLOCK_FREE(fh, max_dblock_rows - 1) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object that can't fit in first row of indirect blocks * previously skipped, but is small enough to fit into second row of @@ -11112,144 +8379,75 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); obj_size = DBLOCK_SIZE(fh, max_dblock_rows - 3) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 2); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert an object to fill up the (2nd biggest) heap block created */ obj_size = DBLOCK_FREE(fh, max_dblock_rows - 2) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in indirect block's direct blocks */ for(u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in first row of skipped 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block rows in second row of skipped 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in used 2nd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows in second row of skipped 2nd level indirect blocks (and used 2nd level block) */ /* Finish blocks in partially used 2nd level indirect block */ if(fill_partial_row(fh, dxpl, num_first_indirect_rows, cparam->managed.width - 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block rows in skipped 2nd level indirect blocks */ /* (less the one indirect block already used) */ for(v = 0; v < cparam->managed.width - 1; v++) if(fill_row(fh, dxpl, num_first_indirect_rows, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) TEST_ERROR - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Direct block row in used 3rd row 2nd level indirect block */ if(fill_row(fh, dxpl, num_first_indirect_rows, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 1); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -11267,8 +8465,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -11300,122 +8496,41 @@ test_abs_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, and skip first rows of direct blocks of 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -11424,97 +8539,42 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); obj_size = DBLOCK_SIZE(fh, 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, 3) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Fill rows skipped over in 3rd level indirect block's direct blocks */ - if(fill_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - if(fill_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - if(fill_row(fh, dxpl, 2, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Add one more object, to create another "large" block */ - obj_size = SMALL_OBJ_SIZE1; - state.man_alloc_size += DBLOCK_SIZE(fh, 3); - if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; + /* Fill rows skipped over in 3rd level indirect block's direct blocks */ + if(fill_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) + TEST_ERROR + if(fill_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) + TEST_ERROR + if(fill_row(fh, dxpl, 2, fill_size, &state, &keep_ids)) + TEST_ERROR - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) + /* Add one more object, to create another "large" block */ + obj_size = SMALL_OBJ_SIZE1; + state.man_alloc_size += DBLOCK_SIZE(fh, 3); + if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -11532,8 +8592,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -11567,137 +8625,49 @@ test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct blocks, and skip first rows of direct blocks of 3rd level indirect block's 2nd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in third level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -11706,99 +8676,44 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); obj_size = DBLOCK_SIZE(fh, 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, 3) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in (3rd level indirect block's) 2nd level * indirect block's direct blocks */ if(fill_row(fh, dxpl, 0, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR if(fill_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR if(fill_row(fh, dxpl, 2, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -11816,8 +8731,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -11850,142 +8763,54 @@ test_abs_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(h { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct blocks, and skip first row of indirect blocks of 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - unsigned u, v; /* Local index variables */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); + off_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct blocks, and skip first row of indirect blocks of 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + TEST_ERROR + + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + TEST_ERROR - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in third level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -11997,34 +8822,20 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in (first 3rd level indirect block's) 2nd level * indirect block's direct blocks @@ -12034,67 +8845,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* Direct block rows in 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in 3rd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -12112,8 +8882,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -12147,94 +8915,27 @@ test_abs_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped( { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct blocks, and skip first two rows of indirect blocks of 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u, v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); @@ -12244,48 +8945,27 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in third level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -12297,18 +8977,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows + 1); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows + 1) - obj_size; @@ -12316,18 +8989,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in (first 3rd level indirect block's) 2nd level * indirect block's direct blocks @@ -12337,71 +9003,30 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* Direct block rows in 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in 3rd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Fill row of direct blocks in second 3rd level indirect block */ if(fill_row(fh, dxpl, num_first_indirect_rows, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows + 1); - if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) + if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -12419,8 +9044,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -12455,159 +9078,64 @@ test_abs_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(hid_t { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling first row of 3rd level indirect blocks, except last one, fill all direct blocks in last 3rd level indirect block, and insert object too large for it's 2nd level indirect blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u, v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks in root indirect block */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill first row (except one) of 3rd level indirect blocks */ for(u = 0; u < cparam->managed.width - 1; u++) /* Fill 3rd level indirect block */ if(fill_3rd_indirect(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) TEST_ERROR - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in last third level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -12619,34 +9147,20 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in 2nd level indirect block's direct blocks * (and rows of next 3rd level indirect block's direct blocks) @@ -12655,67 +9169,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* Direct block rows in 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in current 3rd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -12733,8 +9206,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -12770,173 +9241,71 @@ test_abs_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_s { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling first row of 3rd level indirect blocks, fill all direct blocks in next 3rd level indirect block, fill all 1st row of 2nd level indirect blocks, except last one, and insert object too large for 2nd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks in 4th level indirect block */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR + TEST_ERROR - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill first row of 3rd level indirect blocks */ if(fill_3rd_indirect_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in 2nd row third level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill first row (except one) of 2nd level indirect blocks */ for(u = 0; u < cparam->managed.width - 1; u++) if(fill_2nd_indirect(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) TEST_ERROR - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -12948,34 +9317,20 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in 2nd level indirect block's direct blocks * (and rows of next 2nd level indirect block's direct blocks) @@ -12983,67 +9338,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); for(u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in skipped 2nd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in current 2nd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -13061,8 +9375,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -13096,157 +9408,62 @@ test_abs_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(hid_t fapl, H5 { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill 4th level indirect block's direct blocks, and skip first row of 2nd indirect blocks of 4th level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u, v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ if(fill_all_3rd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in fourth level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -13258,34 +9475,20 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in (first 4th level indirect block's) 2nd level * indirect block's direct blocks @@ -13295,67 +9498,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* Direct block rows in 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in 2nd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR - } /* end for */ - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Add one more object, to create another "large" block */ - obj_size = SMALL_OBJ_SIZE1; - state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) TEST_ERROR + } /* end for */ - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + /* Add one more object, to create another "large" block */ + obj_size = SMALL_OBJ_SIZE1; + state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); + if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) + TEST_ERROR + + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -13373,8 +9535,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -13410,187 +9570,78 @@ test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_blo { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill 4th level indirect block's direct, 2nd level indirect blocks and 3rd level direct block, and skip first row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u, v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ if(fill_all_3rd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in fourth level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks in fourth level indirect block */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in fourth level indirect block's 3rd level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -13602,34 +9653,20 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in (first 4th level indirect block's first 3rd * level block's) 2nd level indirect block's direct blocks @@ -13639,67 +9676,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* Direct block rows in 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in 3rd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -13717,8 +9713,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -13750,152 +9744,64 @@ error: * Monday, April 17, 2006 * *------------------------------------------------------------------------- - */ -static int -test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) -{ - hid_t file = -1; /* File ID */ - hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill first row of 4th level indirect blocks, fill 2nd row 4th level indirect block's direct, 2nd level indirect blocks, first row of 3rd level indirect blocks, 3rd level direct block in 2nd row, and skip first row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - unsigned u, v; /* Local index variables */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR + */ +static int +test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5HF_t *fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + off_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill first row of 4th level indirect blocks, fill 2nd row 4th level indirect block's direct, 2nd level indirect blocks, first row of 3rd level indirect blocks, 3rd level direct block in 2nd row, and skip first row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ if(fill_all_3rd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill first row of 4th level indirect blocks */ if(fill_4th_indirect_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Account for root indirect block doubling # of rows again */ /* (From 16 rows to the max. # of rows: 22) */ @@ -13916,75 +9822,40 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); } /* end if */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in 2nd row 4th level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks in 2nd row 4th level indirect block */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill first row of 3rd level indirect blocks in 2nd row 4th level indirect block */ if(fill_3rd_indirect_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in 4th level indirect block's 2nd row of 3rd level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -13996,34 +9867,20 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in (first block in 2nd row 4th level indirect * block's first 3rd level block's) 2nd level indirect block's direct @@ -14033,67 +9890,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* Direct block rows in 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in 3rd level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -14111,8 +9927,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -14152,209 +9966,93 @@ test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_star { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill first row of 3rd level indirect blocks in 4th level indirect block except last 3rd level block, fill direct blocks in 3rd level block, and skip row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u, v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ if(fill_all_3rd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in 4th level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks in 4th level indirect block */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill first row (except one) of 3rd level indirect blocks in 4th level indirect block */ for(u = 0; u < cparam->managed.width - 1; u++) { /* Fill all direct block rows in 3rd level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill row of 2nd level indirect blocks in 3rd level indirect block */ if(fill_2nd_indirect_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in 4th level indirect block's last 3rd level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -14366,34 +10064,20 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in (4th level indirect block's first 3rd level * block's) 2nd level indirect block's direct blocks (and rows of next 4th @@ -14403,67 +10087,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* Direct block rows in 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in 4th level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -14481,8 +10124,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -14522,224 +10163,108 @@ test_abs_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_ { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill first row of 4th level indirect blocks, except last one, fill first row of 3rd level indirect blocks in last 4th level indirect block except last 3rd level block, fill direct blocks in 3rd level block, and skip row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u, v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ if(fill_all_3rd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill first row (except one) of 4th level indirect blocks */ for(u = 0; u < cparam->managed.width - 1; u++) { /* Fill all direct block rows in 4th level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill all rows of 2nd level indirect blocks in 4th level indirect block */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill row of 3rd level indirect blocks in 4th level indirect block */ if(fill_3rd_indirect_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in 4th level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks in 4th level indirect block */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill row (except one) of 3rd level indirect blocks in 4th level indirect block */ for(u = 0; u < cparam->managed.width - 1; u++) { /* Fill all direct block rows in 3rd level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Fill row of 2nd level indirect blocks in 3rd level indirect block */ if(fill_2nd_indirect_row(fh, dxpl, 1, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all direct block rows in 4th level indirect block's last 3rd level indirect block */ if(fill_all_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Account for root indirect block doubling # of rows again */ /* (From 16 rows to the max. # of rows: 22) */ @@ -14760,15 +10285,8 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); } /* end if */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert large object, to force creation of indirect block and * range of skipped (indirect) blocks that are too small to hold the large @@ -14780,34 +10298,20 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill rows skipped over in (4th level indirect block's first 3rd level * block's) 2nd level indirect block's direct blocks (and rows of next 4th @@ -14817,67 +10321,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* Direct block rows in 2nd level indirect blocks */ for(v = 0; v < cparam->managed.width; v++) if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Direct block row in 4th level indirect block */ if(fill_row(fh, dxpl, u, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -14895,8 +10358,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -14931,89 +10392,25 @@ test_abs_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "fragmenting small blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); /* Insert objects small enough to fit into initial blocks, but not to * share them with other objects of the same size, until the next larger @@ -15026,7 +10423,7 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); for(u = 0; u < cparam->managed.width; u++) { state.man_alloc_size += DBLOCK_SIZE(fh, 0); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR if(u == 0) { state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); @@ -15039,19 +10436,12 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); for(u = 0; u < cparam->managed.width; u++) { state.man_alloc_size += DBLOCK_SIZE(fh, 1); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* (Account for doubling root indirect block for rows 3-4 */ for(u = 0; u < 2; u++) { @@ -15063,81 +10453,33 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); /* Add one more object, to create a 2 * start_block_size block */ state.man_alloc_size += DBLOCK_SIZE(fh, 2); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Go back and fill in direct blocks of initial block size (which have large free space in them) */ obj_size = DBLOCK_FREE(fh, 0) - obj_size; for(u = 0; u < cparam->managed.width; u++) if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR for(u = 0; u < cparam->managed.width; u++) if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) TEST_ERROR - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill in 2 * start_block_size block */ obj_size = DBLOCK_FREE(fh, 2) - (DBLOCK_SIZE(fh, 0) / 2); if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -15155,8 +10497,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -15188,90 +10528,26 @@ test_abs_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned root_direct_rows; /* Number of rows in root indirect block */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "fragmenting direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - unsigned u, v; /* Local index variables */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR + const char *base_desc = "fragmenting direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + TEST_ERROR - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + TEST_ERROR - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); /* Retrieve # of direct rows in root indirect block */ root_direct_rows = H5HF_get_dtable_max_drows_test(fh); @@ -15287,7 +10563,7 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); for(u = 0; u < cparam->managed.width; u++) { state.man_alloc_size += DBLOCK_SIZE(fh, 0); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR if(u == 0) { state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); @@ -15301,19 +10577,12 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); for(u = 0; u < cparam->managed.width; u++) { state.man_alloc_size += DBLOCK_SIZE(fh, 1); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* (Account for doubling root indirect block for rows 3-4 */ for(u = 0; u < 2; u++) { @@ -15328,20 +10597,13 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); for(v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, u + 2); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* (Account for doubling root indirect block for rows 5-8 */ for(u = 0; u < 4; u++) { @@ -15356,20 +10618,13 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); for(v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, u + 4); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* (Account for doubling root indirect block for rows 9-16 */ for(u = 0; u < 8; u++) { @@ -15383,65 +10638,24 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); for(v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, 8); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Go back and backfill all root block's direct blocks */ for(u = 0; u < root_direct_rows; u++) { obj_size = DBLOCK_FREE(fh, u) - (DBLOCK_SIZE(fh, u) / 2); for(v = 0; v < cparam->managed.width; v++) if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -15459,8 +10673,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -15494,94 +10706,27 @@ test_abs_frag_2nd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ const char *base_desc = "fill root direct blocks, then fragment 2nd level indirect block's direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ unsigned u, v; /* Local index variables */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); - - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Compute # of bits used in first row */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); @@ -15591,18 +10736,11 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert objects small enough to fit into each direct block, but not to * share them with other objects of the same size. @@ -15612,66 +10750,25 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); for(v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, u); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Go back and backfill all 2nd level indirect block's direct blocks */ for(u = 0; u < num_first_indirect_rows; u++) { obj_size = DBLOCK_FREE(fh, u) - (DBLOCK_SIZE(fh, u) / 2); for(v = 0; v < cparam->managed.width; v++) if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -15689,8 +10786,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -15725,127 +10820,46 @@ test_abs_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned root_direct_rows; /* Number of rows in root indirect block */ off_t empty_size; /* Size of a file with an empty heap */ - off_t file_size; /* Size of file currently */ size_t obj_size; /* Size of object */ size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "fill root direct blocks and 2nd level indirect blocks, then fragment 3rd level indirect block's direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ - unsigned u, v; /* Local index variables */ - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "fill root direct blocks and 2nd level indirect blocks, then fragment 3rd level indirect block's direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - - /* - * Display testing message - */ - del_str = get_del_string(tparam); - HDassert(del_str); - test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - sprintf(test_desc, base_desc, del_str); - TESTING(test_desc); - del_str = H5MM_xfree(del_str); - test_desc = H5MM_xfree(test_desc); - - /* Initialize the heap ID structure */ - HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); + /* Perform common test initialization operations */ + if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + TEST_ERROR - /* Retrieve "bulk" filling object size */ - fill_size = get_fill_size(tparam); /* Compute # of direct rows in root indirect block */ root_direct_rows = DTABLE_MAX_DROWS(fh); /* Fill direct blocks in root indirect block */ if(fill_root_direct(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Fill all rows of 2nd level indirect blocks in root indirect block */ if(fill_all_2nd_indirect_rows(fh, dxpl, fill_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Insert objects small enough to fit into each direct block, but not to * share them with other objects of the same size. @@ -15855,66 +10869,25 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); for(v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, u); if(add_obj(fh, dxpl, 10, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ } /* end for */ /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Go back and backfill all 3rd level indirect block's direct blocks */ for(u = 0; u < root_direct_rows; u++) { obj_size = DBLOCK_FREE(fh, u) - (DBLOCK_SIZE(fh, u) / 2); for(v = 0; v < cparam->managed.width; v++) if(add_obj(fh, dxpl, 20, obj_size, &state, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR } /* end for */ - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids)) - FAIL_STACK_ERROR - - /* Close the fractal heap */ - if(H5HF_close(fh, dxpl) < 0) - FAIL_STACK_ERROR - fh = NULL; - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); -#endif /* QAK */ - /* Verify the file is correct size */ - if(file_size != empty_size) + /* Perform common file & heap close operations */ + if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -15932,8 +10905,6 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - H5MM_xfree(del_str); - H5MM_xfree(test_desc); if(fh) H5HF_close(fh, dxpl); H5Fclose(file); @@ -15966,12 +10937,11 @@ test_abs_random_managed(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, f { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned long seed = 0; /* Random # seed */ hsize_t total_obj_added; /* Size of objects added */ off_t empty_size; /* Size of a file with an empty heap */ @@ -15981,65 +10951,17 @@ test_abs_random_managed(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, f fheap_heap_state_t state; /* State of fractal heap */ size_t u; /* Local index variable */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - /* * Display testing message */ - TESTING("inserting random-sized objects (smaller than standalone size), then remove all objects (all - random)"); + if(tparam->del_dir == FHEAP_DEL_HEAP) + TESTING("inserting random-sized objects (smaller than standalone size), then remove all objects (all - deleting heap)") + else + TESTING("inserting random-sized objects (smaller than standalone size), then remove all objects (all - random)") /* Initialize the heap ID structure */ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); @@ -16061,18 +10983,11 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed); /* Insert object */ if(add_obj(fh, dxpl, obj_loc, obj_size, NULL, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Increment the amount of objects added */ total_obj_added += obj_size; @@ -16101,33 +11016,36 @@ HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = % } /* end if */ } /* end for */ - /* Delete objects inserted */ - for(u = 0; u < keep_ids.num_ids; u++) { - /* Remove object from heap */ - if(H5HF_remove(fh, dxpl, &keep_ids.ids[HEAP_ID_LEN * u]) < 0) - FAIL_STACK_ERROR + /* Delete individual objects, if we won't be deleting the entire heap later */ + if(tparam->del_dir != FHEAP_DEL_HEAP) { + /* Delete objects inserted */ + for(u = 0; u < keep_ids.num_ids; u++) { + /* Remove object from heap */ + if(H5HF_remove(fh, dxpl, &keep_ids.ids[HEAP_ID_LEN * u]) < 0) + FAIL_STACK_ERROR - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) TEST_ERROR + } /* end for */ - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - } /* end for */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR + /* Check up on heap... */ + if(check_stats(fh, &state)) + TEST_ERROR + } /* end if */ /* Close the fractal heap */ if(H5HF_close(fh, dxpl) < 0) FAIL_STACK_ERROR fh = NULL; + /* Check for deleting the entire heap */ + if(tparam->del_dir == FHEAP_DEL_HEAP) { + /* Delete heap */ + if(H5HF_delete(f, dxpl, fh_addr) < 0) + FAIL_STACK_ERROR + } /* end if */ + /* Close the file */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -16190,12 +11108,11 @@ test_abs_random_pow2_managed(hsize_t size_limit, hid_t fapl, H5HF_create_t *cpar { hid_t file = -1; /* File ID */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ - char filename[1024]; /* Filename to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ unsigned long seed = 0; /* Random # seed */ hsize_t total_obj_added; /* Size of objects added */ off_t empty_size; /* Size of a file with an empty heap */ @@ -16205,65 +11122,17 @@ test_abs_random_pow2_managed(hsize_t size_limit, hid_t fapl, H5HF_create_t *cpar fheap_heap_state_t state; /* State of fractal heap */ size_t u; /* Local index variable */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, H5P_DATASET_XFER_DEFAULT, cparam))) - FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) - FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) - FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) - FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) - FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) - FAIL_STACK_ERROR - - /* Prepare for querying the size of a file with an empty heap */ - - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Close file */ - if(H5Fclose(file)<0) - TEST_ERROR - - /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename)) == 0) - TEST_ERROR -#ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -#endif /* QAK */ - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Perform common file & heap open operations */ + if(open_heap(filename, fapl, dxpl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = H5I_object(file))) - STACK_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - /* * Display testing message */ - TESTING("inserting random-sized objects with power of 2 distribution (smaller than standalone size), then remove all objects (all - random)"); + if(tparam->del_dir == FHEAP_DEL_HEAP) + TESTING("inserting random-sized objects with power of 2 distribution (smaller than standalone size), then remove all objects (all - deleting heap)") + else + TESTING("inserting random-sized objects with power of 2 distribution (smaller than standalone size), then remove all objects (all - random)") /* Initialize the heap ID structure */ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); @@ -16271,7 +11140,7 @@ HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); /* Choose random # seed */ seed = (unsigned long)HDtime(NULL); #ifdef QAK -/* seed = (unsigned long)1153176468; */ +seed = (unsigned long)1154963939; HDfprintf(stderr, "Random # seed was: %lu\n", seed); #endif /* QAK */ HDsrandom(seed); @@ -16297,18 +11166,11 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed); /* Insert object */ if(add_obj(fh, dxpl, obj_loc, obj_size, NULL, &keep_ids)) - FAIL_STACK_ERROR + TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close heap */ - if(H5HF_close(fh, dxpl) < 0) - TEST_ERROR - - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) + TEST_ERROR /* Increment the amount of objects added */ total_obj_added += obj_size; @@ -16337,33 +11199,36 @@ HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = % } /* end if */ } /* end for */ - /* Delete objects inserted */ - for(u = 0; u < keep_ids.num_ids; u++) { - /* Remove object from heap */ - if(H5HF_remove(fh, dxpl, &keep_ids.ids[HEAP_ID_LEN * u]) < 0) - FAIL_STACK_ERROR + /* Delete individual objects, if we won't be deleting the entire heap later */ + if(tparam->del_dir != FHEAP_DEL_HEAP) { + /* Delete objects inserted */ + for(u = 0; u < keep_ids.num_ids; u++) { + /* Remove object from heap */ + if(H5HF_remove(fh, dxpl, &keep_ids.ids[HEAP_ID_LEN * u]) < 0) + FAIL_STACK_ERROR - /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - /* Close (empty) heap */ - if(H5HF_close(fh, dxpl) < 0) + /* Check for closing & re-opening the heap */ + if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0) TEST_ERROR + } /* end for */ - /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) - FAIL_STACK_ERROR - } /* end if */ - } /* end for */ - - /* Check up on heap... */ - if(check_stats(fh, &state)) - FAIL_STACK_ERROR + /* Check up on heap... */ + if(check_stats(fh, &state)) + TEST_ERROR + } /* end if */ /* Close the fractal heap */ if(H5HF_close(fh, dxpl) < 0) FAIL_STACK_ERROR fh = NULL; + /* Check for deleting the entire heap */ + if(tparam->del_dir == FHEAP_DEL_HEAP) { + /* Delete heap */ + if(H5HF_delete(f, dxpl, fh_addr) < 0) + FAIL_STACK_ERROR + } /* end if */ + /* Close the file */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -16460,8 +11325,8 @@ main(void) for(curr_test = FHEAP_TEST_NORMAL; curr_test < FHEAP_TEST_NTESTS; curr_test++) { #else /* QAK */ HDfprintf(stderr, "Uncomment test loop!\n"); -curr_test = FHEAP_TEST_NORMAL; -/* curr_test = FHEAP_TEST_REOPEN; */ +/* curr_test = FHEAP_TEST_NORMAL; */ +curr_test = FHEAP_TEST_REOPEN; #endif /* QAK */ /* Clear the testing parameters */ HDmemset(&tparam, 0, sizeof(fheap_test_param_t)); @@ -16593,17 +11458,21 @@ HDfprintf(stderr, "Uncomment tests!\n"); fheap_test_del_drain_t drain_half; /* Deletion draining */ /* More complex removal patterns */ - for(drain_half = FHEAP_DEL_DRAIN_ALL; drain_half < FHEAP_DEL_DRAIN_N; drain_half++) { - tparam.drain_half = drain_half; - for(del_dir = FHEAP_DEL_FORWARD; del_dir < FHEAP_DEL_NDIRS; del_dir++) { - tparam.del_dir = del_dir; + for(del_dir = FHEAP_DEL_FORWARD; del_dir < FHEAP_DEL_NDIRS; del_dir++) { + tparam.del_dir = del_dir; + for(drain_half = FHEAP_DEL_DRAIN_ALL; drain_half < FHEAP_DEL_DRAIN_N; drain_half++) { + tparam.drain_half = drain_half; #else /* QAK2 */ HDfprintf(stderr, "Uncomment test loops!\n"); +/* tparam.del_dir = FHEAP_DEL_FORWARD; */ +/* tparam.del_dir = FHEAP_DEL_REVERSE; */ +tparam.del_dir = FHEAP_DEL_HEAP; tparam.drain_half = FHEAP_DEL_DRAIN_ALL; /* tparam.drain_half = FHEAP_DEL_DRAIN_HALF; */ -tparam.del_dir = FHEAP_DEL_FORWARD; -/* tparam.del_dir = FHEAP_DEL_REVERSE; */ #endif /* QAK2 */ + /* Don't need to test deletion directions when deleting entire heap */ + if(tparam.del_dir == FHEAP_DEL_HEAP && tparam.drain_half > FHEAP_DEL_DRAIN_ALL) + break; #ifndef QAK /* Simple insertion patterns */ @@ -16690,6 +11559,11 @@ HDfprintf(stderr, "Uncomment tests!\n"); else { /* (reduce size of tests when re-opening each time) */ /* XXX: Try to speed things up enough that these tests don't have to be reduced */ + tparam.del_dir = FHEAP_DEL_FORWARD; + nerrors += test_abs_random_managed((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(50*1000*1000)), fapl, &cparam, &tparam); + nerrors += test_abs_random_pow2_managed((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(4*1000*1000)), fapl, &cparam, &tparam); + + tparam.del_dir = FHEAP_DEL_HEAP; nerrors += test_abs_random_managed((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(50*1000*1000)), fapl, &cparam, &tparam); nerrors += test_abs_random_pow2_managed((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(4*1000*1000)), fapl, &cparam, &tparam); } /* end else */ -- cgit v0.12