diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-09-30 14:27:10 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-09-30 14:27:10 (GMT) |
commit | b2d661b508a7fc7a2592c13bc6bdc175551f075d (patch) | |
tree | 13baeb0d83a7c2a4c6299993c182b1227c2f6114 /test/file_image.c | |
parent | 29ab58b58dce556639ea3154e262895773a8a8df (diff) | |
download | hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2 |
Clang-format of source files
Diffstat (limited to 'test/file_image.c')
-rw-r--r-- | test/file_image.c | 634 |
1 files changed, 318 insertions, 316 deletions
diff --git a/test/file_image.c b/test/file_image.c index d784df2..5b94a53 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -12,62 +12,60 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: file_image -* -* Test setting file images -* -*************************************************************/ + * + * Test program: file_image + * + * Test setting file images + * + *************************************************************/ #include "h5test.h" #include "H5Fprivate.h" /* required to test property removals */ -#define VERIFY(condition, string) do { if (!(condition)) FAIL_PUTS_ERROR(string) } while(0) +#define VERIFY(condition, string) \ + do { \ + if (!(condition)) \ + FAIL_PUTS_ERROR(string) \ + } while (0) /* Values for callback bit field */ -#define MALLOC 0x01 -#define MEMCPY 0x02 -#define REALLOC 0x04 -#define FREE 0x08 -#define UDATA_COPY 0x10 -#define UDATA_FREE 0x20 - -#define RANK 2 -#define DIM0 1024 -#define DIM1 32 +#define MALLOC 0x01 +#define MEMCPY 0x02 +#define REALLOC 0x04 +#define FREE 0x08 +#define UDATA_COPY 0x10 +#define UDATA_FREE 0x20 + +#define RANK 2 +#define DIM0 1024 +#define DIM1 32 #define DSET_NAME "test_dset" #define FAMILY_SIZE (2 * 1024) #define USERBLOCK_SIZE 512 -const char *FILENAME[] = { - "file_image_core_test", - NULL -}; +const char *FILENAME[] = {"file_image_core_test", NULL}; /* need a second file name array, as the first file name array contains * files we don't want to delete on cleanup. */ -const char *FILENAME2[] = { - "sec2_get_file_image_test", - "stdio_get_file_image_test", - "core_get_file_image_test", - "family_get_file_image_test", - "multi_get_file_image_test", - "split_get_file_image_test", - "get_file_image_error_rejection_test", - NULL -}; +const char *FILENAME2[] = {"sec2_get_file_image_test", + "stdio_get_file_image_test", + "core_get_file_image_test", + "family_get_file_image_test", + "multi_get_file_image_test", + "split_get_file_image_test", + "get_file_image_error_rejection_test", + NULL}; typedef struct { - unsigned char used_callbacks; /* Bitfield for tracking callbacks */ - H5FD_file_image_op_t malloc_src; /* Source of file image callbacks */ + unsigned char used_callbacks; /* Bitfield for tracking callbacks */ + H5FD_file_image_op_t malloc_src; /* Source of file image callbacks */ H5FD_file_image_op_t memcpy_src; H5FD_file_image_op_t realloc_src; H5FD_file_image_op_t free_src; } udata_t; - /****************************************************************************** * Function: test_properties * @@ -85,16 +83,16 @@ typedef struct { static int test_properties(void) { - hid_t fapl_1 = -1; - hid_t fapl_2 = -1; - char *buffer = 0; - int count = 10; - void *temp = 0; - char *temp2 = 0; - int i; - size_t size; - size_t temp_size; - int retval = 1; + hid_t fapl_1 = -1; + hid_t fapl_2 = -1; + char * buffer = 0; + int count = 10; + void * temp = 0; + char * temp2 = 0; + int i; + size_t size; + size_t temp_size; + int retval = 1; TESTING("File image property list functions"); @@ -104,27 +102,31 @@ test_properties(void) * property list functions. In the file driver tests further down, this will * not be the case. */ - size = (size_t)count * sizeof(char); + size = (size_t)count * sizeof(char); buffer = (char *)HDmalloc(size); - for(i = 0; i < count - 1; i++) + for (i = 0; i < count - 1; i++) buffer[i] = (char)(65 + i); buffer[count - 1] = '\0'; /* Create fapl */ - if((fapl_1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR + if ((fapl_1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR /* Get file image stuff */ - if(H5Pget_file_image(fapl_1, (void **)&temp, &temp_size) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image(fapl_1, (void **)&temp, &temp_size) < 0) + FAIL_STACK_ERROR /* Check default values */ VERIFY(temp == NULL, "Default pointer is wrong"); VERIFY(temp_size == 0, "Default size is wrong"); /* Set file image stuff */ - if(H5Pset_file_image(fapl_1, (void *)buffer, size) < 0) FAIL_STACK_ERROR + if (H5Pset_file_image(fapl_1, (void *)buffer, size) < 0) + FAIL_STACK_ERROR /* Get the same */ - if(H5Pget_file_image(fapl_1, (void **)&temp, &temp_size) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image(fapl_1, (void **)&temp, &temp_size) < 0) + FAIL_STACK_ERROR /* Check that sizes are the same, and that the buffers are identical but separate */ VERIFY(temp != NULL, "temp is null!"); @@ -133,36 +135,39 @@ test_properties(void) VERIFY(0 == HDmemcmp(temp, buffer, size), "Buffers contain different data"); /* Copy the fapl */ - if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR + if ((fapl_2 = H5Pcopy(fapl_1)) < 0) + FAIL_STACK_ERROR /* Get values from the new fapl */ - if(H5Pget_file_image(fapl_2, (void **)&temp2, &temp_size) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image(fapl_2, (void **)&temp2, &temp_size) < 0) + FAIL_STACK_ERROR /* Check that sizes are the same, and that the buffers are identical but separate */ - VERIFY(temp_size == size,"Sizes of buffers don't match"); - VERIFY(temp2 != NULL,"Recieved buffer not set"); + VERIFY(temp_size == size, "Sizes of buffers don't match"); + VERIFY(temp2 != NULL, "Recieved buffer not set"); VERIFY(temp2 != buffer, "Retrieved buffer is the same as original"); VERIFY(temp2 != temp, "Retrieved buffer is the same as previously retrieved buffer"); - VERIFY(0 == HDmemcmp(temp2, buffer, size),"Buffers contain different data"); + VERIFY(0 == HDmemcmp(temp2, buffer, size), "Buffers contain different data"); retval = 0; error: /* Close everything */ - if(H5Pclose(fapl_1) < 0) retval = 1; - if(H5Pclose(fapl_2) < 0) retval = 1; + if (H5Pclose(fapl_1) < 0) + retval = 1; + if (H5Pclose(fapl_2) < 0) + retval = 1; HDfree(buffer); H5free_memory(temp); H5free_memory(temp2); - if(retval == 0) + if (retval == 0) PASSED(); return retval; } /* end test_properties() */ - /****************************************************************************** * Function: malloc_cb * @@ -185,7 +190,6 @@ malloc_cb(size_t size, H5FD_file_image_op_t op, void *udata) return HDmalloc(size); } - /****************************************************************************** * Function: memcpy_cb * @@ -208,7 +212,6 @@ memcpy_cb(void *dest, const void *src, size_t size, H5FD_file_image_op_t op, voi return HDmemcpy(dest, src, size); } - /****************************************************************************** * Function: realloc_cb * @@ -228,10 +231,9 @@ realloc_cb(void *ptr, size_t size, H5FD_file_image_op_t op, void *udata) u->used_callbacks |= REALLOC; u->realloc_src = op; - return HDrealloc(ptr,size); + return HDrealloc(ptr, size); } - /****************************************************************************** * Function: free_cb * @@ -250,10 +252,9 @@ free_cb(void *ptr, H5FD_file_image_op_t op, void *udata) u->used_callbacks |= FREE; u->free_src = op; HDfree(ptr); - return(SUCCEED); + return (SUCCEED); } - /****************************************************************************** * Function: udata_copy_cb * @@ -277,7 +278,6 @@ udata_copy_cb(void *udata) return udata; } - /****************************************************************************** * Function: udata_free_cb * @@ -298,10 +298,9 @@ udata_free_cb(void *udata) udata_t *u = (udata_t *)udata; u->used_callbacks |= UDATA_FREE; - return(SUCCEED); + return (SUCCEED); } - /****************************************************************************** * Function: reset_udata * @@ -320,7 +319,6 @@ reset_udata(udata_t *u) u->malloc_src = u->memcpy_src = u->realloc_src = u->free_src = H5FD_FILE_IMAGE_OP_NO_OP; } - /****************************************************************************** * Function: test_callbacks * @@ -334,19 +332,19 @@ reset_udata(udata_t *u) static int test_callbacks(void) { - H5FD_file_image_callbacks_t real_callbacks = {&malloc_cb, &memcpy_cb, &realloc_cb, - &free_cb, &udata_copy_cb, &udata_free_cb, NULL}; + H5FD_file_image_callbacks_t real_callbacks = {&malloc_cb, &memcpy_cb, &realloc_cb, &free_cb, + &udata_copy_cb, &udata_free_cb, NULL}; H5FD_file_image_callbacks_t null_callbacks = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; H5FD_file_image_callbacks_t callbacks; - hid_t fapl_1; - hid_t fapl_2; - udata_t *udata; - char *file_image; - char *temp_file_image; - int count = 10; - int i; - size_t size; - size_t temp_size; + hid_t fapl_1; + hid_t fapl_2; + udata_t * udata; + char * file_image; + char * temp_file_image; + int count = 10; + int i; + size_t size; + size_t temp_size; TESTING("Callback use in property list operations"); @@ -358,18 +356,20 @@ test_callbacks(void) real_callbacks.udata = (void *)udata; /* Allocate and initialize file image buffer */ - size = (size_t)count * sizeof(char); + size = (size_t)count * sizeof(char); file_image = (char *)HDmalloc(size); - for(i = 0; i < count - 1; i++) + for (i = 0; i < count - 1; i++) file_image[i] = (char)(65 + i); file_image[count - 1] = '\0'; /* Create fapl */ - if((fapl_1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR + if ((fapl_1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR /* Get file image stuff */ callbacks = real_callbacks; - if(H5Pget_file_image_callbacks(fapl_1, &callbacks) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image_callbacks(fapl_1, &callbacks) < 0) + FAIL_STACK_ERROR /* Check default values */ VERIFY(callbacks.image_malloc == NULL, "Default malloc callback is wrong"); @@ -380,14 +380,15 @@ test_callbacks(void) VERIFY(callbacks.udata_free == NULL, "Default udata free callback is wrong"); VERIFY(callbacks.udata == NULL, "Default udata is wrong"); - /* Set file image callbacks */ callbacks = real_callbacks; - if(H5Pset_file_image_callbacks(fapl_1, &callbacks) < 0) FAIL_STACK_ERROR + if (H5Pset_file_image_callbacks(fapl_1, &callbacks) < 0) + FAIL_STACK_ERROR /* Get file image callbacks */ callbacks = null_callbacks; - if(H5Pget_file_image_callbacks(fapl_1, &callbacks) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image_callbacks(fapl_1, &callbacks) < 0) + FAIL_STACK_ERROR /* Verify values */ VERIFY(callbacks.image_malloc == &malloc_cb, "malloc callback was not set or retrieved properly"); @@ -398,50 +399,59 @@ test_callbacks(void) VERIFY(callbacks.udata_free == &udata_free_cb, "udata free callback was not set or retrieved properly"); VERIFY(callbacks.udata == udata, "udata was not set or retrieved properly"); - /* * Check callbacks in internal function without a previously set file image */ /* Copy fapl */ reset_udata(udata); - if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR + if ((fapl_2 = H5Pcopy(fapl_1)) < 0) + FAIL_STACK_ERROR /* Verify that the property's copy callback used the correct image callbacks */ VERIFY(udata->used_callbacks == (UDATA_COPY), "Copying a fapl with no image used incorrect callbacks"); /* Close fapl */ reset_udata(udata); - if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_2) < 0) + FAIL_STACK_ERROR /* Verify that the udata free callback was used */ VERIFY(udata->used_callbacks == (UDATA_FREE), "Closing a fapl with no image used incorrect callbacks"); /* Copy again */ - if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR + if ((fapl_2 = H5Pcopy(fapl_1)) < 0) + FAIL_STACK_ERROR /* Remove property from fapl */ reset_udata(udata); - if(H5Premove(fapl_2, H5F_ACS_FILE_IMAGE_INFO_NAME) < 0) FAIL_STACK_ERROR + if (H5Premove(fapl_2, H5F_ACS_FILE_IMAGE_INFO_NAME) < 0) + FAIL_STACK_ERROR /* Verify that the property's delete callback was called using the correct image callbacks */ - VERIFY(udata->used_callbacks == (UDATA_FREE), "Removing a property from a fapl with no image used incorrect callbacks"); + VERIFY(udata->used_callbacks == (UDATA_FREE), + "Removing a property from a fapl with no image used incorrect callbacks"); /* Close it again */ - if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_2) < 0) + FAIL_STACK_ERROR /* Get file image */ reset_udata(udata); - if(H5Pget_file_image(fapl_1, (void **)&temp_file_image, &temp_size) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image(fapl_1, (void **)&temp_file_image, &temp_size) < 0) + FAIL_STACK_ERROR /* Verify that the correct callbacks were used */ - VERIFY(udata->used_callbacks == 0, "attempting to retrieve the image from a fapl without an image has an unexpected callback"); + VERIFY(udata->used_callbacks == 0, + "attempting to retrieve the image from a fapl without an image has an unexpected callback"); /* Set file image */ reset_udata(udata); - if(H5Pset_file_image(fapl_1, (void *)file_image, size) < 0) FAIL_STACK_ERROR + if (H5Pset_file_image(fapl_1, (void *)file_image, size) < 0) + FAIL_STACK_ERROR - VERIFY(udata->used_callbacks == (MALLOC | MEMCPY), "Setting a file image (first time) used incorrect callbacks"); + VERIFY(udata->used_callbacks == (MALLOC | MEMCPY), + "Setting a file image (first time) used incorrect callbacks"); /* * Check callbacks in internal functions with a previously set file image @@ -449,55 +459,68 @@ test_callbacks(void) /* Copy fapl */ reset_udata(udata); - if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR + if ((fapl_2 = H5Pcopy(fapl_1)) < 0) + FAIL_STACK_ERROR /* Verify that the property's copy callback used the correct image callbacks */ - VERIFY(udata->used_callbacks == (MALLOC | MEMCPY | UDATA_COPY), "Copying a fapl with an image used incorrect callbacks"); + VERIFY(udata->used_callbacks == (MALLOC | MEMCPY | UDATA_COPY), + "Copying a fapl with an image used incorrect callbacks"); VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, "malloc callback has wrong source"); VERIFY(udata->memcpy_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, "memcpy callback has wrong source"); /* Close fapl */ reset_udata(udata); - if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_2) < 0) + FAIL_STACK_ERROR /* Verify that the udata free callback was used */ - VERIFY(udata->used_callbacks == (FREE | UDATA_FREE), "Closing a fapl with an image used incorrect callbacks"); + VERIFY(udata->used_callbacks == (FREE | UDATA_FREE), + "Closing a fapl with an image used incorrect callbacks"); VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, "free callback has wrong source"); /* Copy again */ - if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR + if ((fapl_2 = H5Pcopy(fapl_1)) < 0) + FAIL_STACK_ERROR /* Remove property from fapl */ reset_udata(udata); - if(H5Premove(fapl_2, H5F_ACS_FILE_IMAGE_INFO_NAME) < 0) FAIL_STACK_ERROR + if (H5Premove(fapl_2, H5F_ACS_FILE_IMAGE_INFO_NAME) < 0) + FAIL_STACK_ERROR /* Verify that the property's delete callback was called using the correct image callbacks */ - VERIFY(udata->used_callbacks == (FREE | UDATA_FREE), "Removing a property from a fapl with an image used incorrect callbacks"); + VERIFY(udata->used_callbacks == (FREE | UDATA_FREE), + "Removing a property from a fapl with an image used incorrect callbacks"); VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, "free callback has wrong source"); /* Close it again */ - if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_2) < 0) + FAIL_STACK_ERROR /* Get file image */ reset_udata(udata); - if(H5Pget_file_image(fapl_1, (void **)&temp_file_image, &temp_size) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image(fapl_1, (void **)&temp_file_image, &temp_size) < 0) + FAIL_STACK_ERROR /* Verify that the correct callbacks were used */ - VERIFY(udata->used_callbacks == (MALLOC | MEMCPY), "attempting to retrieve the image from a fapl with an image has an unexpected callback"); + VERIFY(udata->used_callbacks == (MALLOC | MEMCPY), + "attempting to retrieve the image from a fapl with an image has an unexpected callback"); VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, "malloc callback has wrong source"); VERIFY(udata->memcpy_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, "memcpy callback has wrong source"); /* Set file image */ reset_udata(udata); - if(H5Pset_file_image(fapl_1, (void *)file_image, size) < 0) FAIL_STACK_ERROR + if (H5Pset_file_image(fapl_1, (void *)file_image, size) < 0) + FAIL_STACK_ERROR - VERIFY(udata->used_callbacks == (FREE | MALLOC | MEMCPY), "Setting a file image (second time) used incorrect callbacks"); + VERIFY(udata->used_callbacks == (FREE | MALLOC | MEMCPY), + "Setting a file image (second time) used incorrect callbacks"); VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, "malloc callback has wrong source"); VERIFY(udata->memcpy_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, "memcpy callback has wrong source"); VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, "freec callback has wrong source"); /* Close stuff */ - if(H5Pclose(fapl_1) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_1) < 0) + FAIL_STACK_ERROR HDfree(file_image); HDfree(temp_file_image); HDfree(udata); @@ -509,7 +532,6 @@ error: return 1; } /* test_callbacks() */ - /****************************************************************************** * Function: test_core * @@ -524,22 +546,22 @@ error: static int test_core(void) { - hid_t fapl; - hid_t file; - hid_t dset; - hid_t space; - udata_t *udata; - unsigned char *file_image; - char filename[1024]; - char copied_filename[1024]; - const char *tmp = NULL; - size_t size; - hsize_t dims[2]; - int fd; - h5_stat_t sb; - herr_t ret; - H5FD_file_image_callbacks_t callbacks = {&malloc_cb, &memcpy_cb, &realloc_cb, - &free_cb, &udata_copy_cb, &udata_free_cb, NULL}; + hid_t fapl; + hid_t file; + hid_t dset; + hid_t space; + udata_t * udata; + unsigned char * file_image; + char filename[1024]; + char copied_filename[1024]; + const char * tmp = NULL; + size_t size; + hsize_t dims[2]; + int fd; + h5_stat_t sb; + herr_t ret; + H5FD_file_image_callbacks_t callbacks = {&malloc_cb, &memcpy_cb, &realloc_cb, &free_cb, + &udata_copy_cb, &udata_free_cb, NULL}; TESTING("Initial file image and callbacks in Core VFD"); @@ -579,16 +601,18 @@ test_core(void) reset_udata(udata); file = H5Fopen(copied_filename, H5F_ACC_RDONLY, fapl); VERIFY(file >= 0, "H5Fopen failed"); - VERIFY((udata->used_callbacks == MALLOC) || - (udata->used_callbacks == (MALLOC | UDATA_COPY | UDATA_FREE)), "opening a core file used the wrong callbacks"); - VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_FILE_OPEN, "Malloc callback came from wrong sourc in core open"); + VERIFY((udata->used_callbacks == MALLOC) || (udata->used_callbacks == (MALLOC | UDATA_COPY | UDATA_FREE)), + "opening a core file used the wrong callbacks"); + VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_FILE_OPEN, + "Malloc callback came from wrong sourc in core open"); /* Close file */ reset_udata(udata); ret = H5Fclose(file); VERIFY(ret >= 0, "H5Fclose failed"); VERIFY(udata->used_callbacks == FREE, "Closing a core file used the wrong callbacks"); - VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, "Free callback came from wrong sourc in core close"); + VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, + "Free callback came from wrong sourc in core close"); /* Reopen file */ file = H5Fopen(copied_filename, H5F_ACC_RDWR, fapl); @@ -597,19 +621,20 @@ test_core(void) /* Set up a new dset */ dims[0] = DIM0; dims[1] = DIM1; - space = H5Screate_simple(RANK, dims, dims); + space = H5Screate_simple(RANK, dims, dims); VERIFY(space >= 0, "H5Screate failed"); /* Create new dset, invoking H5FD_core_write */ reset_udata(udata); dset = H5Dcreate2(file, DSET_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset >=0, "H5Dcreate failed"); + VERIFY(dset >= 0, "H5Dcreate failed"); /* Flush the write and check the realloc callback */ ret = H5Fflush(file, H5F_SCOPE_LOCAL); VERIFY(ret >= 0, "H5Fflush failed"); VERIFY(udata->used_callbacks == (REALLOC), "core write used the wrong callbacks"); - VERIFY(udata->realloc_src == H5FD_FILE_IMAGE_OP_FILE_RESIZE, "Realloc callback came from wrong source in core write"); + VERIFY(udata->realloc_src == H5FD_FILE_IMAGE_OP_FILE_RESIZE, + "Realloc callback came from wrong source in core write"); /* Close dset and space */ ret = H5Dclose(dset); @@ -622,26 +647,30 @@ test_core(void) ret = H5Fclose(file); VERIFY(ret >= 0, "H5Fclose failed"); VERIFY(udata->used_callbacks == (FREE), "Closing a core file used the wrong callbacks"); - VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, "Free callback came from wrong sourc in core close"); + VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, + "Free callback came from wrong sourc in core close"); /* Create file image buffer */ fd = HDopen(copied_filename, O_RDONLY); VERIFY(fd > 0, "open failed"); ret = HDfstat(fd, &sb); VERIFY(ret == 0, "fstat failed"); - size = (size_t)sb.st_size; + size = (size_t)sb.st_size; file_image = (unsigned char *)HDmalloc(size); - if(HDread(fd, file_image, size) < 0) + if (HDread(fd, file_image, size) < 0) FAIL_PUTS_ERROR("unable to read from file descriptor"); ret = HDclose(fd); VERIFY(ret == 0, "close failed"); /* Set file image in plist */ - if(H5Pset_file_image(fapl, file_image, size) < 0) FAIL_STACK_ERROR + if (H5Pset_file_image(fapl, file_image, size) < 0) + FAIL_STACK_ERROR /* Test open with file image */ - if((file = H5Fopen("dne.h5", H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if ((file = H5Fopen("dne.h5", H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Release resources */ h5_clean_files(FILENAME, fapl); @@ -657,7 +686,6 @@ error: return 1; } /* end test_core() */ - /****************************************************************************** * Function: test_get_file_image * @@ -680,35 +708,32 @@ error: */ H5_GCC_DIAG_OFF("format-nonliteral") static int -test_get_file_image(const char * test_banner, - const int file_name_num, - hid_t fapl, - hbool_t user) +test_get_file_image(const char *test_banner, const int file_name_num, hid_t fapl, hbool_t user) { - char file_name[1024] = "\0"; - void * insertion_ptr = NULL; - void * image_ptr = NULL; - void * file_image_ptr = NULL; - hbool_t is_family_file = FALSE; - hbool_t identical; - int data[100]; - int i; - int fd = -1; - int result; - hid_t driver = -1; - hid_t file_id = -1; - hid_t dset_id = -1; - hid_t space_id = -1; - hid_t core_fapl_id = -1; - hid_t core_file_id = -1; - herr_t err; - hsize_t dims[2]; - ssize_t bytes_read; - ssize_t image_size; - ssize_t file_size; + char file_name[1024] = "\0"; + void * insertion_ptr = NULL; + void * image_ptr = NULL; + void * file_image_ptr = NULL; + hbool_t is_family_file = FALSE; + hbool_t identical; + int data[100]; + int i; + int fd = -1; + int result; + hid_t driver = -1; + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t space_id = -1; + hid_t core_fapl_id = -1; + hid_t core_file_id = -1; + herr_t err; + hsize_t dims[2]; + ssize_t bytes_read; + ssize_t image_size; + ssize_t file_size; h5_stat_t stat_buf; - hid_t fcpl = -1; - herr_t ret; + hid_t fcpl = -1; + herr_t ret; TESTING(test_banner); @@ -716,18 +741,18 @@ test_get_file_image(const char * test_banner, driver = H5Pget_driver(fapl); VERIFY(driver >= 0, "H5Pget_driver(fapl) failed"); - if(driver == H5FD_FAMILY) + if (driver == H5FD_FAMILY) is_family_file = TRUE; /* setup the file name */ h5_fixname(FILENAME2[file_name_num], fapl, file_name, sizeof(file_name)); - VERIFY(HDstrlen(file_name)>0, "h5_fixname failed"); + VERIFY(HDstrlen(file_name) > 0, "h5_fixname failed"); fcpl = H5Pcreate(H5P_FILE_CREATE); VERIFY(fcpl >= 0, "H5Pcreate"); - if(user) { + if (user) { ret = H5Pset_userblock(fcpl, (hsize_t)USERBLOCK_SIZE); - VERIFY(ret >=0, "H5Pset_userblock"); + VERIFY(ret >= 0, "H5Pset_userblock"); } /* create the file */ @@ -735,15 +760,14 @@ test_get_file_image(const char * test_banner, VERIFY(file_id >= 0, "H5Fcreate() failed."); /* Set up data space for new new data set */ - dims[0] = 10; - dims[1] = 10; + dims[0] = 10; + dims[1] = 10; space_id = H5Screate_simple(2, dims, dims); VERIFY(space_id >= 0, "H5Screate() failed"); /* Create a dataset */ - dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset_id >=0, "H5Dcreate() failed"); + dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VERIFY(dset_id >= 0, "H5Dcreate() failed"); /* write some data to the data set */ for (i = 0; i < 100; i++) @@ -777,17 +801,17 @@ test_get_file_image(const char * test_banner, err = H5Fclose(file_id); VERIFY(err == SUCCEED, "H5Fclose(file_id) failed."); - if(is_family_file) { - char member_file_name[1024]; + if (is_family_file) { + char member_file_name[1024]; ssize_t bytes_to_read; ssize_t member_size; ssize_t size_remaining; - /* + /* * Modifications need to be made to accommodate userblock when * H5Fget_file_image() works for family driver */ - i = 0; + i = 0; file_size = 0; do { @@ -801,7 +825,7 @@ test_get_file_image(const char * test_banner, i++; file_size += member_size; - } while(member_size > 0); + } while (member_size > 0); /* Since we use the eoa to calculate the image size, the file size * may be larger. This is OK, as long as (in this specialized instance) @@ -814,10 +838,10 @@ test_get_file_image(const char * test_banner, VERIFY(file_image_ptr != NULL, "HDmalloc(2f) failed."); size_remaining = image_size; - insertion_ptr = file_image_ptr; - i = 0; + insertion_ptr = file_image_ptr; + i = 0; - while(size_remaining > 0) { + while (size_remaining > 0) { /* construct the member file name */ HDsnprintf(member_file_name, 1024, file_name, i); @@ -825,11 +849,12 @@ test_get_file_image(const char * test_banner, fd = HDopen(member_file_name, O_RDONLY); VERIFY(fd >= 0, "HDopen() failed."); - if(size_remaining >= FAMILY_SIZE ){ - bytes_to_read = FAMILY_SIZE; + if (size_remaining >= FAMILY_SIZE) { + bytes_to_read = FAMILY_SIZE; size_remaining -= FAMILY_SIZE; - } else { - bytes_to_read = size_remaining; + } + else { + bytes_to_read = size_remaining; size_remaining = 0; } @@ -845,7 +870,8 @@ test_get_file_image(const char * test_banner, result = HDclose(fd); VERIFY(result == 0, "HDclose() failed."); } - } else { + } + else { /* get the size of the test file */ result = HDstat(file_name, &stat_buf); VERIFY(result == 0, "HDstat() failed."); @@ -855,12 +881,12 @@ test_get_file_image(const char * test_banner, * the remainder of the file is all '\0's. */ file_size = (ssize_t)stat_buf.st_size; - if(user) { + if (user) { VERIFY(file_size > USERBLOCK_SIZE, "file size !> userblock size."); file_size -= USERBLOCK_SIZE; } - /* with latest mods to truncate call in core file drive, + /* with latest mods to truncate call in core file drive, * file size should match image size */ VERIFY(file_size == image_size, "file size != image size."); @@ -873,7 +899,7 @@ test_get_file_image(const char * test_banner, fd = HDopen(file_name, O_RDONLY); VERIFY(fd >= 0, "HDopen() failed."); - if(user) { + if (user) { HDoff_t off; /* Position at userblock */ @@ -892,20 +918,19 @@ test_get_file_image(const char * test_banner, /* verify that the file and the image contain the same data */ identical = TRUE; - i = 0; - while((i < (int)image_size) && identical) { - if(((char *)image_ptr)[i] != ((char *)file_image_ptr)[i]) + i = 0; + while ((i < (int)image_size) && identical) { + if (((char *)image_ptr)[i] != ((char *)file_image_ptr)[i]) identical = FALSE; i++; } VERIFY(identical, "file and image differ."); - /* finally, verify that we can use the core file driver to open the image */ /* create fapl for core file driver */ core_fapl_id = H5Pcreate(H5P_FILE_ACCESS); - VERIFY(core_fapl_id >=0, "H5Pcreate() failed"); + VERIFY(core_fapl_id >= 0, "H5Pcreate() failed"); /* setup core_fapl_id to use the core file driver */ err = H5Pset_fapl_core(core_fapl_id, (size_t)(64 * 1024), FALSE); @@ -931,11 +956,11 @@ test_get_file_image(const char * test_banner, h5_clean_files(FILENAME2, fapl); /* discard the image buffer if it exists */ - if(image_ptr != NULL) + if (image_ptr != NULL) HDfree(image_ptr); /* discard the image buffer if it exists */ - if(file_image_ptr != NULL) + if (file_image_ptr != NULL) HDfree(file_image_ptr); PASSED(); @@ -947,7 +972,6 @@ error: } /* end test_get_file_image() */ H5_GCC_DIAG_ON("format-nonliteral") - /****************************************************************************** * Function: test_get_file_image_error_rejection * @@ -964,24 +988,23 @@ H5_GCC_DIAG_ON("format-nonliteral") static int test_get_file_image_error_rejection(void) { - const char *memb_name[H5FD_MEM_NTYPES]; - char file_name[1024] = "\0"; - void * image_ptr = NULL; - int data[100]; - int i; - hid_t fapl_id = -1; - hid_t file_id = -1; - hid_t dset_id = -1; - hid_t space_id = -1; - herr_t err; - hsize_t dims[2]; - ssize_t bytes_read; - ssize_t image_size; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - + const char *memb_name[H5FD_MEM_NTYPES]; + char file_name[1024] = "\0"; + void * image_ptr = NULL; + int data[100]; + int i; + hid_t fapl_id = -1; + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t space_id = -1; + herr_t err; + hsize_t dims[2]; + ssize_t bytes_read; + ssize_t image_size; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + H5FD_mem_t mt; + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; TESTING("H5Fget_file_image() error rejection"); @@ -997,7 +1020,6 @@ test_get_file_image_error_rejection(void) * good id, but not a file id */ - /* setup fapl -- driver type doesn't matter much, so make it stdio */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); VERIFY(fapl_id >= 0, "H5Pcreate(1) failed"); @@ -1007,28 +1029,26 @@ test_get_file_image_error_rejection(void) /* setup the file name */ h5_fixname(FILENAME2[6], fapl_id, file_name, sizeof(file_name)); - VERIFY(HDstrlen(file_name)>0, "h5_fixname failed"); + VERIFY(HDstrlen(file_name) > 0, "h5_fixname failed"); /* create the file */ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id); VERIFY(file_id >= 0, "H5Fcreate() failed."); /* Set up data space for new new data set */ - dims[0] = 10; - dims[1] = 10; + dims[0] = 10; + dims[1] = 10; space_id = H5Screate_simple(2, dims, dims); VERIFY(space_id >= 0, "H5Screate() failed"); /* Create a dataset */ - dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset_id >=0, "H5Dcreate() failed"); + dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VERIFY(dset_id >= 0, "H5Dcreate() failed"); /* write some data to the data set */ for (i = 0; i < 100; i++) data[i] = i; - err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)data); + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)data); VERIFY(err >= 0, "H5Dwrite() failed."); /* Flush the file */ @@ -1044,25 +1064,22 @@ test_get_file_image_error_rejection(void) VERIFY(image_ptr != NULL, "HDmalloc(1) failed."); /* load the image of the file into the buffer */ - H5E_BEGIN_TRY { - bytes_read = H5Fget_file_image(file_id, image_ptr, (size_t)(image_size - 1)); - } H5E_END_TRY; + H5E_BEGIN_TRY { bytes_read = H5Fget_file_image(file_id, image_ptr, (size_t)(image_size - 1)); } + H5E_END_TRY; VERIFY(bytes_read < 0, "H5Fget_file_image(2 -- test 1) succeeded."); /* Call H5Fget_file_image() with good buffer and buffer size, * but non-existant file_id. Should fail. */ - H5E_BEGIN_TRY { - bytes_read = H5Fget_file_image((hid_t)0, image_ptr, (size_t)(image_size)); - } H5E_END_TRY; + H5E_BEGIN_TRY { bytes_read = H5Fget_file_image((hid_t)0, image_ptr, (size_t)(image_size)); } + H5E_END_TRY; VERIFY(bytes_read < 0, "H5Fget_file_image(3 -- test 1) succeeded."); /* Call H5Fget_file_image() with good buffer and buffer size, * but a file_id of the wrong type. Should fail. */ - H5E_BEGIN_TRY { - bytes_read = H5Fget_file_image(dset_id, image_ptr, (size_t)(image_size)); - } H5E_END_TRY; + H5E_BEGIN_TRY { bytes_read = H5Fget_file_image(dset_id, image_ptr, (size_t)(image_size)); } + H5E_END_TRY; VERIFY(bytes_read < 0, "H5Fget_file_image(4 -- test 1) succeeded."); /* Close dset and space */ @@ -1079,7 +1096,7 @@ test_get_file_image_error_rejection(void) h5_clean_files(FILENAME2, fapl_id); /* discard the image buffer if it exists */ - if(image_ptr != NULL) + if (image_ptr != NULL) HDfree(image_ptr); /************************** Test #2 **********************************/ @@ -1088,7 +1105,7 @@ test_get_file_image_error_rejection(void) */ /* setup parameters for multi file driver */ - for(mt = (H5FD_mem_t)0; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + for (mt = (H5FD_mem_t)0; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { memb_addr[mt] = HADDR_UNDEF; memb_fapl[mt] = H5P_DEFAULT; memb_map[mt] = H5FD_MEM_DRAW; @@ -1105,10 +1122,10 @@ test_get_file_image_error_rejection(void) memb_name[H5FD_MEM_BTREE] = "%s-b.h5"; memb_addr[H5FD_MEM_BTREE] = memb_addr[H5FD_MEM_SUPER] + TYPE_SLICE; - memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; - memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT; - memb_name[H5FD_MEM_DRAW] = "%s-r.h5"; - memb_addr[H5FD_MEM_DRAW] = memb_addr[H5FD_MEM_BTREE] + TYPE_SLICE; + memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; + memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT; + memb_name[H5FD_MEM_DRAW] = "%s-r.h5"; + memb_addr[H5FD_MEM_DRAW] = memb_addr[H5FD_MEM_BTREE] + TYPE_SLICE; memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; memb_fapl[H5FD_MEM_GHEAP] = H5P_DEFAULT; @@ -1120,44 +1137,41 @@ test_get_file_image_error_rejection(void) memb_name[H5FD_MEM_LHEAP] = "%s-l.h5"; memb_addr[H5FD_MEM_LHEAP] = memb_addr[H5FD_MEM_GHEAP] + TYPE_SLICE; - memb_map[H5FD_MEM_OHDR] = H5FD_MEM_OHDR; - memb_fapl[H5FD_MEM_OHDR] = H5P_DEFAULT; - memb_name[H5FD_MEM_OHDR] = "%s-o.h5"; - memb_addr[H5FD_MEM_OHDR] = memb_addr[H5FD_MEM_LHEAP] + TYPE_SLICE; + memb_map[H5FD_MEM_OHDR] = H5FD_MEM_OHDR; + memb_fapl[H5FD_MEM_OHDR] = H5P_DEFAULT; + memb_name[H5FD_MEM_OHDR] = "%s-o.h5"; + memb_addr[H5FD_MEM_OHDR] = memb_addr[H5FD_MEM_LHEAP] + TYPE_SLICE; /* setup fapl */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); VERIFY(fapl_id >= 0, "H5Pcreate(2) failed"); /* setup the fapl for the multi file driver */ - err = H5Pset_fapl_multi(fapl_id, memb_map, memb_fapl, memb_name, - memb_addr, FALSE); + err = H5Pset_fapl_multi(fapl_id, memb_map, memb_fapl, memb_name, memb_addr, FALSE); VERIFY(err >= 0, "H5Pset_fapl_multi failed"); /* setup the file name */ h5_fixname(FILENAME2[4], fapl_id, file_name, sizeof(file_name)); - VERIFY(HDstrlen(file_name)>0, "h5_fixname failed"); + VERIFY(HDstrlen(file_name) > 0, "h5_fixname failed"); /* create the file */ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id); VERIFY(file_id >= 0, "H5Fcreate() failed."); /* Set up data space for new new data set */ - dims[0] = 10; - dims[1] = 10; + dims[0] = 10; + dims[1] = 10; space_id = H5Screate_simple(2, dims, dims); VERIFY(space_id >= 0, "H5Screate() failed"); /* Create a dataset */ - dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset_id >=0, "H5Dcreate() failed"); + dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VERIFY(dset_id >= 0, "H5Dcreate() failed"); /* write some data to the data set */ for (i = 0; i < 100; i++) data[i] = i; - err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)data); + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)data); VERIFY(err >= 0, "H5Dwrite() failed."); /* Flush the file */ @@ -1165,9 +1179,8 @@ test_get_file_image_error_rejection(void) VERIFY(err >= 0, "H5Fflush failed"); /* attempt to get the size of the file -- should fail */ - H5E_BEGIN_TRY { - image_size = H5Fget_file_image(file_id, NULL, (size_t)0); - } H5E_END_TRY; + H5E_BEGIN_TRY { image_size = H5Fget_file_image(file_id, NULL, (size_t)0); } + H5E_END_TRY; VERIFY(image_size == -1, "H5Fget_file_image(5) succeeded."); /* Close dset and space */ @@ -1198,28 +1211,26 @@ test_get_file_image_error_rejection(void) /* setup the file name */ h5_fixname(FILENAME2[5], fapl_id, file_name, sizeof(file_name)); - VERIFY(HDstrlen(file_name)>0, "h5_fixname failed"); + VERIFY(HDstrlen(file_name) > 0, "h5_fixname failed"); /* create the file */ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id); VERIFY(file_id >= 0, "H5Fcreate() failed."); /* Set up data space for new new data set */ - dims[0] = 10; - dims[1] = 10; + dims[0] = 10; + dims[1] = 10; space_id = H5Screate_simple(2, dims, dims); VERIFY(space_id >= 0, "H5Screate() failed"); /* Create a dataset */ - dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset_id >=0, "H5Dcreate() failed"); + dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VERIFY(dset_id >= 0, "H5Dcreate() failed"); /* write some data to the data set */ for (i = 0; i < 100; i++) data[i] = i; - err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)data); + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)data); VERIFY(err >= 0, "H5Dwrite() failed."); /* Flush the file */ @@ -1227,9 +1238,8 @@ test_get_file_image_error_rejection(void) VERIFY(err >= 0, "H5Fflush failed"); /* attempt to get the size of the file -- should fail */ - H5E_BEGIN_TRY { - image_size = H5Fget_file_image(file_id, NULL, (size_t)0); - } H5E_END_TRY; + H5E_BEGIN_TRY { image_size = H5Fget_file_image(file_id, NULL, (size_t)0); } + H5E_END_TRY; VERIFY(image_size == -1, "H5Fget_file_image(6) succeeded."); /* Close dset and space */ @@ -1258,28 +1268,26 @@ test_get_file_image_error_rejection(void) VERIFY(err >= 0, "H5Pset_fapl_family failed"); h5_fixname(FILENAME2[3], fapl_id, file_name, sizeof(file_name)); - VERIFY(HDstrlen(file_name)>0, "h5_fixname failed"); + VERIFY(HDstrlen(file_name) > 0, "h5_fixname failed"); /* create the file */ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id); VERIFY(file_id >= 0, "H5Fcreate() failed."); /* Set up data space for new new data set */ - dims[0] = 10; - dims[1] = 10; + dims[0] = 10; + dims[1] = 10; space_id = H5Screate_simple(2, dims, dims); VERIFY(space_id >= 0, "H5Screate() failed"); /* Create a dataset */ - dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset_id >=0, "H5Dcreate() failed"); + dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VERIFY(dset_id >= 0, "H5Dcreate() failed"); /* write some data to the data set */ for (i = 0; i < 100; i++) data[i] = i; - err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)data); + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)data); VERIFY(err >= 0, "H5Dwrite() failed."); /* Flush the file */ @@ -1287,9 +1295,8 @@ test_get_file_image_error_rejection(void) VERIFY(err >= 0, "H5Fflush failed"); /* attempt to get the size of the file -- should fail */ - H5E_BEGIN_TRY { - image_size = H5Fget_file_image(file_id, NULL, (size_t)0); - } H5E_END_TRY; + H5E_BEGIN_TRY { image_size = H5Fget_file_image(file_id, NULL, (size_t)0); } + H5E_END_TRY; VERIFY(image_size == -1, "H5Fget_file_image(7) succeeded."); /* Close dset and space */ @@ -1320,8 +1327,8 @@ error: int main(void) { - int errors = 0; - hid_t fapl; + int errors = 0; + hid_t fapl; unsigned user; h5_reset(); @@ -1333,33 +1340,30 @@ main(void) errors += test_core(); /* Perform tests with/without user block */ - for(user = FALSE; user <= TRUE; user++) { - - /* test H5Fget_file_image() with sec2 driver */ - fapl = H5Pcreate(H5P_FILE_ACCESS); - if(H5Pset_fapl_sec2(fapl) < 0) - errors++; - else - errors += test_get_file_image("H5Fget_file_image() with sec2 driver", - 0, fapl, user); - - /* test H5Fget_file_image() with stdio driver */ - fapl = H5Pcreate(H5P_FILE_ACCESS); - if(H5Pset_fapl_stdio(fapl) < 0) - errors++; - else - errors += test_get_file_image("H5Fget_file_image() with stdio driver", - 1, fapl, user); - - /* test H5Fget_file_image() with core driver */ - fapl = H5Pcreate(H5P_FILE_ACCESS); - if(H5Pset_fapl_core(fapl, (size_t)(64 *1024), TRUE) < 0) - errors++; - else - errors += test_get_file_image("H5Fget_file_image() with core driver", - 2, fapl, user); - - } /* end for */ + for (user = FALSE; user <= TRUE; user++) { + + /* test H5Fget_file_image() with sec2 driver */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_sec2(fapl) < 0) + errors++; + else + errors += test_get_file_image("H5Fget_file_image() with sec2 driver", 0, fapl, user); + + /* test H5Fget_file_image() with stdio driver */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_stdio(fapl) < 0) + errors++; + else + errors += test_get_file_image("H5Fget_file_image() with stdio driver", 1, fapl, user); + + /* test H5Fget_file_image() with core driver */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_core(fapl, (size_t)(64 * 1024), TRUE) < 0) + errors++; + else + errors += test_get_file_image("H5Fget_file_image() with core driver", 2, fapl, user); + + } /* end for */ #if 0 /* at present, H5Fget_file_image() rejects files opened with the @@ -1386,13 +1390,11 @@ main(void) /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); - if(errors) { - HDprintf("***** %d File Image TEST%s FAILED! *****\n", - errors, errors > 1 ? "S" : ""); + if (errors) { + HDprintf("***** %d File Image TEST%s FAILED! *****\n", errors, errors > 1 ? "S" : ""); return 1; } HDprintf("All File Image tests passed.\n"); return 0; } - |