diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-22 21:59:31 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-22 21:59:31 (GMT) |
commit | d94581e19b6029d7839e41f882b6b453a87e249e (patch) | |
tree | e2af0b046bf32b9f00a4b8b6b63eec9102ce7917 /test/ohdr.c | |
parent | edf124f40bc52044ba7f020225029d05190ffd39 (diff) | |
download | hdf5-d94581e19b6029d7839e41f882b6b453a87e249e.zip hdf5-d94581e19b6029d7839e41f882b6b453a87e249e.tar.gz hdf5-d94581e19b6029d7839e41f882b6b453a87e249e.tar.bz2 |
[svn-r18618] Description:
Add new internal object header routines to query the header chunk that
a message is in, and to lock/unlock a message into a chunk (so it doesn't get
moved into another chunk during allocation/free events).
Also, move dataspace message to beginning of object header messages
added to a dataset's object header, so it can be locked into chunk #0 (when
performing SWMR operations).
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) 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 debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'test/ohdr.c')
-rw-r--r-- | test/ohdr.c | 173 |
1 files changed, 155 insertions, 18 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() */ |