summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-08-29 20:44:11 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-08-29 20:44:11 (GMT)
commitc78dc8defa003eb2fe95dcae6fe115443cdcbffc (patch)
treed110b661509005e865690cf40bc10e07466b43b7
parent90e4c8770646a057dfc1efa88a64e219d65f31e0 (diff)
downloadhdf5-c78dc8defa003eb2fe95dcae6fe115443cdcbffc.zip
hdf5-c78dc8defa003eb2fe95dcae6fe115443cdcbffc.tar.gz
hdf5-c78dc8defa003eb2fe95dcae6fe115443cdcbffc.tar.bz2
[svn-r15561] Description:
Update extensible array code with function to open an existing earray, add more tests and avoid running the test when core/split/family/multi VFDs are used. Clean up fractal heap test code a bit and expand some of the tests a little bit also. Tested on: Mac OS X/32 10.5.4 (amazon) in debug mode Mac OS X/32 10.5.4 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
-rw-r--r--src/H5EA.c69
-rw-r--r--src/H5EAcache.c10
-rw-r--r--src/H5EAhdr.c11
-rw-r--r--src/H5EApkg.h9
-rw-r--r--src/H5EAprivate.h27
-rw-r--r--src/H5EAtest.c123
-rw-r--r--test/earray.c757
-rw-r--r--test/fheap.c74
8 files changed, 993 insertions, 87 deletions
diff --git a/src/H5EA.c b/src/H5EA.c
index d25a16c..06a11d2 100644
--- a/src/H5EA.c
+++ b/src/H5EA.c
@@ -164,6 +164,75 @@ END_FUNC(PRIV) /* end H5EA_create() */
/*-------------------------------------------------------------------------
+ * Function: H5EA_open
+ *
+ * Purpose: Opens an existing extensible array in the file.
+ *
+ * Return: Pointer to array wrapper on success
+ * NULL on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Aug 28 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(PRIV, ERR,
+H5EA_t *, NULL, NULL,
+H5EA_open(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr))
+
+ /* Local variables */
+ H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */
+ H5EA_hdr_t *hdr = NULL; /* The extensible array header information */
+
+ /*
+ * Check arguments.
+ */
+ HDassert(f);
+ HDassert(H5F_addr_defined(ea_addr));
+
+ /* Load the array header into memory */
+#ifdef QAK
+HDfprintf(stderr, "%s: ea_addr = %a\n", FUNC, ea_addr);
+#endif /* QAK */
+ if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, ea_addr, NULL, NULL, H5AC_READ)))
+ H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header, address = %llu", (unsigned long_long)ea_addr)
+
+ /* Check for pending array deletion */
+ if(hdr->pending_delete)
+ H5E_THROW(H5E_CANTOPENOBJ, "can't open extensible array pending deletion")
+
+ /* Create fractal heap info */
+ if(NULL == (ea = H5FL_MALLOC(H5EA_t)))
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array info")
+
+ /* Point extensible array wrapper at header */
+ ea->hdr = hdr;
+ if(H5EA__hdr_incr(ea->hdr) < 0)
+ H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header")
+
+ /* Increment # of files using this array header */
+ if(H5EA__hdr_fuse_incr(ea->hdr) < 0)
+ H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header")
+
+ /* Set file pointer for this array open context */
+ ea->f = f;
+
+ /* Set the return value */
+ ret_value = ea;
+
+CATCH
+
+ if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_EARRAY_HDR, ea_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header")
+ if(!ret_value)
+ if(ea && H5EA_close(ea, dxpl_id) < 0)
+ H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array")
+
+END_FUNC(PRIV) /* end H5EA_open() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5EA_get_nelmts
*
* Purpose: Query the current number of elements in array
diff --git a/src/H5EAcache.c b/src/H5EAcache.c
index 3fc408d..a6e8178 100644
--- a/src/H5EAcache.c
+++ b/src/H5EAcache.c
@@ -169,8 +169,9 @@ H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *u
if(*p++ != H5EA_HDR_VERSION)
H5E_THROW(H5E_VERSION, "wrong extensible array header version")
- /* General array information */
- hdr->elmt_size = *p++; /* Element size (in bytes) */
+ /* General array creation/configuration information */
+ hdr->raw_elmt_size = *p++; /* Element size in file (in bytes) */
+ hdr->max_nelmts_bits = *p++; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */
hdr->idx_blk_elmts = *p++; /* # of elements to store in index block */
hdr->data_blk_min_elmts = *p++; /* Min. # of elements per data block */
hdr->sup_blk_min_data_ptrs = *p++; /* Min. # of data block pointers for a super block */
@@ -263,8 +264,9 @@ H5EA__cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5
/* Version # */
*p++ = H5EA_HDR_VERSION;
- /* General array information */
- *p++ = hdr->elmt_size; /* Element size (in bytes) */
+ /* General array creation/configuration information */
+ *p++ = hdr->raw_elmt_size; /* Element size in file (in bytes) */
+ *p++ = hdr->max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */
*p++ = hdr->idx_blk_elmts; /* # of elements to store in index block */
*p++ = hdr->data_blk_min_elmts; /* Min. # of elements per data block */
*p++ = hdr->sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */
diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c
index 2f14e6c..5fbcaf9 100644
--- a/src/H5EAhdr.c
+++ b/src/H5EAhdr.c
@@ -49,6 +49,8 @@
/* Local Macros */
/****************/
+/* Max. # of bits for max. nelmts index */
+#define H5EA_MAX_NELMTS_IDX_MAX 64
/******************/
/* Local Typedefs */
@@ -157,8 +159,12 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
#ifndef NDEBUG
/* Check for valid parameters */
- if(cparam->elmt_size == 0)
+ if(cparam->raw_elmt_size == 0)
H5E_THROW(H5E_BADVALUE, "element size must be greater than zero")
+ if(cparam->max_nelmts_bits == 0)
+ H5E_THROW(H5E_BADVALUE, "max. # of nelmts bitsmust be greater than zero")
+ if(cparam->max_nelmts_bits > H5EA_MAX_NELMTS_IDX_MAX)
+ H5E_THROW(H5E_BADVALUE, "element size must be <= %u", (unsigned)H5EA_MAX_NELMTS_IDX_MAX)
if(!POWER_OF_TWO(cparam->sup_blk_min_data_ptrs))
H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block not power of two")
if(!POWER_OF_TWO(cparam->data_blk_min_elmts))
@@ -172,7 +178,8 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
/* Set the internal parameters for the array */
/* Set the creation parameters for the array */
- hdr->elmt_size = cparam->elmt_size;
+ hdr->raw_elmt_size = cparam->raw_elmt_size;
+ hdr->max_nelmts_bits = cparam->max_nelmts_bits;
hdr->idx_blk_elmts = cparam->idx_blk_elmts;
hdr->sup_blk_min_data_ptrs = cparam->sup_blk_min_data_ptrs;
hdr->data_blk_min_elmts = cparam->data_blk_min_elmts;
diff --git a/src/H5EApkg.h b/src/H5EApkg.h
index 95e5c60..33131bd 100644
--- a/src/H5EApkg.h
+++ b/src/H5EApkg.h
@@ -363,6 +363,7 @@ func_init_failed: \
\
/* General heap information */ \
+ 1 /* Element Size */ \
+ + 1 /* Max. # of elements bits */ \
+ 1 /* # of elements to store in index block */ \
+ 1 /* Min. # elements per data block */ \
+ 1 /* Min. # of data block pointers for a super block */ \
@@ -382,7 +383,8 @@ typedef struct H5EA_hdr_t {
H5AC_info_t cache_info;
/* Extensible array configuration/creation parameters (stored) */
- uint8_t elmt_size; /* Element size (in bytes) */
+ uint8_t raw_elmt_size; /* Element size in file (in bytes) */
+ uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */
uint8_t idx_blk_elmts; /* # of elements to store in index block */
uint8_t data_blk_min_elmts; /* Min. # of elements per data block */
uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */
@@ -413,6 +415,11 @@ H5_DLLVAR const H5AC_class_t H5AC_EARRAY_HDR[1];
/* Declare a free list to manage the H5EA_hdr_t struct */
H5FL_EXTERN(H5EA_hdr_t);
+/* Internal extensible array testing class */
+#ifdef H5EA_TESTING
+H5_DLLVAR const H5EA_class_t H5EA_CLS_TEST[1];
+#endif /* H5EA_TESTING */
+
/******************************/
/* Package Private Prototypes */
diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h
index 6a7fc67..e39cefe 100644
--- a/src/H5EAprivate.h
+++ b/src/H5EAprivate.h
@@ -46,9 +46,33 @@
/* Library Private Typedefs */
/****************************/
+/* Extensible array class IDs */
+typedef enum H5EA_cls_id_t {
+ /* Start real class IDs at 0 -QAK */
+ H5EA_CLS_TEST_ID, /* Extensible array is for testing (do not use for actual data) */
+ H5EA_NUM_CLS_ID /* Number of Extensible Array class IDs (must be last) */
+} H5EA_cls_id_t;
+
+/*
+ * Each type of element that can be stored in an extesible array has a
+ * variable of this type that contains class variables and methods.
+ */
+typedef struct H5EA_class_t {
+ H5EA_cls_id_t id; /* ID of Extensible Array class, as found in file */
+ size_t nat_elmt_size; /* Size of native (memory) element */
+
+ /* Extensible array client callback methods */
+ herr_t (*fill)(uint8_t *raw_blk, size_t nelmts); /* Fill array of elements with encoded form of "missing element" value */
+ herr_t (*encode)(uint8_t *raw, const void *elmt); /* Encode element from native form to disk storage form */
+ herr_t (*decode)(const uint8_t *raw, void *elmt); /* Decode element from disk storage form to native form */
+ herr_t (*debug)(FILE *stream, int indent, int fwidth, const void *elmt); /* Print an element for debugging */
+} H5EA_class_t;
+
/* Extensible array creation parameters */
typedef struct H5EA_create_t {
- uint8_t elmt_size; /* Element size (in bytes) */
+ const H5EA_class_t *cls; /* Class of extensible array to create */
+ uint8_t raw_elmt_size; /* Element size in file (in bytes) */
+ uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */
uint8_t idx_blk_elmts; /* # of elements to store in index block */
uint8_t data_blk_min_elmts; /* Min. # of elements per data block */
uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */
@@ -75,6 +99,7 @@ typedef struct H5EA_t H5EA_t;
/* General routines */
H5_DLL H5EA_t *H5EA_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam);
+H5_DLL H5EA_t *H5EA_open(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr);
H5_DLL herr_t H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts);
H5_DLL herr_t H5EA_get_addr(const H5EA_t *ea, haddr_t *addr);
H5_DLL herr_t H5EA_delete(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr);
diff --git a/src/H5EAtest.c b/src/H5EAtest.c
index c05084d..0096d9c 100644
--- a/src/H5EAtest.c
+++ b/src/H5EAtest.c
@@ -60,11 +60,27 @@
/* Local Prototypes */
/********************/
+/* Extensible array class callbacks */
+static herr_t H5EA_test_fill(uint8_t *raw_blk, size_t nelmts);
+static herr_t H5EA_test_encode(uint8_t *raw, const void *elmt);
+static herr_t H5EA_test_decode(const uint8_t *raw, void *elmt);
+static herr_t H5EA_test_debug(FILE *stream, int indent, int fwidth, const void *elmt);
+
/*********************/
/* Package Variables */
/*********************/
+/* Extensible array testing class information */
+const H5EA_class_t H5EA_CLS_TEST[1]={{
+ H5EA_CLS_TEST_ID, /* Type of Extensible array */
+ sizeof(haddr_t), /* Size of native record */
+ H5EA_test_fill, /* Fill block of missing elements callback */
+ H5EA_test_encode, /* Element encoding callback */
+ H5EA_test_decode, /* Element decoding callback */
+ H5EA_test_debug /* Element debugging callback */
+}};
+
/*****************************/
/* Library Private Variables */
@@ -78,6 +94,102 @@
/*-------------------------------------------------------------------------
+ * Function: H5EA_test_fill
+ *
+ * Purpose: Fill "missing elements" in block of elements
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(STATIC, NOERR,
+herr_t, SUCCEED, -,
+H5EA_test_fill(uint8_t *raw_blk, size_t nelmts))
+
+ /* Sanity checks */
+ HDassert(raw_blk);
+ HDassert(nelmts);
+
+END_FUNC(STATIC) /* end H5EA_test_fill() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5EA_test_encode
+ *
+ * Purpose: Encode an element from "native" to "raw" form
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(STATIC, NOERR,
+herr_t, SUCCEED, -,
+H5EA_test_encode(uint8_t *raw, const void *elmt))
+
+ /* Sanity checks */
+ HDassert(raw);
+ HDassert(elmt);
+
+END_FUNC(STATIC) /* end H5EA_test_encode() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5EA_test_decode
+ *
+ * Purpose: Decode an element from "raw" to "native" form
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(STATIC, NOERR,
+herr_t, SUCCEED, -,
+H5EA_test_decode(const uint8_t *raw, void *elmt))
+
+ /* Sanity checks */
+ HDassert(raw);
+ HDassert(elmt);
+
+END_FUNC(STATIC) /* end H5EA_test_decode() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5EA_test_debug
+ *
+ * Purpose: Display an element for debugging
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(STATIC, NOERR,
+herr_t, SUCCEED, -,
+H5EA_test_debug(FILE *stream, int indent, int fwidth, const void *elmt))
+
+ /* Sanity checks */
+ HDassert(stream);
+ HDassert(elmt);
+
+END_FUNC(STATIC) /* end H5EA_test_debug() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5EA_get_cparam_test
*
* Purpose: Retrieve the parameters used to create the extensible array
@@ -99,7 +211,8 @@ H5EA_get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam))
HDassert(cparam);
/* Get extensible array creation parameters */
- cparam->elmt_size = ea->hdr->elmt_size;
+ cparam->raw_elmt_size = ea->hdr->raw_elmt_size;
+ cparam->max_nelmts_bits = ea->hdr->max_nelmts_bits;
cparam->idx_blk_elmts = ea->hdr->idx_blk_elmts;
cparam->sup_blk_min_data_ptrs = ea->hdr->sup_blk_min_data_ptrs;
cparam->data_blk_min_elmts = ea->hdr->data_blk_min_elmts;
@@ -129,9 +242,13 @@ H5EA_cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2)
HDassert(cparam2);
/* Compare creation parameters for array */
- if(cparam1->elmt_size < cparam2->elmt_size)
+ if(cparam1->raw_elmt_size < cparam2->raw_elmt_size)
+ H5_LEAVE(-1)
+ else if(cparam1->raw_elmt_size > cparam2->raw_elmt_size)
+ H5_LEAVE(1)
+ if(cparam1->max_nelmts_bits < cparam2->max_nelmts_bits)
H5_LEAVE(-1)
- else if(cparam1->elmt_size > cparam2->elmt_size)
+ else if(cparam1->max_nelmts_bits > cparam2->max_nelmts_bits)
H5_LEAVE(1)
if(cparam1->idx_blk_elmts < cparam2->idx_blk_elmts)
H5_LEAVE(-1)
diff --git a/test/earray.c b/test/earray.c
index 7c1f05a..32b58bb 100644
--- a/test/earray.c
+++ b/test/earray.c
@@ -37,6 +37,7 @@
/* Extensible array creation values */
#define ELMT_SIZE sizeof(haddr_t)
+#define MAX_NELMTS_BITS 32
#define IDX_BLK_ELMTS 4
#define SUP_BLK_MIN_DATA_PTRS 4
#define DATA_BLK_MIN_ELMTS 16
@@ -50,6 +51,17 @@ typedef enum {
EARRAY_TEST_NTESTS /* The number of test types, must be last */
} earray_test_type_t;
+/* Orders to operate on entries */
+typedef enum {
+ EARRAY_DIR_FORWARD, /* Insert objects from 0 -> nobjs */
+ EARRAY_DIR_RANDOM, /* Insert objects randomly from 0 - nobjs */
+ EARRAY_DIR_CYCLIC, /* Insert every n'th object cyclicly: 0, n, 2n, 3n, ..., nobjs/n, 1+nobjs/n, 1+n+nobjs/n, 1+2n+nobjs/n, ..., nobjs */
+ EARRAY_DIR_REVERSE, /* Insert objects from nobjs -> 0 */
+ EARRAY_DIR_INWARD, /* Insert objects from outside to in: 0, nobjs, 1, nobjs-1, 2, nobjs-2, ..., nobjs/2 */
+ EARRAY_DIR_OUTWARD, /* Insert objects from inside to out: nobjs/2, (nobjs/2)-1, (nobjs/2)+1, ..., 0, nobjs */
+ EARRAY_DIR_NDIRS /* The number of different insertion orders, must be last */
+} earray_test_dir_t;
+
/* Whether to compress data blocks */
typedef enum {
EARRAY_TEST_NO_COMPRESS, /* Don't compress data blocks */
@@ -75,7 +87,14 @@ const char *FILENAME[] = {
NULL
};
-/* Local routines */
+/* Filename to use for all tests */
+char filename_g[EARRAY_FILENAME_LEN];
+
+/* Empty file size */
+h5_stat_size_t empty_size_g;
+
+
+/* Local prototypes */
/*-------------------------------------------------------------------------
@@ -84,7 +103,7 @@ const char *FILENAME[] = {
* Purpose: Initialize array creation parameter structure
*
* Return: Success: 0
- * Failure: 1
+ * Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, August 21, 2008
@@ -98,7 +117,9 @@ init_cparam(H5EA_create_t *cparam)
HDmemset(cparam, 0, sizeof(*cparam));
/* General parameters */
- cparam->elmt_size = ELMT_SIZE;
+ cparam->cls = H5EA_CLS_TEST;
+ cparam->raw_elmt_size = ELMT_SIZE;
+ cparam->max_nelmts_bits = MAX_NELMTS_BITS;
cparam->idx_blk_elmts = IDX_BLK_ELMTS;
cparam->sup_blk_min_data_ptrs = SUP_BLK_MIN_DATA_PTRS;
cparam->data_blk_min_elmts = DATA_BLK_MIN_ELMTS;
@@ -108,12 +129,44 @@ init_cparam(H5EA_create_t *cparam)
/*-------------------------------------------------------------------------
+ * Function: create_file
+ *
+ * Purpose: Create file and retrieve pointer to internal file object
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+create_file(hid_t fapl, hid_t *file, H5F_t **f)
+{
+ /* Create the file to work on */
+ if((*file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (*f = (H5F_t *)H5I_object(*file)))
+ FAIL_STACK_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* create_file() */
+
+
+/*-------------------------------------------------------------------------
* Function: check_stats
*
* Purpose: Verify stats for an extensible array
*
* Return: Success: 0
- * Failure: 1
+ * Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, August 21, 2008
@@ -143,69 +196,259 @@ check_stats(const H5EA_t *ea, const earray_state_t *state)
return(0);
error:
- return(1);
+ return(-1);
} /* check_stats() */
/*-------------------------------------------------------------------------
- * Function: test_basic
+ * Function: reopen_file
*
- * Purpose: Basic tests for extensible arrays
+ * Purpose: Perform common "re-open" operations on file & array for testing
*
- * Return: Success: 0
- * Failure: 1
+ * Return: Success: 0
+ * Failure: -1
*
* Programmer: Quincey Koziol
- * Thursday, August 7, 2008
+ * Thursday, August 28, 2008
*
*-------------------------------------------------------------------------
*/
-static unsigned
-test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tparam)
+static int
+reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
+ H5EA_t **ea, haddr_t ea_addr, const earray_test_param_t *tparam)
+{
+ /* Check for closing & re-opening the array */
+ /* (actually will close & re-open the file as well) */
+ if(tparam->reopen_array) {
+ /* Close array, if given */
+ if(ea) {
+ if(H5EA_close(*ea, dxpl) < 0)
+ FAIL_STACK_ERROR
+ *ea = NULL;
+ } /* end if */
+
+ /* Close file */
+ if(H5Fclose(*file) < 0)
+ FAIL_STACK_ERROR
+ *file = (-1);
+ *f = NULL;
+
+ /* Re-open the file */
+ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (*f = (H5F_t *)H5I_object(*file)))
+ FAIL_STACK_ERROR
+
+ /* Re-open array, if given */
+ if(ea) {
+ if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+ } /* end if */
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* reopen_file() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: create_array
+ *
+ * Purpose: Create an extensible array and perform initial checks
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+create_array(H5F_t *f, hid_t dxpl, const H5EA_create_t *cparam,
+ H5EA_t **ea, haddr_t *ea_addr)
{
- hid_t file = -1; /* File ID */
- char filename[EARRAY_FILENAME_LEN]; /* Filename to use */
- H5F_t *f = NULL; /* Internal file object pointer */
- H5EA_create_t test_cparam; /* Creation parameters for array */
- H5EA_t *ea = NULL; /* Extensible array wrapper */
- haddr_t ea_addr; /* Array address in file */
hsize_t nelmts; /* Number of elements in array */
earray_state_t state; /* State of extensible array */
- h5_stat_size_t empty_size; /* File size, w/o array */
- h5_stat_size_t file_size; /* File size, after deleting array */
- /* Set the filename to use for this test (dependent on fapl) */
- h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+ /* Create array */
+ if(NULL == (*ea = H5EA_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
- /* Create the file to work on */
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ /* Check status of array */
+ nelmts = 0;
+ if(H5EA_get_nelmts(*ea, &nelmts) < 0)
+ FAIL_STACK_ERROR
+ if(nelmts > 0)
+ TEST_ERROR
+ if(H5EA_get_addr(*ea, ea_addr) < 0)
FAIL_STACK_ERROR
+ if(!H5F_addr_defined(*ea_addr))
+ TEST_ERROR
+ HDmemset(&state, 0, sizeof(state));
+ if(check_stats(*ea, &state))
+ TEST_ERROR
- /* Close file */
- if(H5Fclose(file) < 0)
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* create_array() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_cparam
+ *
+ * Purpose: Verify creation parameters are correct
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+verify_cparam(const H5EA_t *ea, const H5EA_create_t *cparam)
+{
+ H5EA_create_t test_cparam; /* Creation parameters for array */
+
+ /* Retrieve creation parameters */
+ HDmemset(&test_cparam, 0, sizeof(H5EA_create_t));
+ if(H5EA_get_cparam_test(ea, &test_cparam) < 0)
FAIL_STACK_ERROR
- /* Get the size of a file w/empty heap*/
- if((empty_size = h5_get_file_size(filename)) < 0)
+ /* Verify creation parameters */
+ if(H5EA_cmp_cparam_test(cparam, &test_cparam))
TEST_ERROR
- /* Re-open the file */
- if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* verify_cparam() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: shutdown
+ *
+ * Purpose: Close array, delete array, close file and verify that file
+ * is empty size
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+shutdown(hid_t file, H5F_t *f, H5EA_t *ea, haddr_t ea_addr)
+{
+ h5_stat_size_t file_size; /* File size, after deleting array */
+
+ /* Close the extensible array */
+ if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
- /* Get a pointer to the internal file object */
- if(NULL == (f = (H5F_t *)H5I_object(file)))
+ /* Delete array */
+ if(H5EA_delete(f, H5P_DATASET_XFER_DEFAULT, ea_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_g)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size_g)
+ TEST_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* shutdown() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_create
+ *
+ * Purpose: Test creating extensible array
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 7, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
/*
* Display testing message
*/
TESTING("invalid extensible array creation parameters");
#ifndef NDEBUG
+{
+ H5EA_create_t test_cparam; /* Creation parameters for array */
+
/* Set invalid element size */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
- test_cparam.elmt_size = 0;
+ test_cparam.raw_elmt_size = 0;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Set invalid max. # of elements bits */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.max_nelmts_bits = 0;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.max_nelmts_bits = 65;
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam);
} H5E_END_TRY;
@@ -246,6 +489,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara
} /* end if */
PASSED()
+}
#else /* NDEBUG */
SKIPPED();
puts(" Not tested when assertions are disabled");
@@ -256,49 +500,314 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara
*/
TESTING("extensible array creation");
- if(NULL == (ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, cparam)))
- FAIL_STACK_ERROR
- nelmts = 0;
- if(H5EA_get_nelmts(ea, &nelmts) < 0)
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr) < 0)
+ TEST_ERROR
+
+ PASSED()
+
+ /* Verify the creation parameters */
+ TESTING("verify array creation parameters");
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(shutdown(file, f, ea, ea_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* end test_create() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_reopen
+ *
+ * Purpose: Create & reopen an extensible array
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("create, close & reopen extensible array");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr) < 0)
+ TEST_ERROR
+
+ /* Close the extensible array */
+ if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
- if(nelmts > 0)
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, tparam) < 0)
TEST_ERROR
- if(H5EA_get_addr(ea, &ea_addr) < 0)
+
+ /* Re-open the array */
+ if(NULL == (ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr)))
FAIL_STACK_ERROR
- if(!H5F_addr_defined(ea_addr))
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
- HDmemset(&state, 0, sizeof(state));
- if(check_stats(ea, &state))
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(shutdown(file, f, ea, ea_addr) < 0)
TEST_ERROR
+
+ /* All tests passed */
PASSED()
- /* Query the type of address mapping */
- TESTING("query array creation parameters");
- HDmemset(&test_cparam, 0, sizeof(H5EA_create_t));
- if(H5EA_get_cparam_test(ea, &test_cparam) < 0)
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_reopen() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_open_twice
+ *
+ * Purpose: Open an extensible array twice
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t file2 = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5F_t *f2 = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ H5EA_t *ea2 = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("open extensible array twice");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr) < 0)
+ TEST_ERROR
+
+ /* Open the array again, through the first file handle */
+ if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr)))
FAIL_STACK_ERROR
- if(H5EA_cmp_cparam_test(cparam, &test_cparam))
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+ if(verify_cparam(ea2, cparam) < 0)
TEST_ERROR
- /* Close the extensible array */
+ /* Close the second extensible array wrapper */
+ if(H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea2 = NULL;
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file2 = H5Freopen(file)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
+ FAIL_STACK_ERROR
+
+ /* Open the extensible array through the second file handle */
+ if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the first extensible array wrapper */
if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
+ ea = NULL;
- /* Delete array */
+ /* Close the first file */
+ /* (close before second file, to detect error on internal array header's
+ * shared file information)
+ */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(shutdown(file2, f2, ea2, ea_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ if(ea2)
+ H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ H5Fclose(file2);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_open_twice() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_delete_open
+ *
+ * Purpose: Delete opened extensible array (& open deleted array)
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ H5EA_t *ea2 = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+ h5_stat_size_t file_size; /* File size, after deleting array */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("deleting open extensible array");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr) < 0)
+ TEST_ERROR
+
+ /* Open the array again */
+ if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr)))
+ FAIL_STACK_ERROR
+
+ /* Request that the array be deleted */
if(H5EA_delete(f, H5P_DATASET_XFER_DEFAULT, ea_addr) < 0)
FAIL_STACK_ERROR
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+ if(verify_cparam(ea2, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the second extensible array wrapper */
+ if(H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea2 = NULL;
+
+ /* Try re-opening the array again (should fail, as array will be deleted) */
+ H5E_BEGIN_TRY {
+ ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr);
+ } H5E_END_TRY;
+ if(ea2) {
+ /* Close opened array */
+ H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT);
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Close the first extensible array wrapper */
+ if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea = NULL;
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, tparam) < 0)
+ TEST_ERROR
+
+ /* Try re-opening the array again (should fail, as array is now deleted) */
+ H5E_BEGIN_TRY {
+ ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+
+ /* Indicate error */
+ TEST_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)
+ if((file_size = h5_get_file_size(filename_g)) < 0)
TEST_ERROR
/* Verify the file is correct size */
- if(file_size != empty_size)
+ if(file_size != empty_size_g)
TEST_ERROR
/* All tests passed */
@@ -310,11 +819,81 @@ error:
H5E_BEGIN_TRY {
if(ea)
H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ if(ea2)
+ H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT);
H5Fclose(file);
} H5E_END_TRY;
return 1;
-} /* end test_create() */
+} /* test_delete_open() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_set_first
+ *
+ * Purpose: Set first element in extensible array
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_set_first(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("setting first element of array");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr) < 0)
+ TEST_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
+ TEST_ERROR
+
+/* Set first element of array */
+
+/* Verify # of elements */
+
+/* Verify array state */
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(shutdown(file, f, ea, ea_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_set_first() */
/*-------------------------------------------------------------------------
@@ -335,6 +914,7 @@ main(void)
{
H5EA_create_t cparam; /* Creation parameters for extensible array */
earray_test_param_t tparam; /* Testing parameters */
+ earray_test_type_t curr_test; /* Current test being worked on */
hid_t fapl = -1; /* File access property list for data files */
unsigned nerrors = 0; /* Cumulative error count */
int ExpressMode; /* Test express value */
@@ -350,19 +930,72 @@ main(void)
if(NULL == (envval = HDgetenv("HDF5_DRIVER")))
envval = "nomatch";
- /* Initialize extensible array creation parameters */
- init_cparam(&cparam);
+ if(HDstrcmp(envval, "core") && HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") &&
+ HDstrcmp(envval, "family")) {
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g));
+
+
+ /* Create an empty file to retrieve size */
+ {
+ hid_t file; /* File ID */
+
+ if((file = H5Fcreate(filename_g, 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/no array */
+ if((empty_size_g = h5_get_file_size(filename_g)) < 0)
+ TEST_ERROR
+ }
+
+
+ /* Initialize extensible array creation parameters */
+ init_cparam(&cparam);
+
+ /* Iterate over the testing parameters */
+ for(curr_test = EARRAY_TEST_NORMAL; curr_test < EARRAY_TEST_NTESTS; curr_test++) {
+
+ /* Clear the testing parameters */
+ HDmemset(&tparam, 0, sizeof(tparam));
+
+ /* Set appropriate testing parameters for each test */
+ switch(curr_test) {
+ /* "Normal" testing parameters */
+ case EARRAY_TEST_NORMAL:
+ puts("Testing with normal parameters");
+ break;
+
+ /* "Re-open array" testing parameters */
+ case EARRAY_TEST_REOPEN:
+ puts("Testing with reopen array flag set");
+ tparam.reopen_array = TRUE;
+ break;
- /* Clear the testing parameters */
- HDmemset(&tparam, 0, sizeof(tparam));
+ /* An unknown test? */
+ default:
+ goto error;
+ } /* end switch */
- /* Tests */
- nerrors = test_create(fapl, &cparam, &tparam);
+ /* Basic capability tests */
+ nerrors += test_create(fapl, &cparam, &tparam);
+ nerrors += test_reopen(fapl, &cparam, &tparam);
+ nerrors += test_open_twice(fapl, &cparam, &tparam);
+ nerrors += test_delete_open(fapl, &cparam, &tparam);
- if(nerrors)
- goto error;
- puts("All extensible array tests passed.");
+ /* Basic capacity tests */
+ nerrors += test_set_first(fapl, &cparam, &tparam);
+ } /* end for */
+ if(nerrors)
+ goto error;
+ puts("All extensible array tests passed.");
+ } /* end if(HDstrcmp(envval=="...")) */
+ else
+ printf("All extensible array tests skipped - Incompatible with current Virtual File Driver\n");
/* Clean up file used */
h5_cleanup(FILENAME, fapl);
diff --git a/test/fheap.c b/test/fheap.c
index c8d43ee..2b7dc1e 100644
--- a/test/fheap.c
+++ b/test/fheap.c
@@ -576,10 +576,13 @@ reopen_file(hid_t *file, H5F_t **f, const char *filename, hid_t fapl, hid_t dxpl
/* Close heap */
if(H5HF_close(*fh, dxpl) < 0)
FAIL_STACK_ERROR
+ *fh = NULL;
/* Close file */
if(H5Fclose(*file) < 0)
FAIL_STACK_ERROR
+ *file = (-1);
+ *f = NULL;
/* Re-open the file */
if((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
@@ -2066,6 +2069,8 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp
H5HF_t *fh = NULL; /* Fractal heap wrapper */
H5HF_t *fh2 = NULL; /* 2nd fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
+ h5_stat_size_t empty_size; /* File size, w/o heap */
+ h5_stat_size_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 */
@@ -2076,22 +2081,25 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
TEST_ERROR
- /* Get a pointer to the internal file object */
- if(NULL == (f = (H5F_t *)H5I_object(file)))
- 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((file2 = H5Freopen(file)) < 0)
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
- FAIL_STACK_ERROR
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ STACK_ERROR
/*
- * Test fractal heap creation
+ * Display testing message
*/
-
TESTING("open fractal heap twice");
/* Create heap */
@@ -2109,11 +2117,11 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp
if(check_stats(fh, &state))
TEST_ERROR
- /* Open the heap again */
+ /* Open the heap again, through the first file handle */
if(NULL == (fh2 = H5HF_open(f, H5P_DATASET_XFER_DEFAULT, fh_addr)))
FAIL_STACK_ERROR
- /* Query the type of address mapping */
+ /* Verify the creation parameters */
HDmemset(&test_cparam, 0, sizeof(H5HF_create_t));
if(H5HF_get_cparam_test(fh2, &test_cparam) < 0)
FAIL_STACK_ERROR
@@ -2125,11 +2133,23 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp
FAIL_STACK_ERROR
fh2 = NULL;
+ /* Check for closing & re-opening the heap & file */
+ if(reopen_file(&file, &f, filename, fapl, H5P_DATASET_XFER_DEFAULT, &fh, fh_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file2 = H5Freopen(file)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
+ FAIL_STACK_ERROR
+
/* Open the fractal heap through the second file handle */
if(NULL == (fh2 = H5HF_open(f2, H5P_DATASET_XFER_DEFAULT, fh_addr)))
FAIL_STACK_ERROR
- /* Query the type of address mapping */
+ /* Verify the creation parameters */
HDmemset(&test_cparam, 0, sizeof(H5HF_create_t));
if(H5HF_get_cparam_test(fh2, &test_cparam) < 0)
FAIL_STACK_ERROR
@@ -2153,10 +2173,22 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp
FAIL_STACK_ERROR
fh2 = NULL;
+ /* Delete heap */
+ if(H5HF_delete(f2, H5P_DATASET_XFER_DEFAULT, fh_addr) < 0)
+ FAIL_STACK_ERROR
+
/* Close the second file */
if(H5Fclose(file2) < 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 */
PASSED()
@@ -2171,6 +2203,7 @@ error:
H5Fclose(file);
H5Fclose(file2);
} H5E_END_TRY;
+
return(1);
} /* test_open_twice() */
@@ -2252,7 +2285,7 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *t
if(H5HF_delete(f, H5P_DATASET_XFER_DEFAULT, fh_addr) < 0)
FAIL_STACK_ERROR
- /* Query the type of address mapping */
+ /* Verify the creation parameters */
HDmemset(&test_cparam, 0, sizeof(H5HF_create_t));
if(H5HF_get_cparam_test(fh2, &test_cparam) < 0)
FAIL_STACK_ERROR
@@ -2281,7 +2314,21 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *t
FAIL_STACK_ERROR
fh = NULL;
-#ifdef QAK
+ /* Check for closing & re-opening the file */
+ if(tparam->reopen_heap) {
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_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 = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
/* Try re-opening the heap again (should fail, as heap is now deleted) */
H5E_BEGIN_TRY {
fh = H5HF_open(f, H5P_DATASET_XFER_DEFAULT, fh_addr);
@@ -2293,7 +2340,6 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *t
/* Indicate error */
TEST_ERROR
} /* end if */
-#endif /* QAK */
/* Close the file */
if(H5Fclose(file) < 0)