diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/enc_dec_plist.c | 878 | ||||
-rw-r--r-- | test/gen_plist.c | 4 | ||||
-rw-r--r-- | test/th5s.c | 900 | ||||
-rw-r--r-- | test/trefer.c | 58 | ||||
-rw-r--r-- | test/vds.c | 84 |
5 files changed, 1440 insertions, 484 deletions
diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index 33d23dc..2c8f691 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -15,75 +15,139 @@ * Serial tests for encoding/decoding plists */ -#include "h5test.h" +#include "testhdf5.h" #include "H5ACprivate.h" #include "H5Pprivate.h" +#define SRC_FNAME "source_file.h5" +#define SRC_DSET "src_dset" + static int -test_encode_decode(hid_t orig_pl) +test_encode_decode(hid_t orig_pl, H5F_libver_t low, H5F_libver_t high, hbool_t support_virtual) { - hid_t pl = (-1); /* Decoded property list */ + hid_t pl = (-1); /* Decoded property list */ + hid_t fapl = -1; /* File access property list */ void *temp_buf = NULL; /* Pointer to encoding buffer */ size_t temp_size = 0; /* Size of encoding buffer */ + herr_t ret; /* Return value */ - /* first call to encode returns only the size of the buffer needed */ - if(H5Pencode(orig_pl, NULL, &temp_size) < 0) - STACK_ERROR + /* Create file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR - if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + /* Set library version bounds */ + if(H5Pset_libver_bounds(fapl, low, high) < 0) TEST_ERROR - if(H5Pencode(orig_pl, temp_buf, &temp_size) < 0) - STACK_ERROR + H5E_BEGIN_TRY { + ret = H5Pencode2(orig_pl, NULL, &temp_size, fapl); + } H5E_END_TRY; + + if(support_virtual && high < H5F_LIBVER_V110) + VERIFY(ret, FAIL, "H5Pencode2"); + else { + + VERIFY(ret, SUCCEED, "H5Pencode2"); + + /* Allocate the buffer for encoding */ + if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + TEST_ERROR + + /* Encode the property list to the buffer */ + if(H5Pencode2(orig_pl, temp_buf, &temp_size, fapl) < 0) + TEST_ERROR + + /* Decode the buffer */ + if((pl = H5Pdecode(temp_buf)) < 0) + STACK_ERROR + + /* Check if the original and the decoded property lists are equal */ + if(!H5Pequal(orig_pl, pl)) + PUTS_ERROR("encoding-decoding cycle failed\n") + + /* Close the decoded property list */ + if((H5Pclose(pl)) < 0) + TEST_ERROR + + /* Free the buffer */ + if(temp_buf) + HDfree(temp_buf); + +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* Test H5Pencode1() */ + + /* first call to encode returns only the size of the buffer needed */ + if(H5Pencode1(orig_pl, NULL, &temp_size) < 0) + STACK_ERROR + + if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + TEST_ERROR + + if(H5Pencode1(orig_pl, temp_buf, &temp_size) < 0) + STACK_ERROR - if((pl = H5Pdecode(temp_buf)) < 0) - STACK_ERROR + if((pl = H5Pdecode(temp_buf)) < 0) + STACK_ERROR - if(!H5Pequal(orig_pl, pl)) - PUTS_ERROR("encoding-decoding cycle failed\n") + if(!H5Pequal(orig_pl, pl)) + PUTS_ERROR("encoding-decoding cycle failed\n") - if((H5Pclose(pl)) < 0) - STACK_ERROR + if((H5Pclose(pl)) < 0) + STACK_ERROR - HDfree(temp_buf); + if(temp_buf) + HDfree(temp_buf); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + } + + if((H5Pclose(fapl)) < 0) + TEST_ERROR /* Success */ return(0); error: - if(pl > 0) - H5Pclose(pl); if(temp_buf) HDfree(temp_buf); + H5E_BEGIN_TRY { + H5Pclose(pl); + H5Pclose(fapl); + } H5E_END_TRY; + return(-1); } /* end test_encode_decode() */ int main(void) { - hid_t dcpl; /* dataset create prop. list */ - hid_t dapl; /* dataset access prop. list */ - hid_t dxpl; /* dataset xfer prop. list */ - hid_t gcpl; /* group create prop. list */ - hid_t ocpypl; /* object copy prop. list */ - hid_t ocpl; /* object create prop. list */ - hid_t lcpl; /* link create prop. list */ - hid_t lapl; /* link access prop. list */ - hid_t fapl; /* file access prop. list */ - hid_t fcpl; /* file create prop. list */ - hid_t strcpl; /* string create prop. list */ - hid_t acpl; /* attribute create prop. list */ - + hid_t dcpl; /* dataset create prop. list */ + hid_t dapl; /* dataset access prop. list */ + hid_t dxpl; /* dataset xfer prop. list */ + hid_t gcpl; /* group create prop. list */ + hid_t ocpypl; /* object copy prop. list */ + hid_t ocpl; /* object create prop. list */ + hid_t lcpl; /* link create prop. list */ + hid_t lapl; /* link access prop. list */ + hid_t fapl; /* file access prop. list */ + hid_t fcpl; /* file create prop. list */ + hid_t strcpl; /* string create prop. list */ + hid_t acpl; /* attribute create prop. list */ + hid_t srcspace = -1; /* Source dataspaces */ + hid_t vspace = -1; /* Virtual dset dataspaces */ + hsize_t dims[1] = {3}; /* Data space current size */ hsize_t chunk_size[2] = {16384, 4}; /* chunk size */ - double fill = 2.7f; /* Fill value */ - hsize_t max_size[1]; /* data space maximum size */ + double fill = 2.7f; /* Fill value */ + hsize_t max_size[1]; /* data space maximum size */ size_t nslots = 521 * 2; size_t nbytes = 1048576 * 10; double w0 = 0.5f; unsigned max_compact; unsigned min_dense; const char* c_to_f = "x+32"; + H5F_libver_t low, high; /* Low and high bounds */ + H5AC_cache_config_t my_cache_config = { H5AC__CURR_CACHE_CONFIG_VERSION, TRUE, @@ -115,467 +179,511 @@ main(void) 0.2f, (256 * 2048), H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + H5AC_cache_image_config_t my_cache_image_config = { - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, - TRUE, + H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, + TRUE, FALSE, - -1}; - - if(VERBOSE_MED) - printf("Encode/Decode DCPLs\n"); + -1 }; + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + char* low_string; /* The low bound string */ + char* high_string; /* The high bound string */ + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + /* Display testing info */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Testing ENCODE/DECODE with file version bounds: (%s, %s):", low_string, high_string); + HDputs(msg); + + + if(VERBOSE_MED) + printf("Encode/Decode DCPLs\n"); + + /******* ENCODE/DECODE DCPLS *****/ + TESTING("Default DCPL Encoding/Decoding"); + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(dcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default DCPL encoding/decoding failed\n") + + PASSED(); + + TESTING("DCPL Encoding/Decoding"); + + if((H5Pset_chunk(dcpl, 2, chunk_size)) < 0) + FAIL_STACK_ERROR + + if((H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE)) < 0) + FAIL_STACK_ERROR + + if((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0) + FAIL_STACK_ERROR + + if((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0) + FAIL_STACK_ERROR + + max_size[0] = 100; + if((H5Pset_external(dcpl, "ext1.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + if((H5Pset_external(dcpl, "ext2.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + if((H5Pset_external(dcpl, "ext3.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + if((H5Pset_external(dcpl, "ext4.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding property list */ + if(test_encode_decode(dcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") + + /* release resource */ + if((H5Pclose(dcpl)) < 0) + FAIL_STACK_ERROR + + PASSED(); + + /******* ENCODE/DECODE DCPLS *****/ + TESTING("DCPL Encoding/Decoding for virtual layout"); + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Set virtual layout */ + if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + TEST_ERROR + + /* Create source dataspace */ + if((srcspace = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR + + /* Create virtual dataspace */ + if((vspace = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR + + /* Add virtual layout mapping */ + if(H5Pset_virtual(dcpl, vspace, SRC_FNAME, SRC_DSET, srcspace) < 0) + TEST_ERROR + + if(test_encode_decode(dcpl, low, high, TRUE) < 0) + FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") + + /* release resource */ + if((H5Pclose(dcpl)) < 0) + FAIL_STACK_ERROR + + /******* ENCODE/DECODE DAPLS *****/ + TESTING("Default DAPL Encoding/Decoding"); + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(dapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default DAPL encoding/decoding failed\n") + + PASSED(); + + TESTING("DAPL Encoding/Decoding"); + + if((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding property list */ + if(test_encode_decode(dapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("DAPL encoding/decoding failed\n") + + /* release resource */ + if((H5Pclose(dapl)) < 0) + FAIL_STACK_ERROR - /******* ENCODE/DECODE DCPLS *****/ - TESTING("Default DCPL Encoding/Decoding"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR + PASSED(); - /* Test encoding & decoding default property list */ - if(test_encode_decode(dcpl) < 0) - FAIL_PUTS_ERROR("Default DCPL encoding/decoding failed\n") + /******* ENCODE/DECODE OCPLS *****/ + TESTING("Default OCPL Encoding/Decoding"); + if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(ocpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default OCPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("DCPL Encoding/Decoding"); + TESTING("OCPL Encoding/Decoding"); - if((H5Pset_chunk(dcpl, 2, chunk_size)) < 0) - FAIL_STACK_ERROR + if((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) + FAIL_STACK_ERROR - if((H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE)) < 0) - FAIL_STACK_ERROR + if((H5Pset_attr_phase_change (ocpl, 110, 105)) < 0) + FAIL_STACK_ERROR - if((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0) - FAIL_STACK_ERROR + if((H5Pset_filter (ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0) + FAIL_STACK_ERROR - if((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding property list */ + if(test_encode_decode(ocpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("OCPL encoding/decoding failed\n") - max_size[0] = 100; - if((H5Pset_external(dcpl, "ext1.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext2.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext3.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext4.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(ocpl)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(dcpl) < 0) - FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(dcpl)) < 0) - FAIL_STACK_ERROR + PASSED(); - PASSED(); + /******* ENCODE/DECODE DXPLS *****/ + TESTING("Default DXPL Encoding/Decoding"); + if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(dxpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default DXPL encoding/decoding failed\n") - /******* ENCODE/DECODE DAPLS *****/ - TESTING("Default DAPL Encoding/Decoding"); - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR + PASSED(); - /* Test encoding & decoding default property list */ - if(test_encode_decode(dapl) < 0) - FAIL_PUTS_ERROR("Default DAPL encoding/decoding failed\n") + TESTING("DXPL Encoding/Decoding"); - PASSED(); + if((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0) + FAIL_STACK_ERROR + if((H5Pset_hyper_vector_size(dxpl, 5)) < 0) + FAIL_STACK_ERROR - TESTING("DAPL Encoding/Decoding"); +#ifdef H5_HAVE_PARALLEL + if((H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_chunk_opt(dxpl, H5FD_MPIO_CHUNK_MULTI_IO)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl, 30)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_chunk_opt_num(dxpl, 40)) < 0) + FAIL_STACK_ERROR +#endif/* H5_HAVE_PARALLEL */ + if((H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)) < 0) + FAIL_STACK_ERROR + if((H5Pset_data_transform(dxpl, c_to_f)) < 0) + FAIL_STACK_ERROR - if((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding property list */ + if(test_encode_decode(dxpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("DXPL encoding/decoding failed\n") - /* Test encoding & decoding property list */ - if(test_encode_decode(dapl) < 0) - FAIL_PUTS_ERROR("DAPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(dapl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(dxpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); + /******* ENCODE/DECODE GCPLS *****/ + TESTING("Default GCPL Encoding/Decoding"); + if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(gcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default GCPL encoding/decoding failed\n") - /******* ENCODE/DECODE OCPLS *****/ - TESTING("Default OCPL Encoding/Decoding"); - if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) - FAIL_STACK_ERROR + PASSED(); - /* Test encoding & decoding default property list */ - if(test_encode_decode(ocpl) < 0) - FAIL_PUTS_ERROR("Default OCPL encoding/decoding failed\n") + TESTING("GCPL Encoding/Decoding"); - PASSED(); + if((H5Pset_local_heap_size_hint(gcpl, 256)) < 0) + FAIL_STACK_ERROR - TESTING("OCPL Encoding/Decoding"); + if((H5Pset_link_phase_change(gcpl, 2, 2)) < 0) + FAIL_STACK_ERROR - if((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) - FAIL_STACK_ERROR + /* Query the group creation properties */ + if((H5Pget_link_phase_change(gcpl, &max_compact, &min_dense)) < 0) + FAIL_STACK_ERROR - if((H5Pset_attr_phase_change (ocpl, 110, 105)) < 0) - FAIL_STACK_ERROR + if((H5Pset_est_link_info(gcpl, 3, 9)) < 0) + FAIL_STACK_ERROR - if((H5Pset_filter (ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0) - FAIL_STACK_ERROR + if((H5Pset_link_creation_order(gcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(ocpl) < 0) - FAIL_PUTS_ERROR("OCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(gcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("GCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(ocpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(gcpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); + /******* ENCODE/DECODE LCPLS *****/ + TESTING("Default LCPL Encoding/Decoding"); + if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) + FAIL_STACK_ERROR - /******* ENCODE/DECODE DXPLS *****/ - TESTING("Default DXPL Encoding/Decoding"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(lcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default LCPL encoding/decoding failed\n") - /* Test encoding & decoding default property list */ - if(test_encode_decode(dxpl) < 0) - FAIL_PUTS_ERROR("Default DXPL encoding/decoding failed\n") + PASSED(); - PASSED(); + TESTING("LCPL Encoding/Decoding"); - TESTING("DXPL Encoding/Decoding"); + if((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0) + FAIL_STACK_ERROR - if((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0) - FAIL_STACK_ERROR - if((H5Pset_hyper_vector_size(dxpl, 5)) < 0) - FAIL_STACK_ERROR -#ifdef H5_HAVE_PARALLEL - if((H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt(dxpl, H5FD_MPIO_CHUNK_MULTI_IO)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl, 30)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt_num(dxpl, 40)) < 0) - FAIL_STACK_ERROR -#endif/* H5_HAVE_PARALLEL */ - if((H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)) < 0) - FAIL_STACK_ERROR - if((H5Pset_data_transform(dxpl, c_to_f)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(dxpl) < 0) - FAIL_PUTS_ERROR("DXPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(lcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("LCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(dxpl)) < 0) - FAIL_STACK_ERROR - - PASSED(); + /* release resource */ + if((H5Pclose(lcpl)) < 0) + FAIL_STACK_ERROR + PASSED(); - /******* ENCODE/DECODE GCPLS *****/ - TESTING("Default GCPL Encoding/Decoding"); - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) - FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(gcpl) < 0) - FAIL_PUTS_ERROR("Default GCPL encoding/decoding failed\n") + /******* ENCODE/DECODE LAPLS *****/ + TESTING("Default LAPL Encoding/Decoding"); + if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) + FAIL_STACK_ERROR - PASSED(); + /* Test encoding & decoding default property list */ + if(test_encode_decode(lapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default LAPL encoding/decoding failed\n") - TESTING("GCPL Encoding/Decoding"); - - if((H5Pset_local_heap_size_hint(gcpl, 256)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_link_phase_change(gcpl, 2, 2)) < 0) - FAIL_STACK_ERROR - - /* Query the group creation properties */ - if((H5Pget_link_phase_change(gcpl, &max_compact, &min_dense)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_est_link_info(gcpl, 3, 9)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_link_creation_order(gcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(gcpl) < 0) - FAIL_PUTS_ERROR("GCPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(gcpl)) < 0) - FAIL_STACK_ERROR + PASSED(); - PASSED(); + TESTING("LAPL Encoding/Decoding"); + if((H5Pset_nlinks(lapl, (size_t)134)) < 0) + FAIL_STACK_ERROR - /******* ENCODE/DECODE LCPLS *****/ - TESTING("Default LCPL Encoding/Decoding"); - if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) - FAIL_STACK_ERROR + if((H5Pset_elink_acc_flags(lapl, H5F_ACC_RDONLY)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(lcpl) < 0) - FAIL_PUTS_ERROR("Default LCPL encoding/decoding failed\n") + if((H5Pset_elink_prefix(lapl, "/tmpasodiasod")) < 0) + FAIL_STACK_ERROR - PASSED(); + /* Create FAPL for the elink FAPL */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR + if((H5Pset_alignment(fapl, 2, 1024)) < 0) + FAIL_STACK_ERROR - TESTING("LCPL Encoding/Decoding"); + if((H5Pset_elink_fapl(lapl, fapl)) < 0) + FAIL_STACK_ERROR - if((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0) - FAIL_STACK_ERROR + /* Close the elink's FAPL */ + if((H5Pclose(fapl)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(lcpl) < 0) - FAIL_PUTS_ERROR("LCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(lapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("LAPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(lcpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(lapl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE LAPLS *****/ - TESTING("Default LAPL Encoding/Decoding"); - if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) - FAIL_STACK_ERROR + /******* ENCODE/DECODE OCPYPLS *****/ + TESTING("Default OCPYPL Encoding/Decoding"); + if((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(lapl) < 0) - FAIL_PUTS_ERROR("Default LAPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(ocpypl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default OCPYPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("LAPL Encoding/Decoding"); + TESTING("OCPYPL Encoding/Decoding"); - if((H5Pset_nlinks(lapl, (size_t)134)) < 0) - FAIL_STACK_ERROR + if((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0) + FAIL_STACK_ERROR - if((H5Pset_elink_acc_flags(lapl, H5F_ACC_RDONLY)) < 0) - FAIL_STACK_ERROR + if((H5Padd_merge_committed_dtype_path(ocpypl, "foo")) < 0) + FAIL_STACK_ERROR + if((H5Padd_merge_committed_dtype_path(ocpypl, "bar")) < 0) + FAIL_STACK_ERROR - if((H5Pset_elink_prefix(lapl, "/tmpasodiasod")) < 0) - FAIL_STACK_ERROR - - /* Create FAPL for the elink FAPL */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - FAIL_STACK_ERROR - if((H5Pset_alignment(fapl, 2, 1024)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_elink_fapl(lapl, fapl)) < 0) - FAIL_STACK_ERROR - - /* Close the elink's FAPL */ - if((H5Pclose(fapl)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(lapl) < 0) - FAIL_PUTS_ERROR("LAPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(ocpypl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("OCPYPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(lapl)) < 0) - FAIL_STACK_ERROR - - PASSED(); + /* release resource */ + if((H5Pclose(ocpypl)) < 0) + FAIL_STACK_ERROR + PASSED(); - /******* ENCODE/DECODE OCPYPLS *****/ - TESTING("Default OCPYPL Encoding/Decoding"); - if((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0) - FAIL_STACK_ERROR + /******* ENCODE/DECODE FAPLS *****/ + TESTING("Default FAPL Encoding/Decoding"); + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(ocpypl) < 0) - FAIL_PUTS_ERROR("Default OCPYPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(fapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default FAPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("OCPYPL Encoding/Decoding"); + TESTING("FAPL Encoding/Decoding"); - if((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0) - FAIL_STACK_ERROR + if((H5Pset_family_offset(fapl, 1024)) < 0) + FAIL_STACK_ERROR + if((H5Pset_meta_block_size(fapl, 2098452)) < 0) + FAIL_STACK_ERROR + if((H5Pset_sieve_buf_size(fapl, 1048576)) < 0) + FAIL_STACK_ERROR + if((H5Pset_alignment(fapl, 2, 1024)) < 0) + FAIL_STACK_ERROR + if((H5Pset_cache(fapl, 1024, 128, 10485760, 0.3f)) < 0) + FAIL_STACK_ERROR + if((H5Pset_elink_file_cache_size(fapl, 10485760)) < 0) + FAIL_STACK_ERROR + if((H5Pset_gc_references(fapl, 1)) < 0) + FAIL_STACK_ERROR + if((H5Pset_small_data_block_size(fapl, 2048)) < 0) + FAIL_STACK_ERROR + if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) + FAIL_STACK_ERROR + if((H5Pset_fclose_degree(fapl, H5F_CLOSE_WEAK)) < 0) + FAIL_STACK_ERROR + if((H5Pset_multi_type(fapl, H5FD_MEM_GHEAP)) < 0) + FAIL_STACK_ERROR + if((H5Pset_mdc_config(fapl, &my_cache_config)) < 0) + FAIL_STACK_ERROR + if((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0) + FAIL_STACK_ERROR - if((H5Padd_merge_committed_dtype_path(ocpypl, "foo")) < 0) - FAIL_STACK_ERROR - if((H5Padd_merge_committed_dtype_path(ocpypl, "bar")) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding property list */ + if(test_encode_decode(fapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("FAPL encoding/decoding failed\n") - /* Test encoding & decoding property list */ - if(test_encode_decode(ocpypl) < 0) - FAIL_PUTS_ERROR("OCPYPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(ocpypl)) < 0) - FAIL_STACK_ERROR - - PASSED(); - - - /******* ENCODE/DECODE FAPLS *****/ - TESTING("Default FAPL Encoding/Decoding"); - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding default property list */ - if(test_encode_decode(fapl) < 0) - FAIL_PUTS_ERROR("Default FAPL encoding/decoding failed\n") - - PASSED(); - - TESTING("FAPL Encoding/Decoding"); - - if((H5Pset_family_offset(fapl, 1024)) < 0) - FAIL_STACK_ERROR - if((H5Pset_meta_block_size(fapl, 2098452)) < 0) - FAIL_STACK_ERROR - if((H5Pset_sieve_buf_size(fapl, 1048576)) < 0) - FAIL_STACK_ERROR - if((H5Pset_alignment(fapl, 2, 1024)) < 0) - FAIL_STACK_ERROR - if((H5Pset_cache(fapl, 1024, 128, 10485760, 0.3f)) < 0) - FAIL_STACK_ERROR - if((H5Pset_elink_file_cache_size(fapl, 10485760)) < 0) - FAIL_STACK_ERROR - if((H5Pset_gc_references(fapl, 1)) < 0) - FAIL_STACK_ERROR - if((H5Pset_small_data_block_size(fapl, 2048)) < 0) - FAIL_STACK_ERROR - if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) - FAIL_STACK_ERROR - if((H5Pset_fclose_degree(fapl, H5F_CLOSE_WEAK)) < 0) - FAIL_STACK_ERROR - if((H5Pset_multi_type(fapl, H5FD_MEM_GHEAP)) < 0) - FAIL_STACK_ERROR - if((H5Pset_mdc_config(fapl, &my_cache_config)) < 0) - FAIL_STACK_ERROR - if((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(fapl) < 0) - FAIL_PUTS_ERROR("FAPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(fapl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(fapl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE FCPLS *****/ - TESTING("Default FCPL Encoding/Decoding"); + /******* ENCODE/DECODE FCPLS *****/ + TESTING("Default FCPL Encoding/Decoding"); - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(fcpl) < 0) - FAIL_PUTS_ERROR("Default FCPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(fcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default FCPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("FCPL Encoding/Decoding"); + TESTING("FCPL Encoding/Decoding"); - if((H5Pset_userblock(fcpl, 1024) < 0)) - FAIL_STACK_ERROR + if((H5Pset_userblock(fcpl, 1024) < 0)) + FAIL_STACK_ERROR - if((H5Pset_istore_k(fcpl, 3) < 0)) - FAIL_STACK_ERROR + if((H5Pset_istore_k(fcpl, 3) < 0)) + FAIL_STACK_ERROR - if((H5Pset_sym_k(fcpl, 4, 5) < 0)) - FAIL_STACK_ERROR + if((H5Pset_sym_k(fcpl, 4, 5) < 0)) + FAIL_STACK_ERROR - if((H5Pset_shared_mesg_nindexes(fcpl, 8) < 0)) - FAIL_STACK_ERROR + if((H5Pset_shared_mesg_nindexes(fcpl, 8) < 0)) + FAIL_STACK_ERROR - if((H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0)) - FAIL_STACK_ERROR + if((H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0)) + FAIL_STACK_ERROR - if((H5Pset_shared_mesg_phase_change(fcpl, 60, 20) < 0)) - FAIL_STACK_ERROR + if((H5Pset_shared_mesg_phase_change(fcpl, 60, 20) < 0)) + FAIL_STACK_ERROR - if((H5Pset_sizes(fcpl, 8, 4) < 0)) - FAIL_STACK_ERROR + if((H5Pset_sizes(fcpl, 8, 4) < 0)) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(fcpl) < 0) - FAIL_PUTS_ERROR("FCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(fcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("FCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(fcpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(fcpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE STRCPLS *****/ - TESTING("Default STRCPL Encoding/Decoding"); + /******* ENCODE/DECODE STRCPLS *****/ + TESTING("Default STRCPL Encoding/Decoding"); - if((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0) - FAIL_STACK_ERROR + if((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(strcpl) < 0) - FAIL_PUTS_ERROR("Default STRCPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(strcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default STRCPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("STRCPL Encoding/Decoding"); + TESTING("STRCPL Encoding/Decoding"); - if((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0)) - FAIL_STACK_ERROR + if((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0)) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(strcpl) < 0) - FAIL_PUTS_ERROR("STRCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(strcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("STRCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(strcpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(strcpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE ACPLS *****/ - TESTING("Default ACPL Encoding/Decoding"); + /******* ENCODE/DECODE ACPLS *****/ + TESTING("Default ACPL Encoding/Decoding"); - if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) - FAIL_STACK_ERROR + if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(acpl) < 0) - FAIL_PUTS_ERROR("Default ACPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(acpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default ACPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("ACPL Encoding/Decoding"); + TESTING("ACPL Encoding/Decoding"); - if((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0)) - FAIL_STACK_ERROR + if((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0)) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(acpl) < 0) - FAIL_PUTS_ERROR("ACPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(acpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("ACPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(acpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(acpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); + } /* end high */ + } /* end low */ return 0; diff --git a/test/gen_plist.c b/test/gen_plist.c index 68da6cc..8f38b1a 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -466,13 +466,13 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil HDassert(ret > 0); /* first call to encode returns only the size of the buffer needed */ - if((ret = H5Pencode(plist_id, NULL, &temp_size)) < 0) + if((ret = H5Pencode2(plist_id, NULL, &temp_size, H5P_DEFAULT)) < 0) HDassert(ret > 0); temp_buf = (void *)HDmalloc(temp_size); HDassert(temp_buf); - if((ret = H5Pencode(plist_id, temp_buf, &temp_size)) < 0) + if((ret = H5Pencode2(plist_id, temp_buf, &temp_size, H5P_DEFAULT)) < 0) HDassert(ret > 0); fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); diff --git a/test/th5s.c b/test/th5s.c index 07d31ed..6632a4c 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -90,7 +90,21 @@ struct space4_struct { unsigned u; float f; char c2; - } space4_data={'v',987123,-3.14F,'g'}; /* Test data for 4th dataspace */ +} space4_data={'v',987123,-3.14F,'g'}; /* Test data for 4th dataspace */ + +/* + * Testing configuration defines used by: + * test_h5s_encode_regular_hyper() + * test_h5s_encode_irregular_hyper() + * test_h5s_encode_points() + */ +#define CONFIG_8 1 +#define CONFIG_16 2 +#define CONFIG_32 3 +#define POWER8 256 /* 2^8 */ +#define POWER16 65536 /* 2^16 */ +#define POWER32 4294967296 /* 2^32 */ + /**************************************************************** ** @@ -1163,27 +1177,30 @@ test_h5s_zero_dim(void) ** ** test_h5s_encode(): Test H5S (dataspace) encoding and decoding. ** +** Note: See "RFC: H5Sencode/H5Sdecode Format Change". +** ****************************************************************/ static void -test_h5s_encode(void) +test_h5s_encode(H5F_libver_t low, H5F_libver_t high) { - hid_t sid1, sid2, sid3; /* Dataspace ID */ - hid_t decoded_sid1, decoded_sid2, decoded_sid3; - int rank; /* Logical rank of dataspace */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - size_t sbuf_size=0, null_size=0, scalar_size=0; - unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL; - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - hsize_t start[] = {0, 0, 0}; - hsize_t stride[] = {2, 5, 3}; - hsize_t count[] = {2, 2, 2}; - hsize_t block[] = {1, 3, 1}; - H5S_sel_type sel_type; - H5S_class_t space_type; - hssize_t nblocks; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t sid1, sid2, sid3; /* Dataspace ID */ + hid_t decoded_sid1, decoded_sid2, decoded_sid3; + int rank; /* Logical rank of dataspace */ + hid_t fapl = -1; /* File access property list ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + size_t sbuf_size=0, null_size=0, scalar_size=0; + unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL; + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + hsize_t start[] = {0, 0, 0}; + hsize_t stride[] = {2, 5, 3}; + hsize_t count[] = {2, 2, 2}; + hsize_t block[] = {1, 3, 1}; + H5S_sel_type sel_type; + H5S_class_t space_type; + hssize_t nblocks; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace Encoding and Decoding\n")); @@ -1192,26 +1209,40 @@ test_h5s_encode(void) * Test encoding and decoding of simple dataspace and hyperslab selection. *------------------------------------------------------------------------- */ + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); + /* Set the hyperslab selection */ ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Encode simple data space in a buffer */ - ret = H5Sencode(sid1, NULL, &sbuf_size); - CHECK(ret, FAIL, "H5Sencode"); + /* Encode simple data space in a buffer with the fapl setting */ + ret = H5Sencode2(sid1, NULL, &sbuf_size, fapl); + CHECK(ret, FAIL, "H5Sencode2"); - if(sbuf_size>0) + if(sbuf_size>0) { sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size); + CHECK(sbuf, NULL, "HDcalloc"); + } /* Try decoding bogus buffer */ H5E_BEGIN_TRY { - ret_id = H5Sdecode(sbuf); + ret_id = H5Sdecode(sbuf); } H5E_END_TRY; VERIFY(ret_id, FAIL, "H5Sdecode"); - ret = H5Sencode(sid1, sbuf, &sbuf_size); + /* Encode the simple data space in a buffer with the fapl setting */ + ret = H5Sencode2(sid1, sbuf, &sbuf_size, fapl); CHECK(ret, FAIL, "H5Sencode"); /* Decode from the dataspace buffer and return an object handle */ @@ -1224,22 +1255,26 @@ test_h5s_encode(void) VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Sget_simple_extent_npoints"); + /* Retrieve and verify the dataspace rank */ rank = H5Sget_simple_extent_ndims(decoded_sid1); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims"); + /* Retrieve and verify the dataspace dimensions */ rank = H5Sget_simple_extent_dims(decoded_sid1, tdims, NULL); CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, "H5Sget_simple_extent_dims"); - /* Verify hyperslabe selection */ + /* Verify the type of dataspace selection */ sel_type = H5Sget_select_type(decoded_sid1); VERIFY(sel_type, H5S_SEL_HYPERSLABS, "H5Sget_select_type"); + /* Verify the number of hyperslab blocks */ nblocks = H5Sget_select_hyper_nblocks(decoded_sid1); VERIFY(nblocks, 2*2*2, "H5Sget_select_hyper_nblocks"); + /* Close the dataspaces */ ret = H5Sclose(sid1); CHECK(ret, FAIL, "H5Sclose"); @@ -1254,23 +1289,27 @@ test_h5s_encode(void) CHECK(sid2, FAIL, "H5Screate"); /* Encode null data space in a buffer */ - ret = H5Sencode(sid2, NULL, &null_size); + ret = H5Sencode2(sid2, NULL, &null_size, fapl); CHECK(ret, FAIL, "H5Sencode"); - if(null_size>0) + if(null_size>0) { null_sbuf = (unsigned char*)HDcalloc((size_t)1, null_size); + CHECK(null_sbuf, NULL, "HDcalloc"); + } - ret = H5Sencode(sid2, null_sbuf, &null_size); - CHECK(ret, FAIL, "H5Sencode"); + /* Encode the null data space in the buffer */ + ret = H5Sencode2(sid2, null_sbuf, &null_size, fapl); + CHECK(ret, FAIL, "H5Sencode2"); /* Decode from the dataspace buffer and return an object handle */ decoded_sid2=H5Sdecode(null_sbuf); CHECK(decoded_sid2, FAIL, "H5Sdecode"); - /* Verify decoded dataspace */ + /* Verify the decoded dataspace type */ space_type = H5Sget_simple_extent_type(decoded_sid2); VERIFY(space_type, H5S_NULL, "H5Sget_simple_extent_type"); + /* Close the dataspaces */ ret = H5Sclose(sid2); CHECK(ret, FAIL, "H5Sclose"); @@ -1286,16 +1325,211 @@ test_h5s_encode(void) CHECK(sid3, FAIL, "H5Screate_simple"); /* Encode scalar data space in a buffer */ - ret = H5Sencode(sid3, NULL, &scalar_size); + ret = H5Sencode2(sid3, NULL, &scalar_size, fapl); CHECK(ret, FAIL, "H5Sencode"); - if(scalar_size>0) + if(scalar_size>0) { scalar_buf = (unsigned char*)HDcalloc((size_t)1, scalar_size); + CHECK(scalar_buf, NULL, "HDcalloc"); + } + + /* Encode the scalar data space in the buffer */ + ret = H5Sencode2(sid3, scalar_buf, &scalar_size, fapl); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode from the dataspace buffer and return an object handle */ + decoded_sid3=H5Sdecode(scalar_buf); + CHECK(decoded_sid3, FAIL, "H5Sdecode"); + + /* Verify extent type */ + space_type = H5Sget_simple_extent_type(decoded_sid3); + VERIFY(space_type, H5S_SCALAR, "H5Sget_simple_extent_type"); + + /* Verify decoded dataspace */ + n = H5Sget_simple_extent_npoints(decoded_sid3); + CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); + VERIFY(n, 1, "H5Sget_simple_extent_npoints"); + + /* Retrieve and verify the dataspace rank */ + rank = H5Sget_simple_extent_ndims(decoded_sid3); + CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); + VERIFY(rank, 0, "H5Sget_simple_extent_ndims"); - ret = H5Sencode(sid3, scalar_buf, &scalar_size); + /* Close the dataspaces */ + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(decoded_sid3); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the file access property list */ + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Release resources */ + if(sbuf) + HDfree(sbuf); + if(null_sbuf) + HDfree(null_sbuf); + if(scalar_buf) + HDfree(scalar_buf); +} /* test_h5s_encode() */ + +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/**************************************************************** +** +** test_h5s_encode(): Test H5S (dataspace) encoding and decoding. +** +****************************************************************/ +static void +test_h5s_encode1(void) +{ + hid_t sid1, sid2, sid3; /* Dataspace ID */ + hid_t decoded_sid1, decoded_sid2, decoded_sid3; + int rank; /* Logical rank of dataspace */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + size_t sbuf_size=0, null_size=0, scalar_size=0; + unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL; + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + hsize_t start[] = {0, 0, 0}; + hsize_t stride[] = {2, 5, 3}; + hsize_t count[] = {2, 2, 2}; + hsize_t block[] = {1, 3, 1}; + H5S_sel_type sel_type; + H5S_class_t space_type; + hssize_t nblocks; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace Encoding (H5Sencode1) and Decoding\n")); + + /*------------------------------------------------------------------------- + * Test encoding and decoding of simple dataspace and hyperslab selection. + *------------------------------------------------------------------------- + */ + /* Create the dataspace */ + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + CHECK(sid1, FAIL, "H5Screate_simple"); + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Encode simple data space in a buffer with the fapl setting */ + ret = H5Sencode1(sid1, NULL, &sbuf_size); + CHECK(ret, FAIL, "H5Sencode2"); + + if(sbuf_size>0) { + sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size); + CHECK(sbuf, NULL, "HDcalloc"); + } + + /* Try decoding bogus buffer */ + H5E_BEGIN_TRY { + ret_id = H5Sdecode(sbuf); + } H5E_END_TRY; + VERIFY(ret_id, FAIL, "H5Sdecode"); + + /* Encode the simple data space in a buffer */ + ret = H5Sencode1(sid1, sbuf, &sbuf_size); CHECK(ret, FAIL, "H5Sencode"); /* Decode from the dataspace buffer and return an object handle */ + decoded_sid1=H5Sdecode(sbuf); + CHECK(decoded_sid1, FAIL, "H5Sdecode"); + + /* Verify the decoded dataspace */ + n = H5Sget_simple_extent_npoints(decoded_sid1); + CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); + VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, + "H5Sget_simple_extent_npoints"); + + /* Retrieve and verify the dataspace rank */ + rank = H5Sget_simple_extent_ndims(decoded_sid1); + CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); + VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims"); + + /* Retrieve and verify the dataspace dimensions */ + rank = H5Sget_simple_extent_dims(decoded_sid1, tdims, NULL); + CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, + "H5Sget_simple_extent_dims"); + + /* Verify the type of dataspace selection */ + sel_type = H5Sget_select_type(decoded_sid1); + VERIFY(sel_type, H5S_SEL_HYPERSLABS, "H5Sget_select_type"); + + /* Verify the number of hyperslab blocks */ + nblocks = H5Sget_select_hyper_nblocks(decoded_sid1); + VERIFY(nblocks, 2*2*2, "H5Sget_select_hyper_nblocks"); + + /* Close the dataspaces */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(decoded_sid1); + CHECK(ret, FAIL, "H5Sclose"); + + /*------------------------------------------------------------------------- + * Test encoding and decoding of null dataspace. + *------------------------------------------------------------------------- + */ + sid2 = H5Screate(H5S_NULL); + CHECK(sid2, FAIL, "H5Screate"); + + /* Encode null data space in a buffer */ + ret = H5Sencode1(sid2, NULL, &null_size); + CHECK(ret, FAIL, "H5Sencode"); + + if(null_size>0) { + null_sbuf = (unsigned char*)HDcalloc((size_t)1, null_size); + CHECK(null_sbuf, NULL, "HDcalloc"); + } + + /* Encode the null data space in the buffer */ + ret = H5Sencode1(sid2, null_sbuf, &null_size); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode from the dataspace buffer and return an object handle */ + decoded_sid2=H5Sdecode(null_sbuf); + CHECK(decoded_sid2, FAIL, "H5Sdecode"); + + /* Verify the decoded dataspace type */ + space_type = H5Sget_simple_extent_type(decoded_sid2); + VERIFY(space_type, H5S_NULL, "H5Sget_simple_extent_type"); + + /* Close the dataspaces */ + ret = H5Sclose(sid2); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(decoded_sid2); + CHECK(ret, FAIL, "H5Sclose"); + + /*------------------------------------------------------------------------- + * Test encoding and decoding of scalar dataspace. + *------------------------------------------------------------------------- + */ + /* Create scalar dataspace */ + sid3 = H5Screate(H5S_SCALAR); + CHECK(sid3, FAIL, "H5Screate_simple"); + + /* Encode scalar data space in a buffer */ + ret = H5Sencode1(sid3, NULL, &scalar_size); + CHECK(ret, FAIL, "H5Sencode"); + + if(scalar_size>0) { + scalar_buf = (unsigned char*)HDcalloc((size_t)1, scalar_size); + CHECK(scalar_buf, NULL, "HDcalloc"); + } + + /* Encode the scalar data space in the buffer */ + ret = H5Sencode1(sid3, scalar_buf, &scalar_size); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode from the dataspace buffer and return an object handle */ decoded_sid3=H5Sdecode(scalar_buf); CHECK(decoded_sid3, FAIL, "H5Sdecode"); @@ -1308,20 +1542,551 @@ test_h5s_encode(void) CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); VERIFY(n, 1, "H5Sget_simple_extent_npoints"); + /* Retrieve and verify the dataspace rank */ rank = H5Sget_simple_extent_ndims(decoded_sid3); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, 0, "H5Sget_simple_extent_ndims"); + /* Close the dataspaces */ ret = H5Sclose(sid3); CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(decoded_sid3); CHECK(ret, FAIL, "H5Sclose"); - HDfree(sbuf); - HDfree(null_sbuf); - HDfree(scalar_buf); -} /* test_h5s_encode() */ + /* Release resources */ + if(sbuf) + HDfree(sbuf); + if(null_sbuf) + HDfree(null_sbuf); + if(scalar_buf) + HDfree(scalar_buf); +} /* test_h5s_encode1() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + +/**************************************************************** +** +** test_h5s_check_encoding(): +** This is the helper routine to verify that H5Sencode2() +** works as specified in the RFC for the library format setting +** in the file access property list. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +** This routine is used by: +** test_h5s_encode_regular_hyper() +** test_h5s_encode_irregular_hyper() +** test_h5s_encode_points() +** +****************************************************************/ +static herr_t +test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, + uint32_t expected_version, uint8_t expected_enc_size, hbool_t expected_to_fail) +{ + char *buf = NULL; /* Pointer to the encoded buffer */ + size_t buf_size; /* Size of the encoded buffer */ + hid_t d_sid = -1; /* The decoded dataspace ID */ + htri_t check; + hsize_t in_low_bounds[1]; /* The low bounds for the selection for in_sid */ + hsize_t in_high_bounds[1]; /* The high bounds for the selection for in_sid */ + hsize_t d_low_bounds[1]; /* The low bounds for the selection for d_sid */ + hsize_t d_high_bounds[1]; /* The high bounds for the selection for d_sid */ + herr_t ret; /* Return value */ + + /* Get buffer size for encoding with the format setting in in_fapl */ + H5E_BEGIN_TRY { + ret = H5Sencode2(in_sid, NULL, &buf_size, in_fapl); + } H5E_END_TRY + + if(expected_to_fail) { + VERIFY(ret, FAIL, "H5Screate_simple"); + } else { + + CHECK(ret, FAIL, "H5Sencode2"); + + /* Allocate the buffer for encoding */ + buf = (char *)HDmalloc(buf_size); + CHECK(buf, NULL, "H5Dmalloc"); + + /* Encode according to the setting in in_fapl */ + ret = H5Sencode2(in_sid, buf, &buf_size, in_fapl); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode the buffer */ + d_sid = H5Sdecode(buf); + CHECK(d_sid, FAIL, "H5Sdecode"); + + /* Verify the number of selected points for in_sid and d_sid */ + VERIFY(H5Sget_select_npoints(in_sid), H5Sget_select_npoints(d_sid), "Compare npoints"); + + /* Verify if the two dataspace selections (in_sid, d_sid) are the same shape */ + check = H5S__select_shape_same_test(in_sid, d_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); + + /* Compare the starting/ending coordinates of the bounding box for in_sid and d_sid */ + ret = H5Sget_select_bounds(in_sid, in_low_bounds, in_high_bounds); + CHECK(ret, FAIL, "H5Sget_select_bounds"); + ret = H5Sget_select_bounds(d_sid, d_low_bounds, d_high_bounds); + CHECK(ret, FAIL, "H5Sget_select_bounds"); + VERIFY(in_low_bounds[0], d_low_bounds[0], "Compare selection low bounds"); + VERIFY(in_high_bounds[0], d_high_bounds[0], "Compare selection high bounds"); + + /* + * See "RFC: H5Sencode/H5Sdeocde Format Change" for the verification of: + * H5S_SEL_POINTS: + * --the expected version for point selection info + * --the expected encoded size (version 2 points selection info) + * H5S_SEL_HYPERSLABS: + * --the expected version for hyperslab selection info + * --the expected encoded size (version 3 hyperslab selection info) + */ + + if(H5Sget_select_type(in_sid) == H5S_SEL_POINTS) { + + /* Verify the version */ + VERIFY((uint32_t)buf[35], expected_version, "Version for point selection"); + + /* Verify the encoded size for version 2 */ + if(expected_version == 2) + VERIFY((uint8_t)buf[39], expected_enc_size, "Encoded size of point selection info"); + } + + if(H5Sget_select_type(in_sid) == H5S_SEL_HYPERSLABS) { + + /* Verify the version */ + VERIFY((uint32_t)buf[35], expected_version, "Version for hyperslab selection info"); + + /* Verify the encoded size for version 3 */ + if(expected_version == 3) + VERIFY((uint8_t)buf[40], expected_enc_size, "Encoded size of selection info"); + + } /* hyperslab selection */ + + ret = H5Sclose(d_sid); + CHECK(ret, FAIL, "H5Sclose"); + if(buf) + HDfree(buf); + + } + + return(0); + +} /* test_h5s_check_encoding */ + +/**************************************************************** +** +** test_h5s_encode_regular_hyper(): +** This test verifies that H5Sencode2() works as specified in +** the RFC for regular hyperslabs. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +****************************************************************/ +static void +test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) +{ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimension size */ + unsigned num_dsets = 513; /* Used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t start, stride, count, block; /* Selection info */ + unsigned config; /* Testing configuration */ + unsigned unlim; /* H5S_UNLIMITED setting or not */ + herr_t ret; /* Generic return value */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace encoding of regular hyperslabs\n")); + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ + sid = H5Screate_simple(1, vdsdims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Testing with each configuration */ + for(config = CONFIG_16; config <= CONFIG_32; config++) { + hbool_t expected_to_fail = FALSE; + + /* Testing with unlimited or not */ + for(unlim = 0; unlim <= 1; unlim++) { + start = 0; + count = unlim? H5S_UNLIMITED : 2; + + if((high <= H5F_LIBVER_V18) && + (unlim || config == CONFIG_32)) + expected_to_fail = TRUE; + + if(low >= H5F_LIBVER_V112) + expected_version = 3; + else if(config == CONFIG_16 && !unlim) + expected_version = 1; + else + expected_version = 2; + + /* test 1 */ + switch(config) { + case CONFIG_16: + stride = POWER16 - 1; + block = 4; + expected_enc_size = expected_version == 3 ? 2 : 4; + break; + case CONFIG_32: + stride = POWER32 - 1; + block = 4; + expected_enc_size = expected_version == 3 ? 4 : 8; + + break; + default: + HDassert(0); + break; + } /* end switch */ + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 2 */ + switch(config) { + case CONFIG_16: + stride = POWER16 - 1; + block = POWER16 - 2; + expected_enc_size = expected_version == 3 ? 2 : 4; + break; + case CONFIG_32: + stride = POWER32 - 1; + block = POWER32 - 2; + expected_enc_size = expected_version == 3 ? 4 : 8; + break; + default: + HDassert(0); + break; + } /* end switch */ + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 3 */ + switch(config) { + case CONFIG_16: + stride = POWER16 - 1; + block = POWER16 - 1; + expected_enc_size = 4; + break; + case CONFIG_32: + stride = POWER32 - 1; + block = POWER32 - 1; + expected_enc_size = 8; + break; + default: + HDassert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 4 */ + switch(config) { + case CONFIG_16: + stride = POWER16; + block = POWER16 - 2; + expected_enc_size = 4; + break; + case CONFIG_32: + stride = POWER32; + block = POWER32 - 2; + expected_enc_size = 8; + break; + default: + HDassert(0); + break; + } /* end switch */ + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 5 */ + switch(config) { + case CONFIG_16: + stride = POWER16; + block = 1; + expected_enc_size = 4; + break; + case CONFIG_32: + stride = POWER32; + block = 1; + expected_enc_size = 8; + break; + default: + HDassert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + } /* for unlim */ + } /* for config */ + + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + +} /* test_h5s_encode_regular_hyper() */ + +/**************************************************************** +** +** test_h5s_encode_irregular_hyper(): +** This test verifies that H5Sencode2() works as specified in +** the RFC for irregular hyperslabs. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +****************************************************************/ +static void +test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) +{ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimension size */ + unsigned num_dsets = 513; /* Used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t start, stride, count, block; /* Selection info */ + htri_t is_regular; /* Is this a regular hyperslab */ + unsigned config; /* Testing configuration */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace encoding of irregular hyperslabs\n")); + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ + sid = H5Screate_simple(1, vdsdims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Testing with each configuration */ + for(config = CONFIG_8; config <= CONFIG_32; config++) { + hbool_t expected_to_fail = FALSE; /* Whether H5Sencode2 is expected to fail */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */ + + start = 0; + count = 2; + block = 4; + + /* H5Sencode2 is expected to fail for library v110 and below + when the selection exceeds the 32 bits integer limit */ + if(high <= H5F_LIBVER_V110 && config == CONFIG_32) + expected_to_fail = TRUE; + + if(low >= H5F_LIBVER_V112 || config == CONFIG_32) + expected_version = 3; + else + expected_version = 1; + + switch(config) { + case CONFIG_8: + stride = POWER8 - 2; + break; + + case CONFIG_16: + stride = POWER16 - 2; + break; + + case CONFIG_32: + stride = POWER32 - 2; + break; + + default: + HDassert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + start = 8; + count = 5; + block = 2; + + switch(config) { + case CONFIG_8: + stride = POWER8; + expected_enc_size = expected_version == 3 ? 2 : 4; + break; + + case CONFIG_16: + stride = POWER16; + expected_enc_size = 4; + break; + + case CONFIG_32: + stride = POWER32; + expected_enc_size = 8; + break; + + default: + assert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Should be irregular hyperslab */ + is_regular = H5Sis_regular_hyperslab(sid); + VERIFY(is_regular, FALSE, "H5Sis_regular_hyperslab"); + + /* Verify the version and encoded size expected for the configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + } /* for config */ + + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + +} /* test_h5s_encode_irregular_hyper() */ + +/**************************************************************** +** +** test_h5s_encode_points(): +** This test verifies that H5Sencode2() works as specified in +** the RFC for point selection. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +****************************************************************/ +static void +test_h5s_encode_points(H5F_libver_t low, H5F_libver_t high) +{ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimenion size */ + unsigned num_dsets = 513; /* used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t coord[4]; /* The point coordinates */ + herr_t ret; /* Generic return value */ + hbool_t expected_to_fail = FALSE; /* Expected to fail or not */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size of selection info */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace encoding of points selection\n")); + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ + sid = H5Screate_simple(1, vdsdims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* test 1 */ + coord[0] = 5; + coord[1] = 15; + coord[2] = POWER16; + coord[3] = 19; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + expected_to_fail = FALSE; + expected_enc_size = 4; + expected_version = 1; + + if(low >= H5F_LIBVER_V112) + expected_version = 2; + + /* Verify the version and encoded size expected for the configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 2 */ + coord[0] = 5; + coord[1] = 15; + coord[2] = POWER32 - 1; + coord[3] = 19; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + /* Expected result same as test 1 */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 3 */ + if(high <= H5F_LIBVER_V110) + expected_to_fail = TRUE; + + if(high >= H5F_LIBVER_V112) { + expected_version = 2; + expected_enc_size = 8; + } + + coord[0] = 5; + coord[1] = 15; + coord[2] = POWER32 + 1; + coord[3] = 19; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + /* Verify the version and encoded size expected for the configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + +} /* test_h5s_encode_points() */ /**************************************************************** ** @@ -1362,7 +2127,7 @@ test_h5s_encode_length(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Encode simple data space in a buffer */ - ret = H5Sencode(sid, NULL, &sbuf_size); + ret = H5Sencode2(sid, NULL, &sbuf_size, H5P_DEFAULT); CHECK(ret, FAIL, "H5Sencode"); /* Allocate the buffer */ @@ -1372,7 +2137,7 @@ test_h5s_encode_length(void) } /* Encode the dataspace */ - ret = H5Sencode(sid, sbuf, &sbuf_size); + ret = H5Sencode2(sid, sbuf, &sbuf_size, H5P_DEFAULT); CHECK(ret, FAIL, "H5Sencode"); /* Verify that length stored at this location in the buffer is correct */ @@ -1400,7 +2165,6 @@ test_h5s_encode_length(void) } /* test_h5s_encode_length() */ - /**************************************************************** ** ** test_h5s_scalar_write(): Test scalar H5S (dataspace) writing code. @@ -1409,14 +2173,14 @@ test_h5s_encode_length(void) static void test_h5s_scalar_write(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - int rank; /* Logical rank of dataspace */ - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - H5S_class_t ext_type; /* Extent type */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + int rank; /* Logical rank of dataspace */ + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + H5S_class_t ext_type; /* Extent type */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Scalar Dataspace Manipulation during Writing\n")); @@ -1435,14 +2199,17 @@ test_h5s_scalar_write(void) sid1 = H5Screate_simple(SPACE3_RANK, NULL, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); + /* Retrieve the number of elements in the dataspace selection */ n = H5Sget_simple_extent_npoints(sid1); CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); VERIFY(n, 1, "H5Sget_simple_extent_npoints"); + /* Get the dataspace rank */ rank = H5Sget_simple_extent_ndims(sid1); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, SPACE3_RANK, "H5Sget_simple_extent_ndims"); + /* Get the dataspace dimension sizes */ rank = H5Sget_simple_extent_dims(sid1, tdims, NULL); VERIFY(rank, 0, "H5Sget_simple_extent_dims"); @@ -1454,6 +2221,7 @@ test_h5s_scalar_write(void) dataset = H5Dcreate2(fid1, "Dataset1", H5T_NATIVE_UINT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); + /* Write to the dataset */ ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &space3_data); CHECK(ret, FAIL, "H5Dwrite"); @@ -1468,7 +2236,7 @@ test_h5s_scalar_write(void) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5s_scalar_write() */ +} /* test_h5s_scalar_write() */ /**************************************************************** ** @@ -2587,16 +3355,38 @@ test_versionbounds(void) void test_h5s(void) { + H5F_libver_t low, high; /* Low and high bounds */ + /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspaces\n")); - test_h5s_basic(); /* Test basic H5S code */ - test_h5s_null(); /* Test Null dataspace H5S code */ + test_h5s_basic(); /* Test basic H5S code */ + test_h5s_null(); /* Test Null dataspace H5S code */ test_h5s_zero_dim(); /* Test dataspace with zero dimension size */ - test_h5s_encode(); /* Test encoding and decoding */ - test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */ + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + test_h5s_encode(low, high); /* Test encoding and decoding */ + test_h5s_encode_regular_hyper(low, high); /* Test encoding regular hyperslabs */ + test_h5s_encode_irregular_hyper(low, high); /* Test encoding irregular hyperslabs */ + test_h5s_encode_points(low, high); /* Test encoding points */ + + } /* end high bound */ + } /* end low bound */ + + test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + test_h5s_encode1(); /* Test operations with old API routine (H5Sencode1) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + test_h5s_scalar_write(); /* Test scalar H5S writing code */ - test_h5s_scalar_read(); /* Test scalar H5S reading code */ + test_h5s_scalar_read(); /* Test scalar H5S reading code */ test_h5s_compound_scalar_write(); /* Test compound datatype scalar H5S writing code */ test_h5s_compound_scalar_read(); /* Test compound datatype scalar H5S reading code */ diff --git a/test/trefer.c b/test/trefer.c index 938f040..4bf9caf 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -490,16 +490,20 @@ test_reference_obj(void) ** test_reference_region(): Test basic H5R (reference) object reference code. ** Tests references to various kinds of objects ** +** Note: The libver_low/libver_high parameters are added to create the file +** with the low and high bounds setting in fapl. +** Please see the RFC for "H5Sencode/H5Sdecode Format Change". +** ****************************************************************/ static void test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) { - hid_t fid1; /* HDF5 File IDs */ + hid_t fid1; /* HDF5 File IDs */ hid_t fapl = -1; /* File access property list */ - hid_t dset1, /* Dataset ID */ + hid_t dset1, /* Dataset ID */ dset2; /* Dereferenced dataset ID */ - hid_t sid1, /* Dataspace ID #1 */ - sid2; /* Dataspace ID #2 */ + hid_t sid1, /* Dataspace ID #1 */ + sid2; /* Dataspace ID #2 */ hid_t dapl_id; /* Dataset access property list */ hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; @@ -508,24 +512,24 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hsize_t *coords; /* Coordinate buffer */ - hsize_t low[SPACE2_RANK]; /* Selection bounds */ - hsize_t high[SPACE2_RANK]; /* Selection bounds */ - hdset_reg_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - hdset_reg_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */ - uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ - *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - H5O_type_t obj_type; /* Type of object */ - int i, j; /* counting variables */ - hssize_t hssize_ret; /* hssize_t return value */ - htri_t tri_ret; /* htri_t return value */ - herr_t ret; /* Generic return value */ - haddr_t addr = HADDR_UNDEF; /* test for undefined reference */ - hid_t dset_NA; /* Dataset id for undefined reference */ - hid_t space_NA; /* Dataspace id for undefined reference */ - hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ + hsize_t *coords; /* Coordinate buffer */ + hsize_t low[SPACE2_RANK]; /* Selection bounds */ + hsize_t high[SPACE2_RANK]; /* Selection bounds */ + hdset_reg_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + hdset_reg_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */ + uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ + *drbuf; /* Buffer for reading numeric data from disk */ + uint8_t *tu8; /* Temporary pointer to uint8 data */ + H5O_type_t obj_type; /* Type of object */ + int i, j; /* counting variables */ + hssize_t hssize_ret; /* hssize_t return value */ + htri_t tri_ret; /* htri_t return value */ + herr_t ret; /* Generic return value */ + haddr_t addr = HADDR_UNDEF; /* test for undefined reference */ + hid_t dset_NA; /* Dataset id for undefined reference */ + hid_t space_NA; /* Dataspace id for undefined reference */ + hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ hdset_reg_ref_t wdata_NA[1], /* Write buffer */ rdata_NA[1]; /* Read buffer */ @@ -634,8 +638,14 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints"); /* Store third dataset region */ - ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); - CHECK(ret, FAIL, "H5Rcreate"); + H5E_BEGIN_TRY { + ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); + } H5E_END_TRY; + + if(libver_high < H5F_LIBVER_V110) + VERIFY(ret, FAIL, "H5Rcreate"); + else + CHECK(ret, FAIL, "H5Rcreate"); ret = H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &wbuf[0], &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type2"); @@ -420,11 +420,11 @@ test_api_get_ex_dcpl(test_api_config_t config, hid_t fapl, hid_t dcpl, size_t plist_buf_size; /* Encode property list to plist_buf */ - if(H5Pencode(dcpl, NULL, &plist_buf_size) < 0) + if(H5Pencode2(dcpl, NULL, &plist_buf_size, fapl) < 0) TEST_ERROR if(NULL == (plist_buf = HDmalloc(plist_buf_size))) TEST_ERROR - if(H5Pencode(dcpl, plist_buf, &plist_buf_size) < 0) + if(H5Pencode2(dcpl, plist_buf, &plist_buf_size, fapl) < 0) TEST_ERROR /* Decode serialized property list to *ex_dcpl */ @@ -469,7 +469,7 @@ error: /* Main test function */ static int -test_api(test_api_config_t config, hid_t fapl) +test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) { char filename[FILENAME_BUF_SIZE]; hid_t dcpl = -1; /* Dataset creation property list */ @@ -618,7 +618,8 @@ test_api(test_api_config_t config, hid_t fapl) TEST_ERROR /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)213) < 0) + if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, + (low >= H5F_LIBVER_V112)?(hsize_t)99:(low >= H5F_LIBVER_V110?174:213)) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ @@ -1025,7 +1026,8 @@ test_api(test_api_config_t config, hid_t fapl) } /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)697) < 0) + if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, + (low >= H5F_LIBVER_V112)?(hsize_t)607:(hsize_t)697) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ @@ -11410,6 +11412,11 @@ test_dapl_values(hid_t fapl_id) * * Purpose: Tests datasets with virtual layout * + * Note: + * Tests are modified to test with the low/high bounds combination + * set in fapl. + * Please see RFC for "H5Sencode/H5Sdecode Format Change". + * * Return: EXIT_SUCCESS/EXIT_FAILURE *------------------------------------------------------------------------- */ @@ -11418,8 +11425,11 @@ main(void) { char filename[FILENAME_BUF_SIZE]; hid_t fapl; + hid_t my_fapl = -1; /* File access property list */ int test_api_config; unsigned bit_config; + unsigned latest = FALSE; /* Using the latest library version bound */ + H5F_libver_t low, high; /* Low and high bounds */ int nerrors = 0; /* Testing setup */ @@ -11428,21 +11438,59 @@ main(void) 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); - for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { - HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); - nerrors += test_basic_io(bit_config, fapl); - nerrors += test_vds_prefix_first(bit_config, fapl); - nerrors += test_unlim(bit_config, fapl); - nerrors += test_printf(bit_config, fapl); - nerrors += test_all(bit_config, fapl); - } + /* Set to use the latest file format */ + if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + char *low_string; /* The low bound string */ + char *high_string; /* The high bound string */ + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + /* Test virtual dataset only for V110 and above */ + if(high < H5F_LIBVER_V110) + continue; + + /* Whether to use latest hyperslab/point selection version */ + if(low >= H5F_LIBVER_V112) + latest = TRUE; + + /* Set the low/high version bounds */ + if(H5Pset_libver_bounds(my_fapl, low, high) < 0) + TEST_ERROR + + /* Display testing info */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, high_string); + HDputs(msg); + + 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, my_fapl, low); + for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + nerrors += test_basic_io(bit_config, my_fapl); + nerrors += test_vds_prefix_first(bit_config, my_fapl); + nerrors += test_unlim(bit_config, my_fapl); + nerrors += test_printf(bit_config, my_fapl); + nerrors += test_all(bit_config, my_fapl); + } - nerrors += test_dapl_values(fapl); + nerrors += test_dapl_values(my_fapl); - /* Verify symbol table messages are cached */ - nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); + /* Verify symbol table messages are cached */ + nerrors += (h5_verify_cached_stabs(FILENAME, my_fapl) < 0 ? 1 : 0); + + } /* end for high */ + } /* end for low */ + + if(H5Pclose(my_fapl) < 0) + TEST_ERROR if(nerrors) goto error; |