[svn-r25401] add serial and parallel regression tests for zero dset read/write bug.

This commit is contained in:
Mohamad Chaarawi 2014-07-09 14:01:25 -05:00
parent 6d637e03f7
commit 92cc75bfae
4 changed files with 137 additions and 0 deletions

View File

@ -50,6 +50,7 @@ const char *FILENAME[] = {
"chunk_expand",
"copy_dcpl_newfile",
"layout_extend",
"zero_chunk",
NULL
};
#define FILENAME_BUF_SIZE 1024
@ -8190,6 +8191,80 @@ error:
return -1;
} /* end test_large_chunk_shrink() */
/*-------------------------------------------------------------------------
* Function: test_zero_dim_dset
*
* Purpose: Tests support for reading a 1D chunled dataset with
* dimension size = 0.
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Mohamad Chaarawi
* Wednesdat, July 9, 2014
*
*-------------------------------------------------------------------------
*/
static herr_t
test_zero_dim_dset(hid_t fapl)
{
char filename[FILENAME_BUF_SIZE];
hid_t fid = -1; /* File ID */
hid_t dcpl = -1; /* Dataset creation property list ID */
hid_t sid = -1; /* Dataspace ID */
hid_t dsid = -1; /* Dataset ID */
hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */
int data[1];
TESTING("shrinking large chunk");
h5_fixname(FILENAME[13], fapl, filename, sizeof filename);
/* Create file */
if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
/* Create dataset creation property list */
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
/* Set 1 chunk size */
chunk_dim = 1;
if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR
/* Create 1D dataspace with 0 dim size */
dim = 0;
if((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR
/* Create chunked dataset */
if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
/* write 0 elements from dataset */
if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR
/* Read 0 elements from dataset */
if(H5Dread(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR
/* Close everything */
if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
H5Dclose(dsid);
H5Sclose(sid);
H5Fclose(fid);
} H5E_END_TRY;
return -1;
} /* end test_zero_dim_dset() */
/*-------------------------------------------------------------------------
* Function: test_scatter
@ -9340,6 +9415,7 @@ main(void)
nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0);
nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0);
nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0);
nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0);
if(H5Fclose(file) < 0)
goto error;

View File

@ -73,6 +73,63 @@ get_size(void)
} /* get_size() */
/*
* Example of using PHDF5 to create a zero sized dataset.
*
*/
void zero_dim_dset(void)
{
int mpi_size, mpi_rank;
const char *filename;
hid_t fid, plist, dcpl, dsid, sid;
hsize_t dim, chunk_dim;
herr_t ret;
int data[1];
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
filename = GetTestParameters();
plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type);
VRFY((plist>=0), "create_faccess_plist succeeded");
fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist);
VRFY((fid>=0), "H5Fcreate succeeded");
ret = H5Pclose(plist);
VRFY((ret>=0), "H5Pclose succeeded");
dcpl = H5Pcreate(H5P_DATASET_CREATE);
VRFY((dcpl>=0), "failed H5Pcreate");
/* Set 1 chunk size */
chunk_dim = 1;
ret = H5Pset_chunk(dcpl, 1, &chunk_dim);
VRFY((ret>=0), "failed H5Pset_chunk");
/* Create 1D dataspace with 0 dim size */
dim = 0;
sid = H5Screate_simple(1, &dim, NULL);
VRFY((sid>=0), "failed H5Screate_simple");
/* Create chunked dataset */
dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
VRFY((dsid>=0), "failed H5Dcreate2");
/* write 0 elements from dataset */
ret = H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data);
VRFY((ret>=0), "failed H5Dwrite");
/* Read 0 elements from dataset */
ret = H5Dread(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data);
VRFY((ret>=0), "failed H5Dread");
H5Pclose(dcpl);
H5Dclose(dsid);
H5Sclose(sid);
H5Fclose(fid);
}
/*
* Example of using PHDF5 to create ndatasets datasets. Each process write
* a slab of array to the file.

View File

@ -377,6 +377,9 @@ int main(int argc, char **argv)
"compressed dataset collective read", PARATESTFILE);
#endif /* H5_HAVE_FILTER_DEFLATE */
AddTest("zerodsetr", zero_dim_dset, NULL,
"zero dim dset", PARATESTFILE);
ndsets_params.name = PARATESTFILE;
ndsets_params.count = ndatasets;
AddTest("ndsetw", multiple_dset_write, NULL,

View File

@ -237,6 +237,7 @@ extern int dxfer_coll_type;
/* Test program prototypes */
void test_plist_ed(void);
void zero_dim_dset(void);
void multiple_dset_write(void);
void multiple_group_write(void);
void multiple_group_read(void);