From 0dd0ffd5c10d0af4b1e672eb105428eeb20e434d Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 15 Mar 2016 12:43:34 -0500 Subject: [svn-r29421] Fix for HDFFV-9516. Corrects a problem where H5Dget_access_plist() returns a dapl that does not contain all dapl fields. Tested on: 64-bit Ubuntu 15.10 w/ gcc 5.2.1 autotools serial --- src/H5Dint.c | 12 +++++ test/Makefile.am | 4 +- test/external.c | 117 +++++++++++++++++++++++++++++++++++++--- test/vds.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 277 insertions(+), 16 deletions(-) diff --git a/src/H5Dint.c b/src/H5Dint.c index 733ffe7..d91693d 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -3082,6 +3082,18 @@ H5D_get_access_plist(H5D_t *dset) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks") } /* end if */ + /* Set the VDS view option */ + if(H5P_set(new_plist, H5D_ACS_VDS_VIEW_NAME, &(dset->shared->layout.storage.u.virt.view)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VDS view") + + /* Set the VDS printf gap option */ + if(H5P_set(new_plist, H5D_ACS_VDS_PRINTF_GAP_NAME, &(dset->shared->layout.storage.u.virt.printf_gap)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VDS printf gap") + + /* Set the external file prefix option */ + if(H5P_set(new_plist, H5D_ACS_EFILE_PREFIX_NAME, &(dset->shared->extfile_prefix)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file prefix") + /* Set the return value */ ret_value = new_dapl_id; diff --git a/test/Makefile.am b/test/Makefile.am index c3761b7..afd84be 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -129,7 +129,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \ copy_dcpl_newfile.h5 extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \ sys_file1 tfile[1-7].h5 th5s[1-4].h5 lheap.h5 fheap.h5 ohdr.h5 \ - stab.h5 extern_[1-4].h5 extern_[1-4][rw].raw gheap[0-4].h5 \ + stab.h5 extern_[1-5].h5 extern_[1-4][rw].raw gheap[0-4].h5 \ dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \ big.data big[0-9][0-9][0-9][0-9][0-9].h5 \ stdio.h5 sec2.h5 dtypes[0-9].h5 dtypes1[0].h5 dt_arith[1-2].h5 tattr.h5 \ @@ -149,7 +149,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \ file_image_core_test.h5.copy unregister_filter_1.h5 unregister_filter_2.h5 \ - vds_virt.h5 vds_src_[0-1].h5 + vds_virt.h5 vds_dapl.h5 vds_src_[0-1].h5 # Sources for testhdf5 executable testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ diff --git a/test/external.c b/test/external.c index af38428..1865e71 100644 --- a/test/external.c +++ b/test/external.c @@ -27,6 +27,7 @@ const char *FILENAME[] = { "extern_3", "extern_4", "extern_dir/file_1", + "extern_5", NULL }; @@ -825,6 +826,7 @@ test_read_file_set(hid_t fapl) error: H5E_BEGIN_TRY { + H5Gclose(grp); H5Dclose(dset); H5Pclose(dcpl); H5Sclose(space); @@ -1407,13 +1409,110 @@ error: /*------------------------------------------------------------------------- - * Function: main + * Function: test_h5d_get_access_plist * - * Purpose: Runs external dataset tests. + * Purpose: Ensure that H5Dget_access_plist returns correct values. * - * Return: Success: exit(0) + * Return: Success: 0 + * Failure: 1 * - * Failure: exit(non-zero) + * Programmer: Dana Robinson + * March 2016 + * + *------------------------------------------------------------------------- + */ +static int +test_h5d_get_access_plist(hid_t fapl_id) +{ + hid_t fid = -1; /* file to write to */ + hid_t dcpl_id = -1; /* dataset creation properties */ + hid_t dapl_id = -1; /* dataset access properties */ + hid_t sid = -1; /* data space */ + hid_t did = -1; /* dataset */ + hsize_t dims = 0; /* dataset size */ + char *buffer = NULL; /* saved prefix name from dapl */ + char filename[1024]; /* file names */ + + TESTING("H5Dget_access_plist() returns correct prefix"); + + if(HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) + TEST_ERROR + + /* Reset the raw data files */ + if(reset_raw_data_files() < 0) + TEST_ERROR + + /* Create the file */ + h5_fixname(FILENAME[5], fapl_id, filename, sizeof(filename)); + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + FAIL_STACK_ERROR + + /* Create the dcpl and set external storage */ + if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if(H5Pset_external(dcpl_id, "extern_1r.raw", (off_t)0, (hsize_t)0) < 0) + FAIL_STACK_ERROR + + /* Create the dapl and set the prefix */ + if((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR + if(H5Pset_efile_prefix(dapl_id, "someprefix") < 0) + FAIL_STACK_ERROR + + /* Create the dataset */ + if((sid = H5Screate_simple(1, &dims, NULL)) < 0) + FAIL_STACK_ERROR + if((did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, dapl_id)) < 0) + FAIL_STACK_ERROR + + /* Close the dapl */ + if(H5Pclose(dapl_id) < 0) + FAIL_STACK_ERROR + dapl_id = -1; + + /* Get a data access property list from the dataset */ + if((dapl_id = H5Dget_access_plist(did)) < 0) + FAIL_STACK_ERROR + + /* Check the value for the external prefix */ + if((buffer = (char *)HDcalloc((size_t)64, sizeof(char))) == NULL) + TEST_ERROR + if(H5Pget_efile_prefix(dapl_id, buffer, (size_t)64) < 0) + FAIL_STACK_ERROR + if(HDstrcmp(buffer, "someprefix") != 0) + FAIL_PUTS_ERROR("external file prefix from dapl incorrect"); + + /* Close everything */ + HDfree(buffer); + if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + if(H5Dclose(did) < 0) FAIL_STACK_ERROR + if(H5Pclose(dcpl_id) < 0) FAIL_STACK_ERROR + if(H5Pclose(dapl_id) < 0) FAIL_STACK_ERROR + if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + + PASSED(); + return 0; + + error: + if(buffer) + HDfree(buffer); + H5E_BEGIN_TRY { + H5Dclose(did); + H5Pclose(dcpl_id); + H5Pclose(dapl_id); + H5Sclose(sid); + H5Fclose(fid); + } H5E_END_TRY; + return 1; +} /* end test_h5d_get_access_plist() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Runs external dataset tests. + * + * Return: EXIT_SUCCESS/EXIT_FAILURE * * Programmer: Robb Matzke * Tuesday, March 3, 1998 @@ -1443,17 +1542,21 @@ main(void) if(H5Pset_libver_bounds(fapl_id_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR + /* The file format doesn't matter for this test */ + nerrors += test_h5d_get_access_plist(fapl_id_new); + HDputs(""); + /* Test with old & new format groups */ for(latest_format = FALSE; latest_format <= TRUE; latest_format++) { hid_t current_fapl_id = -1; /* Set the fapl for different file formats */ if(latest_format) { - puts("\nTesting with the latest file format:"); + HDputs("\nTesting with the latest file format:"); current_fapl_id = fapl_id_new; } /* end if */ else { - puts("Testing with the default file format:"); + HDputs("Testing with the default file format:"); current_fapl_id = fapl_id_old; } /* end else */ @@ -1526,7 +1629,7 @@ error: H5Gclose(gid); } H5E_END_TRY; nerrors = MAX(1, nerrors); - printf ("%d TEST%s FAILED.\n", nerrors, 1==nerrors?"":"s"); + printf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s"); return EXIT_FAILURE; } /* end main() */ diff --git a/test/vds.c b/test/vds.c index eff01c1..1c3dcca 100644 --- a/test/vds.c +++ b/test/vds.c @@ -38,6 +38,7 @@ const char *FILENAME[] = { "vds_src_0", "vds_src_1", "vds%%_src", + "vds_dapl", NULL }; @@ -447,7 +448,7 @@ test_api_get_ex_dcpl(test_api_config_t config, hid_t fapl, hid_t dcpl, } /* end else */ /* Verify examination DCPL is equal to original DCPL. Do not compare the - * plist to itselt, and do not do the comparison if we reopened the file, + * plist to itself, and do not do the comparison if we reopened the file, * because in that case the extent of the source dset will not be corrent. */ if((*ex_dcpl != dcpl) && (config != TEST_API_REOPEN_FILE)) { @@ -11093,13 +11094,156 @@ error: /*------------------------------------------------------------------------- + * Function: test_dapl_values + * + * Purpose: Ensure that H5Dget_access_plist returns correct values. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Dana Robinson + * March 2016 + * + *------------------------------------------------------------------------- + */ +static int +test_dapl_values(hid_t fapl_id) +{ + hid_t fid = -1; /* file to write to */ + hid_t dcpl_id = -1; /* dataset creation properties */ + hid_t dapl_id1 = -1; /* dataset access properties */ + hid_t dapl_id2 = -1; /* dataset access properties */ + hid_t vds_sid = -1; /* vds data space */ + hid_t src_sid = -1; /* source data space */ + hid_t did1 = -1; /* dataset */ + hid_t did2 = -1; /* dataset */ + hsize_t start; /* hyperslab start */ + hsize_t stride; /* hyperslab count */ + hsize_t count; /* hyperslab count */ + hsize_t block; /* hyperslab count */ + hsize_t dims; /* dataset size */ + hsize_t max_dims; /* dataset max size */ + H5D_vds_view_t view; /* view from dapl */ + hsize_t gap_size; /* gap size from dapl */ + char filename[1024]; /* file names */ + + TESTING("H5Dget_access_plist() returns dapl w/ correct values"); + + /* Create the file */ + h5_fixname(FILENAME[5], fapl_id, filename, sizeof(filename)); + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + FAIL_STACK_ERROR + + /* Create the dcpl and set up VDS mapping */ + if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + /* source */ + dims = 42; + if((src_sid = H5Screate_simple(1, &dims, NULL)) < 0) + FAIL_STACK_ERROR + /* vds */ + dims = 0; + max_dims = H5S_UNLIMITED; + if((vds_sid = H5Screate_simple(1, &dims, &max_dims)) < 0) + FAIL_STACK_ERROR + start = 0; + stride = 42; + count = H5S_UNLIMITED; + block = 42; + if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, &start, &stride, &count, &block) < 0) + FAIL_STACK_ERROR + /* map */ + if(H5Pset_virtual(dcpl_id, vds_sid, "f-%b.h5", "/dset1", src_sid) < 0) + FAIL_STACK_ERROR + + /* Create the dapls and set values + * There are two of them. The reason for this is that the only way + * to set the printf gap is to use the default view and using the + * default isn't the best way to test setting and getting the view. + */ + /* dapl 1 */ + if((dapl_id1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR + if(H5Pset_virtual_view(dapl_id1, H5D_VDS_FIRST_MISSING) < 0) + FAIL_STACK_ERROR + /* dapl 2 */ + if((dapl_id2 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR + /* default but we set it explicitly to be sure */ + if(H5Pset_virtual_view(dapl_id2, H5D_VDS_LAST_AVAILABLE) < 0) + FAIL_STACK_ERROR + if(H5Pset_virtual_printf_gap(dapl_id2, 123) < 0) + FAIL_STACK_ERROR + + /* Create the datasets */ + if((did1 = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, vds_sid, H5P_DEFAULT, dcpl_id, dapl_id1)) < 0) + FAIL_STACK_ERROR + if((did2 = H5Dcreate2(fid, "dset2", H5T_NATIVE_INT, vds_sid, H5P_DEFAULT, dcpl_id, dapl_id2)) < 0) + FAIL_STACK_ERROR + + /* Close the dapls */ + if(H5Pclose(dapl_id1) < 0) + FAIL_STACK_ERROR + dapl_id1 = -1; + if(H5Pclose(dapl_id2) < 0) + FAIL_STACK_ERROR + dapl_id2 = -1; + + /* Get a data access property lists from the dataset */ + if((dapl_id1 = H5Dget_access_plist(did1)) < 0) + FAIL_STACK_ERROR + if((dapl_id2 = H5Dget_access_plist(did2)) < 0) + FAIL_STACK_ERROR + + /* Check the values from the dapls */ + /* dapl 1 */ + if(H5Pget_virtual_view(dapl_id1, &view) < 0) + FAIL_STACK_ERROR + if(H5D_VDS_FIRST_MISSING != view) + TEST_ERROR + /* dapl 2 */ + if(H5Pget_virtual_view(dapl_id2, &view) < 0) + FAIL_STACK_ERROR + if(H5D_VDS_LAST_AVAILABLE != view) + TEST_ERROR + if(H5Pget_virtual_printf_gap(dapl_id2, &gap_size) < 0) + FAIL_STACK_ERROR + if(gap_size != 123) + + /* Close everything */ + if(H5Sclose(vds_sid) < 0) FAIL_STACK_ERROR + if(H5Sclose(src_sid) < 0) FAIL_STACK_ERROR + if(H5Dclose(did1) < 0) FAIL_STACK_ERROR + if(H5Dclose(did2) < 0) FAIL_STACK_ERROR + if(H5Pclose(dapl_id1) < 0) FAIL_STACK_ERROR + if(H5Pclose(dapl_id2) < 0) FAIL_STACK_ERROR + if(H5Pclose(dcpl_id) < 0) FAIL_STACK_ERROR + if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Dclose(did1); + H5Dclose(did2); + H5Pclose(dapl_id1); + H5Pclose(dapl_id2); + H5Pclose(dcpl_id); + H5Sclose(vds_sid); + H5Sclose(src_sid); + H5Fclose(fid); + } H5E_END_TRY; + return 1; +} /* end test_dapl_values() */ + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests datasets with virtual layout * - * Return: Success: exit(0) - * - * Failure: exit(1) + * Return: EXIT_SUCCESS/EXIT_FAILURE * * Programmer: Neil Fortner * Tuesday, February 17, 2015 @@ -11119,7 +11263,7 @@ main(void) h5_reset(); fapl = h5_fileaccess(); - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); for(test_api_config = (int)TEST_API_BASIC; test_api_config < (int)TEST_API_NTESTS; test_api_config++) nerrors += test_api((test_api_config_t)test_api_config, fapl); @@ -11131,6 +11275,8 @@ main(void) nerrors += test_all(bit_config, fapl); } /* end for */ + nerrors += test_dapl_values(fapl); + /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); @@ -11139,12 +11285,12 @@ main(void) printf("All virtual dataset tests passed.\n"); h5_cleanup(FILENAME, fapl); - return 0; + return EXIT_SUCCESS; error: nerrors = MAX(1, nerrors); printf("***** %d VIRTUAL DATASET TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); - return 1; + return EXIT_FAILURE; } /* end main() */ -- cgit v0.12