summaryrefslogtreecommitdiffstats
path: root/test/mf.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2016-08-09 21:36:01 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2016-08-09 21:36:01 (GMT)
commit7ee176d29bf33f11139b757d8555645cdf314335 (patch)
tree9e00b47452414aaec5d46b8293944926a5513ffb /test/mf.c
parentb3017997a8044daf273bf2e8084cc172e666830e (diff)
downloadhdf5-7ee176d29bf33f11139b757d8555645cdf314335.zip
hdf5-7ee176d29bf33f11139b757d8555645cdf314335.tar.gz
hdf5-7ee176d29bf33f11139b757d8555645cdf314335.tar.bz2
[svn-r30275] Rework test_mf_bug1 to work with multi and split drivers.
Tested: ummon
Diffstat (limited to 'test/mf.c')
-rw-r--r--test/mf.c172
1 files changed, 106 insertions, 66 deletions
diff --git a/test/mf.c b/test/mf.c
index 98231b9..e3d1845 100644
--- a/test/mf.c
+++ b/test/mf.c
@@ -5999,109 +5999,149 @@ error:
* endpoint is extended to allocate an aligned object
*/
static unsigned
-test_mf_bug1(hid_t fapl)
+test_mf_bug1(const char *env_h5_drvr, hid_t fapl)
{
hid_t file = -1; /* File ID */
hid_t copied_fapl = -1; /* FAPL to use for this test */
char filename[FILENAME_LEN]; /* Filename to use */
H5F_t *f = NULL; /* Internal file object pointer */
- void *fd;
H5FD_mem_t type;
haddr_t addr1, addr2;
hsize_t block_size;
+ hsize_t align;
+ hbool_t split = FALSE, multi = FALSE;
TESTING("H5MF_alloc() bug 1");
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
- /* Create the file to work on */
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ /* Copy fapl */
+ if((copied_fapl = H5Pcopy(fapl)) < 0)
TEST_ERROR
- /* Get file's VFD handle */
- if(H5Fget_vfd_handle(file, fapl, &fd) < 0)
+ /* Get metadata block size */
+ if(H5Pget_meta_block_size(copied_fapl, &block_size) < 0)
TEST_ERROR
- /* Skip test when using VFDs that don't aggregate metadata */
- if(((H5FD_t *)fd)->feature_flags & H5FD_FEAT_AGGREGATE_METADATA) {
- /* Close file */
- if(H5Fclose(file) < 0)
- TEST_ERROR
+ /* Set alignment to equal block size / 2 */
+ align = block_size / 2;
+ if(H5Pset_alignment(copied_fapl, 0, align) < 0)
+ TEST_ERROR
- /* Copy fapl */
- if((copied_fapl = H5Pcopy(fapl)) < 0)
- TEST_ERROR
+ /* Check for split or multi driver */
+ if(!HDstrcmp(env_h5_drvr, "split"))
+ split = TRUE;
+ else if(!HDstrcmp(env_h5_drvr, "multi"))
+ multi = TRUE;
- /* Get metadata block size */
- if(H5Pget_meta_block_size(copied_fapl, &block_size) < 0)
- TEST_ERROR
+ /* Add alignment to member files for split/multi driver */
+ if(split || multi) {
+ hid_t memb_fapl;
- /* Set alignment to equal block size / 2 */
- if(H5Pset_alignment(copied_fapl, 0, block_size / 2) < 0)
+ /* Creat fapl */
+ if((memb_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
TEST_ERROR
- /* Reopen the file with alignment */
- if((file = H5Fopen(filename, H5F_ACC_RDWR, copied_fapl)) < 0)
+ /* Set alignment. Note that it is the block size of the parent FAPL that
+ * is important here. */
+ if(H5Pset_alignment(memb_fapl, 0, align) < 0)
TEST_ERROR
- /* Get a pointer to the internal file object */
- if(NULL == (f = (H5F_t *)H5I_object(file)))
+ if(split) {
+ /* Set split driver with new FAPLs */
+ if(H5Pset_fapl_split(copied_fapl, "-m.h5", memb_fapl, "-r.h5", memb_fapl) < 0)
+ TEST_ERROR
+ } /* end if */
+ else {
+ H5FD_mem_t memb_map[H5FD_MEM_NTYPES];
+ hid_t memb_fapl_arr[H5FD_MEM_NTYPES];
+ char *memb_name[H5FD_MEM_NTYPES];
+ haddr_t memb_addr[H5FD_MEM_NTYPES];
+ hbool_t relax;
+ H5FD_mem_t mt;
+
+ /* Get current multi settings */
+ HDmemset(memb_name, 0, sizeof memb_name);
+ if(H5Pget_fapl_multi(copied_fapl, memb_map, NULL, memb_name, memb_addr, &relax) < 0)
+ TEST_ERROR
+
+ /* Populate memb_fapl_arr, patch memb_addr so member file addresses
+ * are aligned */
+ for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) {
+ memb_fapl_arr[mt] = memb_fapl;
+ memb_addr[mt] = ((memb_addr[mt] + align - 1) / align) * align;
+ } /* end for */
+
+ /* Set multi driver with new FAPLs */
+ if(H5Pset_fapl_multi(copied_fapl, memb_map, memb_fapl_arr, (const char * const *)memb_name, memb_addr, relax) < 0)
+ TEST_ERROR
+
+ /* Free memb_name */
+ for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt))
+ free(memb_name[mt]);
+ } /* end else */
+
+ /* Close memb_fapl */
+ if(H5Pclose(memb_fapl) < 0)
TEST_ERROR
+ } /* end if */
- /* Allocate a block of size block_size / 2 from meta_aggr. This should
- * create an aggregator that extends to the end of the file, with
- * block_size / 2 bytes remaining, and the end of the file aligned */
- type = H5FD_MEM_SUPER;
- addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, block_size / 2);
+ /* Reopen the file with alignment */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, copied_fapl)) < 0)
+ TEST_ERROR
- /* Verify that the allocated block is aligned */
- if(addr1 % (block_size / 2)) TEST_ERROR
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ TEST_ERROR
- /* Allocate a block of size block_size / 2 from meta_aggr. This should
- * force the aggregator to extend to the end of the file, with 0 bytes
- * remaining, and the end of the file aligned */
- type = H5FD_MEM_SUPER;
- addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, block_size / 2);
+ /* Allocate a block of size align from meta_aggr. This should create an
+ * aggregator that extends to the end of the file, with
+ * block_size / 2 bytes remaining, and the end of the file aligned */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, align);
- /* Verify that the allocated block is aligned */
- if(addr2 % (block_size / 2)) TEST_ERROR
+ /* Verify that the allocated block is aligned */
+ if(addr1 % align) TEST_ERROR
- /* Verify that the allocated block is placed block_size / 2 after the
- * previous */
- if((addr2 - addr1) != (block_size / 2)) TEST_ERROR
+ /* Allocate a block of size align from meta_aggr. This should force the
+ * aggregator to extend to the end of the file, with 0 bytes remaining, and
+ * the end of the file aligned */
+ type = H5FD_MEM_SUPER;
+ addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, align);
- /* Allocate a block of size block_size + 1 from meta_aggr. This should
- * force the aggregator to extend to the end of the file, with 0 bytes
- * remaining, and the end of the file unaligned */
- type = H5FD_MEM_SUPER;
- addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, block_size + (hsize_t)1);
+ /* Verify that the allocated block is aligned */
+ if(addr2 % align) TEST_ERROR
- /* Verify that the allocated block is aligned */
- if(addr1 % (block_size / 2)) TEST_ERROR
+ /* Verify that the allocated block is placed align after the previous */
+ if((addr2 - addr1) != align) TEST_ERROR
- /* Verify that the allocated block is placed block_size / 2 after the
- * previous */
- if((addr1 - addr2) != (block_size / 2)) TEST_ERROR
+ /* Allocate a block of size block_size + 1 from meta_aggr. This should
+ * force the aggregator to extend to the end of the file, with 0 bytes
+ * remaining, and the end of the file unaligned */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, block_size + (hsize_t)1);
- /* Allocate a block of size 1. This should extend the aggregator from
- * the previous allocation, and align the new block */
- type = H5FD_MEM_SUPER;
- addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)1);
+ /* Verify that the allocated block is aligned */
+ if(addr1 % align) TEST_ERROR
- /* Verify that the allocated block is aligned */
- if(addr2 % (block_size / 2)) TEST_ERROR
+ /* Verify that the allocated block is placed block_size / 2 after the
+ * previous */
+ if((addr1 - addr2) != align) TEST_ERROR
- /* Verify that the allocated block is placed 3 * (block_size / 2) after
- * the previous */
- if((addr2 - addr1) != (3 * (block_size / 2))) TEST_ERROR
+ /* Allocate a block of size 1. This should extend the aggregator from
+ * the previous allocation, and align the new block */
+ type = H5FD_MEM_SUPER;
+ addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)1);
- PASSED()
- } /* end if */
- else {
- SKIPPED();
- puts(" Current VFD doesn't support mis-aligned fragments");
- } /* end else */
+ /* Verify that the allocated block is aligned */
+ if(addr2 % align) TEST_ERROR
+
+ /* Verify that the allocated block is placed 3 * (block_size / 2) after
+ * the previous */
+ if((addr2 - addr1) != (3 * align)) TEST_ERROR
+
+ PASSED()
/* Close file */
if(H5Fclose(file) < 0)
@@ -7659,7 +7699,7 @@ main(void)
nerrors += test_filespace_drivers(fapl);
/* tests for specific bugs */
- nerrors += test_mf_bug1(fapl);
+ nerrors += test_mf_bug1(env_h5_drvr, fapl);
if(H5Pclose(new_fapl) < 0)
FAIL_STACK_ERROR