summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ohdr.c173
-rw-r--r--test/tsohm.c6
2 files changed, 155 insertions, 24 deletions
diff --git a/test/ohdr.c b/test/ohdr.c
index 16f1957..ad83ec1 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -97,7 +97,7 @@ test_cont(char *filename, hid_t fapl)
FAIL_STACK_ERROR
if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
if(H5O_msg_create(&oh_locA, H5O_NAME_ID, 0, 0, &short_name, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
@@ -137,8 +137,9 @@ error:
H5E_BEGIN_TRY {
H5O_close(&oh_locA);
H5O_close(&oh_locB);
- H5Fclose (file);
+ H5Fclose(file);
} H5E_END_TRY;
+
return -1;
} /* test_cont() */
@@ -146,30 +147,28 @@ error:
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose:
+ * Purpose: Exercise private object header behavior and routines
*
- * Return: Success:
- *
- * Failure:
+ * Return: Success: 0
+ * Failure: 1
*
* Programmer: Robb Matzke
* Tuesday, November 24, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
main(void)
{
- hid_t fapl=-1, file=-1;
- hid_t dset=-1;
- H5F_t *f=NULL;
+ hid_t fapl = -1, file = -1;
+ hid_t dset = -1;
+ H5F_t *f = NULL;
char filename[1024];
- H5O_hdr_info_t hdr_info; /* Object info */
- H5O_loc_t oh_loc;
+ H5O_hdr_info_t hdr_info; /* Object info */
+ H5O_loc_t oh_loc, oh_loc2; /* Object header locations */
time_t time_new, ro;
- int i;
+ int chunkno; /* Chunk index for message */
+ int i; /* Local index variable */
hbool_t b; /* Index for "new format" loop */
herr_t ret; /* Generic return value */
@@ -187,15 +186,18 @@ main(void)
HDputs("Using default file format:");
/* Set the format to use for the file */
- if (H5Pset_libver_bounds(fapl, (b ? H5F_LIBVER_LATEST : H5F_LIBVER_EARLIEST), H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR
+ if(H5Pset_libver_bounds(fapl, (b ? H5F_LIBVER_LATEST : H5F_LIBVER_EARLIEST), H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
/* test on object continuation block */
- if (test_cont(filename, fapl) < 0)
+ if(test_cont(filename, fapl) < 0)
FAIL_STACK_ERROR
/* Create the file to operate on */
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
/*
@@ -359,6 +361,140 @@ main(void)
FAIL_STACK_ERROR
PASSED();
+ /*
+ * Test moving message to first chunk
+ */
+ TESTING("locking messages");
+ HDmemset(&oh_loc, 0, sizeof(oh_loc));
+ if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)64, H5P_GROUP_CREATE_DEFAULT, &oh_loc/*out*/) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create second object header, to guarantee that first object header uses multiple chunks */
+ HDmemset(&oh_loc2, 0, sizeof(oh_loc2));
+ if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)64, H5P_GROUP_CREATE_DEFAULT, &oh_loc2/*out*/) < 0)
+ FAIL_STACK_ERROR
+
+ /* Fill object header with messages, creating multiple chunks */
+ for(i = 0; i < 10; i++) {
+ time_new = (i + 1) * 1000 + 10;
+ if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ } /* end for */
+
+ /* Get # of object header chunks */
+ if(H5O_get_hdr_info(&oh_loc, H5P_DATASET_XFER_DEFAULT, &hdr_info) < 0)
+ FAIL_STACK_ERROR
+ if(hdr_info.nchunks != 2)
+ TEST_ERROR
+
+ /* Add message to lock to object header */
+ time_new = 11111111;
+ if(H5O_msg_create(&oh_loc, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify chunk index for message */
+ if((chunkno = H5O_msg_get_chunkno(&oh_loc, H5O_MTIME_ID, H5P_DATASET_XFER_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if(chunkno != 1)
+ TEST_ERROR
+
+ /* Lock the message into the chunk */
+ if(H5O_msg_lock(&oh_loc, H5O_MTIME_ID, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ /* Attempt to lock the message twice */
+ H5E_BEGIN_TRY {
+ ret = H5O_msg_lock(&oh_loc, H5O_MTIME_ID, H5P_DATASET_XFER_DEFAULT);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Delete all the other messages, which would move the message into
+ * chunk #0, if it wasn't locked
+ */
+ if(H5O_msg_remove(&oh_loc, H5O_MTIME_NEW_ID, H5O_ALL, TRUE, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify chunk index for message */
+ if((chunkno = H5O_msg_get_chunkno(&oh_loc, H5O_MTIME_ID, H5P_DATASET_XFER_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if(chunkno != 1)
+ TEST_ERROR
+
+ /* Unlock the message */
+ if(H5O_msg_unlock(&oh_loc, H5O_MTIME_ID, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ /* Attempt to unlock the message twice */
+ H5E_BEGIN_TRY {
+ ret = H5O_msg_unlock(&oh_loc, H5O_MTIME_ID, H5P_DATASET_XFER_DEFAULT);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Close object headers */
+ if(H5O_close(&oh_loc2) < 0)
+ FAIL_STACK_ERROR
+ if(H5O_close(&oh_loc) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open first object header */
+ HDmemset(&oh_loc, 0, sizeof(oh_loc));
+ if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)64, H5P_GROUP_CREATE_DEFAULT, &oh_loc/*out*/) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create second object header, to guarantee that first object header uses multiple chunks */
+ HDmemset(&oh_loc2, 0, sizeof(oh_loc2));
+ if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)64, H5P_GROUP_CREATE_DEFAULT, &oh_loc2/*out*/) < 0)
+ FAIL_STACK_ERROR
+
+ /* Add message to move to object header */
+ time_new = 11111111;
+ if(H5O_msg_create(&oh_loc, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify chunk index for message */
+ if((chunkno = H5O_msg_get_chunkno(&oh_loc, H5O_MTIME_ID, H5P_DATASET_XFER_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if(chunkno != 0)
+ TEST_ERROR
+
+ /* Lock the message into the chunk */
+ if(H5O_msg_lock(&oh_loc, H5O_MTIME_ID, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ /* Fill object header with messages, creating multiple chunks */
+ /* (would normally move locked message to new chunk) */
+ for(i = 0; i < 10; i++) {
+ time_new = (i + 1) * 1000 + 10;
+ if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ } /* end for */
+
+ /* Get # of object header chunks */
+ if(H5O_get_hdr_info(&oh_loc, H5P_DATASET_XFER_DEFAULT, &hdr_info) < 0)
+ FAIL_STACK_ERROR
+ if(hdr_info.nchunks != 2)
+ TEST_ERROR
+
+ /* Verify chunk index for message */
+ if((chunkno = H5O_msg_get_chunkno(&oh_loc, H5O_MTIME_ID, H5P_DATASET_XFER_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if(chunkno != 0)
+ TEST_ERROR
+
+ /* Unlock the message */
+ if(H5O_msg_unlock(&oh_loc, H5O_MTIME_ID, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close object headers */
+ if(H5O_close(&oh_loc2) < 0)
+ FAIL_STACK_ERROR
+ if(H5O_close(&oh_loc) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED();
+
/* Test reading datasets with undefined object header messages */
HDputs("Accessing objects with unknown header messages:");
@@ -477,6 +613,7 @@ error:
H5E_BEGIN_TRY {
H5Fclose(file);
} H5E_END_TRY;
+
return(1);
} /* end main() */
diff --git a/test/tsohm.c b/test/tsohm.c
index 28854e2..8782a6d 100644
--- a/test/tsohm.c
+++ b/test/tsohm.c
@@ -2446,15 +2446,9 @@ static void test_sohm_size2(int close_reopen)
if((mult_index_med.dsets2 - mult_index_med.dsets1) >
(list_index_med.dsets2 - list_index_med.dsets1) * OVERHEAD_ALLOWED)
VERIFY(0, 1, "h5_get_file_size");
- if((mult_index_med.dsets2 - mult_index_med.dsets1) <
- (list_index_med.dsets2 - list_index_med.dsets1))
- VERIFY(0, 1, "h5_get_file_size");
if((mult_index_btree.dsets2 - mult_index_btree.dsets1) >
(btree_index.dsets2 - btree_index.dsets1) * OVERHEAD_ALLOWED)
VERIFY(0, 1, "h5_get_file_size");
- if((mult_index_btree.dsets2 - mult_index_btree.dsets1) <
- (btree_index.dsets2 - btree_index.dsets1))
- VERIFY(0, 1, "h5_get_file_size");
if((mult_index_med.interleaved - mult_index_med.dsets2) >
(list_index_med.interleaved - list_index_med.dsets2) * OVERHEAD_ALLOWED)