summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-09-11 14:03:23 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-09-11 14:03:23 (GMT)
commitf1d22675ffc09e604c8715b2a6a010ec21acb771 (patch)
treee6d1551f3f8eb71bfeace3255a3fca50cca25cbb /test
parent37ebc24cf85a9aca975181f67afea59ddf08a5ed (diff)
downloadhdf5-f1d22675ffc09e604c8715b2a6a010ec21acb771.zip
hdf5-f1d22675ffc09e604c8715b2a6a010ec21acb771.tar.gz
hdf5-f1d22675ffc09e604c8715b2a6a010ec21acb771.tar.bz2
[svn-r15614] Description:
More extensible array features: add support for setting/getting elements in the array's index block. 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
Diffstat (limited to 'test')
-rw-r--r--test/earray.c80
1 files changed, 63 insertions, 17 deletions
diff --git a/test/earray.c b/test/earray.c
index 32b58bb..868a7ba 100644
--- a/test/earray.c
+++ b/test/earray.c
@@ -36,7 +36,7 @@
#define EARRAY_FILENAME_LEN 1024
/* Extensible array creation values */
-#define ELMT_SIZE sizeof(haddr_t)
+#define ELMT_SIZE sizeof(uint64_t)
#define MAX_NELMTS_BITS 32
#define IDX_BLK_ELMTS 4
#define SUP_BLK_MIN_DATA_PTRS 4
@@ -215,7 +215,8 @@ error:
*/
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)
+ H5EA_t **ea, haddr_t ea_addr, const H5EA_class_t *ea_cls,
+ const earray_test_param_t *tparam)
{
/* Check for closing & re-opening the array */
/* (actually will close & re-open the file as well) */
@@ -243,7 +244,7 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
/* Re-open array, if given */
if(ea) {
- if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr)))
+ if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, ea_cls)))
FAIL_STACK_ERROR
} /* end if */
} /* end if */
@@ -281,7 +282,7 @@ create_array(H5F_t *f, hid_t dxpl, const H5EA_create_t *cparam,
FAIL_STACK_ERROR
/* Check status of array */
- nelmts = 0;
+ nelmts = (hsize_t)ULLONG_MAX;
if(H5EA_get_nelmts(*ea, &nelmts) < 0)
FAIL_STACK_ERROR
if(nelmts > 0)
@@ -572,11 +573,11 @@ test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
FAIL_STACK_ERROR
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, tparam) < 0)
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, NULL, tparam) < 0)
TEST_ERROR
/* Re-open the array */
- if(NULL == (ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr)))
+ if(NULL == (ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
@@ -641,7 +642,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
TEST_ERROR
/* Open the array again, through the first file handle */
- if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr)))
+ if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
@@ -656,7 +657,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
ea2 = NULL;
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, cparam->cls, tparam) < 0)
TEST_ERROR
/* Re-open the file */
@@ -668,7 +669,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
FAIL_STACK_ERROR
/* Open the extensible array through the second file handle */
- if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr)))
+ if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
@@ -747,7 +748,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
TEST_ERROR
/* Open the array again */
- if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr)))
+ if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls)))
FAIL_STACK_ERROR
/* Request that the array be deleted */
@@ -767,7 +768,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
/* 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);
+ ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls);
} H5E_END_TRY;
if(ea2) {
/* Close opened array */
@@ -783,12 +784,12 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
ea = NULL;
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, tparam) < 0)
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, NULL, 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);
+ ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls);
} H5E_END_TRY;
if(ea) {
/* Close opened array */
@@ -847,6 +848,10 @@ 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 */
+ 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 */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
/* Create file & retrieve pointer to internal file object */
@@ -867,14 +872,55 @@ test_set_first(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
TEST_ERROR
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
+ 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 first element of array (not set yet) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, 0, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify first element is fill value for array */
+ if(relmt != H5EA_TEST_FILL)
+ TEST_ERROR
+
+ /* Set first element of array */
+ welmt = (uint64_t)7;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, 0, &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 != 1)
TEST_ERROR
-/* Set first element of array */
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ if(check_stats(ea, &state))
+ TEST_ERROR
-/* Verify # of elements */
+ /* Retrieve first element of array (set now) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, 0, &relmt) < 0)
+ FAIL_STACK_ERROR
-/* Verify array state */
+ /* Verify first element is value written */
+ if(relmt != welmt)
+ TEST_ERROR
/* Close array, delete array, close file & verify file is empty */
if(shutdown(file, f, ea, ea_addr) < 0)