summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-09-22 22:42:21 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-09-22 22:42:21 (GMT)
commitfe6cf16d94aeface4e429660142b243f471f8fbb (patch)
tree84c9fa296ad75a00eec67022737003b12d3ccf7f
parentd0859bb17474d05e87eb9cbf3ccfd28c92c84185 (diff)
downloadhdf5-fe6cf16d94aeface4e429660142b243f471f8fbb.zip
hdf5-fe6cf16d94aeface4e429660142b243f471f8fbb.tar.gz
hdf5-fe6cf16d94aeface4e429660142b243f471f8fbb.tar.bz2
[svn-r15681] Description:
Correct small error in allocating data block elements and add some more tests. 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/H5EAhdr.c2
-rw-r--r--test/earray.c256
2 files changed, 255 insertions, 3 deletions
diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c
index a49116f..5fcf2be 100644
--- a/src/H5EAhdr.c
+++ b/src/H5EAhdr.c
@@ -265,7 +265,7 @@ HDfprintf(stderr, "%s: nelmts = %Zu, hdr->data_blk_min_elmts = %u, idx = %u\n",
/* Check for needing to increase size of array of factories */
if(idx >= hdr->elmt_fac.nalloc) {
H5FL_fac_head_t **new_fac; /* New array of element factories */
- size_t new_nalloc = MAX(1, (2 * hdr->elmt_fac.nalloc)); /* New number of factories allocated */
+ size_t new_nalloc = MAX3(1, (idx + 1), (2 * hdr->elmt_fac.nalloc)); /* New number of factories allocated */
/* Re-allocate array of element factories */
if(NULL == (new_fac = H5FL_SEQ_REALLOC(H5FL_fac_head_ptr_t, hdr->elmt_fac.fac, new_nalloc)))
diff --git a/test/earray.c b/test/earray.c
index 3b33c0a..c0c7bb7 100644
--- a/test/earray.c
+++ b/test/earray.c
@@ -1120,7 +1120,7 @@ error:
/*-------------------------------------------------------------------------
- * Function: test_set_first_dblock
+ * Function: test_set_first_dblock_first
*
* Purpose: Set first element in extensible array's first data block
*
@@ -1133,7 +1133,7 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_set_first_dblock(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
+test_set_first_dblock_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 */
@@ -1236,10 +1236,260 @@ error:
} H5E_END_TRY;
return 1;
+} /* test_set_first_dblock_first() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_set_first_dblock
+ *
+ * Purpose: Set all elements in extensible array's first data block
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, September 22, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_set_first_dblock(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 */
+ earray_state_t state; /* State of extensible array */
+ uint64_t welmt; /* Element to write */
+ uint64_t relmt; /* Element to read */
+ hsize_t nelmts; /* Highest element written in array */
+ hsize_t idx; /* Index value of first element of first data block */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+ unsigned u; /* Local index variable */
+
+ /*
+ * Display testing message
+ */
+ TESTING("setting all elements of array's first data block");
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /* 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, cparam->cls, tparam) < 0)
+ TEST_ERROR
+
+ /* Verify high-water # of elements written */
+ nelmts = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(ea, &nelmts) < 0)
+ FAIL_STACK_ERROR
+ if(nelmts != 0)
+ TEST_ERROR
+
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ if(check_stats(ea, &state))
+ TEST_ERROR
+
+ /* Retrieve elements of array in data block (not set yet) */
+ for(u = 0; u < cparam->data_blk_min_elmts; u++) {
+ /* Compute index of element of first data block */
+ idx = cparam->idx_blk_elmts + u;
+
+ /* Retrieve element of first data block of array (not set yet) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify element is fill value for array */
+ if(relmt != H5EA_TEST_FILL)
+ TEST_ERROR
+ } /* end for */
+
+ /* Set elements of array in index block */
+ for(u = 0; u < cparam->data_blk_min_elmts; u++) {
+ /* Compute index of element of first data block */
+ idx = cparam->idx_blk_elmts + u;
+
+ /* Set element of first data block */
+ welmt = (uint64_t)7 + u;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify high-water # of elements written */
+ nelmts = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(ea, &nelmts) < 0)
+ FAIL_STACK_ERROR
+ if(nelmts != (idx + 1))
+ TEST_ERROR
+
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ state.max_idx_set = idx + 1;
+ state.ndata_blks = 1;
+ state.nelmts = (hsize_t)(cparam->idx_blk_elmts + cparam->data_blk_min_elmts);
+ if(check_stats(ea, &state))
+ TEST_ERROR
+
+ /* Retrieve element of array (set now) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify element is value written */
+ if(relmt != welmt)
+ TEST_ERROR
+ } /* end for */
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(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_dblock() */
/*-------------------------------------------------------------------------
+ * Function: test_set_second_dblock_first
+ *
+ * Purpose: Set first element in extensible array's second data block
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, September 22, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_set_second_dblock_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 */
+ earray_state_t state; /* State of extensible array */
+ uint64_t welmt; /* Element to write */
+ uint64_t relmt; /* Element to read */
+ hsize_t nelmts; /* Highest element written in array */
+ hsize_t idx; /* Index value of first element of first data block */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /*
+ * Display testing message
+ */
+ TESTING("setting first element of array's second data block");
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /* 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, cparam->cls, tparam) < 0)
+ TEST_ERROR
+
+ /* Verify high-water # of elements written */
+ nelmts = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(ea, &nelmts) < 0)
+ FAIL_STACK_ERROR
+ if(nelmts != 0)
+ TEST_ERROR
+
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ if(check_stats(ea, &state))
+ TEST_ERROR
+
+ /* Compute index of first element of second data block */
+ idx = (hsize_t)(cparam->idx_blk_elmts + cparam->data_blk_min_elmts);
+
+ /* Retrieve element from array (not set yet) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify element is fill value for array */
+ if(relmt != H5EA_TEST_FILL)
+ TEST_ERROR
+
+ /* Set element of array */
+ welmt = (uint64_t)7;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify high-water # of elements written */
+ nelmts = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(ea, &nelmts) < 0)
+ FAIL_STACK_ERROR
+ if(nelmts != (idx + 1))
+ TEST_ERROR
+
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ state.max_idx_set = idx + 1;
+ state.ndata_blks = 1;
+ state.nelmts = (hsize_t)(cparam->idx_blk_elmts + cparam->data_blk_min_elmts * 2);
+ if(check_stats(ea, &state))
+ TEST_ERROR
+
+ /* Retrieve element of array (set now) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify element is value written */
+ if(relmt != welmt)
+ TEST_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(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_second_dblock_first() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test the extensible array code
@@ -1332,7 +1582,9 @@ main(void)
/* Basic capacity tests */
nerrors += test_set_first(fapl, &cparam, &tparam);
nerrors += test_set_iblock(fapl, &cparam, &tparam);
+ nerrors += test_set_first_dblock_first(fapl, &cparam, &tparam);
nerrors += test_set_first_dblock(fapl, &cparam, &tparam);
+ nerrors += test_set_second_dblock_first(fapl, &cparam, &tparam);
} /* end for */
if(nerrors)