diff options
author | Vailin Choi <vchoi@jam.ad.hdfgroup.org> | 2018-03-21 16:44:24 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@jam.ad.hdfgroup.org> | 2018-03-21 16:44:24 (GMT) |
commit | aa9e1aeea18a0eff050feac19596be6cad9a7c65 (patch) | |
tree | c42bc0424629644969ddf562eba105c61509c88a /hl/test | |
parent | 6a1627f2967099039e11b9e86cf347f6482bdf3c (diff) | |
download | hdf5-aa9e1aeea18a0eff050feac19596be6cad9a7c65.zip hdf5-aa9e1aeea18a0eff050feac19596be6cad9a7c65.tar.gz hdf5-aa9e1aeea18a0eff050feac19596be6cad9a7c65.tar.bz2 |
Add test and release info for the fix to HDFFV-10425 test failure with H5DOwrite_chunk.
Diffstat (limited to 'hl/test')
-rw-r--r-- | hl/test/test_dset_opt.c | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/hl/test/test_dset_opt.c b/hl/test/test_dset_opt.c index 383a87a..fe2b2f3 100644 --- a/hl/test/test_dset_opt.c +++ b/hl/test/test_dset_opt.c @@ -62,6 +62,14 @@ #define OVERWRITE_CHUNK_NY 2 #define OVERWRITE_VALUE 42 +/* Defines used in test_single_chunk_latest() */ +#define FILE "single_latest.h5" +#define DATASET "dataset" +#define DIM0 4 +#define DIM1 32 +#define CHUNK0 DIM0 +#define CHUNK1 DIM1 + /* Local prototypes for filter functions */ static size_t filter_bogus1(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); @@ -1969,6 +1977,139 @@ error: } /* test_read_unallocated_chunk() */ /*------------------------------------------------------------------------- + * Function: test_single_chunk_latest + * + * Purpose: This is to verify the fix for jira issue HDFFV-10425. + * The problem was due to a bug in the internal ilbrary routine + * H5D__chunk_direct_write() which passed a null dataset + * pointer to the insert callback for the chunk index type. + * Currently, the single chunk index is the only one that + * used the dataset pointer in the insert callback. + * + * This routine is based on the test program attached to + * this jira issue: + * Create a file with the latest format and a chunked dataset + * with one single chunk. The library will use single chunk + * index for the dataset. + * Verify that the data read is the same as the written data. + * + * Return: Success: 0 + * Failure: 1 + * + *------------------------------------------------------------------------- + */ +static int +test_single_chunk_latest(void) +{ + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list ID */ + hid_t sid; /* Dataspace ID */ + hid_t did; /* Dataset ID */ + hid_t dcpl; /* Dataset creation property list */ + hsize_t dims[2] = {DIM0, DIM1}; /* Dimension sizes */ + hsize_t chunk[2] = {CHUNK0, CHUNK1}; /* Chunk dimension sizes */ + hsize_t offset[2] = {0,0}; /* Offset for writing */ + int wdata[DIM0][DIM1]; /* Write buffer */ + int rdata[DIM0][DIM1]; /* Read buffer */ + int i, j; /* Local index variable */ + + TESTING("H5DOwrite_chunk with single chunk and latest format"); + + /* Initialize data */ + for (i=0; i<DIM0; i++) { + for (j=0; j< DIM1; j++) + wdata[i][j] = j/CHUNK0; + } + + /* Create a new file with the latest format */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + goto error; + if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + + /* Create dataspace */ + if((sid = H5Screate_simple(2, dims, NULL)) < 0) + goto error; + + /* Create the dataset creation property list and set the chunk size */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if(H5Pset_chunk(dcpl, 2, chunk) < 0) + goto error; + + /* Create the dataset */ + if((did = H5Dcreate(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + + /* Write the data directly to the dataset */ + if(H5DOwrite_chunk(did, H5P_DEFAULT, 0, offset, CHUNK0*CHUNK1*4, (void *)wdata) < 0) + goto error; + + /* + * Close and release resources. + */ + if(H5Pclose(dcpl) < 0) + goto error; + if(H5Dclose(did) < 0) + goto error; + if(H5Sclose(sid) < 0) + goto error; + if(H5Pclose(fapl) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + + /* Open the file and dataset with default properties */ + if((fid = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + goto error; + if((did = H5Dopen(fid, DATASET, H5P_DEFAULT)) < 0) + goto error; + + /* Retrieve dataset creation property list */ + if((dcpl = H5Dget_create_plist(did)) < 0) + goto error; + + /* Read the data */ + if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) + goto error; + + /* Verify that the data read was correct. */ + for (i = 0; i < DIM0; i++) { + for (j = 0; j < DIM1; j++) { + if(rdata[i][j] != wdata[i][j]) + goto error; + } + } + + /* + * Close and release resources + */ + if(H5Pclose(dcpl) < 0) + goto error; + if(H5Dclose(did) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcpl); + H5Pclose(fapl); + H5Fclose(fid); + } H5E_END_TRY; + + H5_FAILED(); + return 1; +} /* test_single_chunk_latest() */ + +/*------------------------------------------------------------------------- * Function: Main function * * Purpose: Test direct chunk write function H5DOwrite_chunk and @@ -2012,6 +2153,8 @@ int main( void ) nerrors += test_read_unfiltered_dset(file_id); nerrors += test_read_unallocated_chunk(file_id); + nerrors += test_single_chunk_latest(); + if(H5Fclose(file_id) < 0) goto error; |