diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2010-01-29 20:38:34 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2010-01-29 20:38:34 (GMT) |
commit | 35b0159a0a5f1f4b80e305204ea51a742b052403 (patch) | |
tree | 94e39458c4da4f360b103e96e2afccfc06442460 /test | |
parent | c147f1815e21a6b65b1bda4a7c96156143329605 (diff) | |
download | hdf5-35b0159a0a5f1f4b80e305204ea51a742b052403.zip hdf5-35b0159a0a5f1f4b80e305204ea51a742b052403.tar.gz hdf5-35b0159a0a5f1f4b80e305204ea51a742b052403.tar.bz2 |
[svn-r18193] I added a test for copying an existing DCPL and using the copy to create a new dataset. There's
a bug report (#1608) saying h5repack failed to do that sometimes. But I couldn't reproduce it.
So I added this test and closed the report. The test is in the function test_copy_dcpl in dsets.c.
Tested on jam. But I tested the same change in 1.8 on jam, amani, and linew.
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/Makefile.in | 11 | ||||
-rw-r--r-- | test/dsets.c | 137 |
3 files changed, 144 insertions, 6 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 5a33c82..d342c17 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -106,7 +106,7 @@ flush2.chkexe_: flush1.chkexe_ CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offset.h5 \ max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \ huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \ - extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \ + copy_dcpl_newfile.h5 extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \ sys_file1 tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 \ stab.h5 extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \ dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \ diff --git a/test/Makefile.in b/test/Makefile.in index ed4cfac..4777bf6 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -668,11 +668,12 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \ compact_dataset.h5 dataset.h5 dset_offset.h5 \ max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \ huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \ - extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \ - sys_file1 tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 \ - stab.h5 extern_[1-3].h5 extern_[1-4][ab].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 \ + copy_dcpl_newfile.h5 extend.h5 istore.h5 extlinks*.h5 \ + frspace.h5 links*.h5 sys_file1 tfile[1-4].h5 th5s[1-3].h5 \ + lheap.h5 fheap.h5 ohdr.h5 stab.h5 extern_[1-3].h5 \ + extern_[1-4][ab].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[1-8].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \ unlink.h5 unicode.h5 coord.h5 fillval_[0-9].h5 fillval.raw \ mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[1-3].h5 tvltypes.h5 \ diff --git a/test/dsets.c b/test/dsets.c index b4c6a84..1041385 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -47,6 +47,7 @@ const char *FILENAME[] = { "chunk_cache", "big_chunk", "chunk_expand", + "copy_dcpl_newfile", NULL }; #define FILENAME_BUF_SIZE 1024 @@ -97,6 +98,9 @@ const char *FILENAME[] = { #define DSET_SCALEOFFSET_DOUBLE_NAME_2 "scaleoffset_double_2" #define DSET_COMPARE_DCPL_NAME "compare_dcpl" #define DSET_COMPARE_DCPL_NAME_2 "compare_dcpl_2" +#define DSET_COPY_DCPL_NAME_1 "copy_dcpl_1" +#define DSET_COPY_DCPL_NAME_2 "copy_dcpl_2" +#define COPY_DCPL_EXTFILE_NAME "ext_file" #define DSET_DEPREC_NAME "deprecated" #define DSET_DEPREC_NAME_CHUNKED "deprecated_chunked" #define DSET_DEPREC_NAME_COMPACT "deprecated_compact" @@ -5555,6 +5559,138 @@ error: /*------------------------------------------------------------------------- + * Function: test_copy_dcpl + * + * Purpose: Verifies whether the copy of dataset creation property + * list works. It tests the DCPL for chunked layout with + * filter and for contiguous layout with external storage. + * (Please see #1608 in Bugzilla) + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 28 January 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_copy_dcpl(hid_t file, hid_t fapl) +{ + hid_t dsid1=(-1), dsid2=(-1); /* Dataset ID */ + hid_t new_dsid1=(-1), new_dsid2=(-1); /* Dataset ID */ + hid_t sid=(-1); /* Dataspace ID */ + hid_t dcpl=(-1); /* Dataset creation property list ID */ + hid_t dcpl1=(-1),dcpl2=(-1); /* Copies of creation property list IDs */ + hid_t dcpl1_copy=(-1),dcpl2_copy=(-1);/* Copies of creation property list IDs */ + const hsize_t dims[2] = {500, 4096}; /* Dataspace dimensions */ + const hsize_t chunk_dims[2] = {250, 2048}; /* Chunk dimensions */ + char filename[FILENAME_BUF_SIZE]; + hid_t new_file=(-1); + + TESTING("copying dataset creation property lists"); + + /* Create the data space */ + if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR + + /* Create dcpl with special filter */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR + if(H5Pset_fletcher32(dcpl) < 0) TEST_ERROR + + /* Create first dataset of chunking with filter */ + if((dsid1 = H5Dcreate2(file, DSET_COPY_DCPL_NAME_1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, + H5P_DEFAULT)) < 0) TEST_ERROR + + /* Close dataset */ + if(H5Dclose (dsid1) < 0) TEST_ERROR + + /* Reopen the first dataset */ + if((dsid1 = H5Dopen2(file, DSET_COPY_DCPL_NAME_1, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Get the copy of dataset's creation property list */ + if((dcpl1=H5Dget_create_plist(dsid1)) < 0) TEST_ERROR + if((dcpl1_copy = H5Pcopy(dcpl1)) < 0) TEST_ERROR + + /* Close dataset */ + if(H5Dclose (dsid1) < 0) TEST_ERROR + + /* Change the DCPL for contiguous layout with external storage. The size of the reserved + * space in the external file is the size of the dataset - 500*4096*sizeof(int). + * There's no need to clean up the external file since the library doesn't create it + * until the data is written to it. */ + if(H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) TEST_ERROR + if(H5Premove_filter(dcpl, H5Z_FILTER_FLETCHER32) < 0) TEST_ERROR + if(H5Pset_external(dcpl, COPY_DCPL_EXTFILE_NAME, 0, 500*4096*sizeof(int)) < 0) TEST_ERROR + + /* Create second dataset of contiguous layout with external storage */ + if((dsid2 = H5Dcreate2(file, DSET_COPY_DCPL_NAME_2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, + H5P_DEFAULT)) < 0) TEST_ERROR + + /* Close dataset */ + if(H5Dclose (dsid2) < 0) TEST_ERROR + + /* Reopen the second dataset */ + if((dsid2 = H5Dopen2(file, DSET_COPY_DCPL_NAME_2, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Get copy of dataset's dataset creation property list */ + if((dcpl2=H5Dget_create_plist(dsid2)) < 0) TEST_ERROR + if((dcpl2_copy = H5Pcopy(dcpl2)) < 0) TEST_ERROR + + /* Close dataset */ + if(H5Dclose (dsid2) < 0) TEST_ERROR + + /* Create a second file and create 2 datasets with the copies of the DCPLs in the first + * file. Test whether the copies of DCPLs work. */ + h5_fixname(FILENAME[11], fapl, filename, sizeof filename); + if((new_file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((new_dsid1 = H5Dcreate2(new_file, DSET_COPY_DCPL_NAME_1, H5T_NATIVE_INT, sid, + H5P_DEFAULT, dcpl1_copy, H5P_DEFAULT)) < 0) TEST_ERROR + + if((new_dsid2 = H5Dcreate2(new_file, DSET_COPY_DCPL_NAME_2, H5T_NATIVE_INT, sid, + H5P_DEFAULT, dcpl2_copy, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Close dataspace */ + if(H5Sclose(sid) < 0) TEST_ERROR + + /* Close datasets */ + if(H5Dclose (new_dsid1) < 0) TEST_ERROR + if(H5Dclose (new_dsid2) < 0) TEST_ERROR + + /* Close the second file */ + if(H5Fclose (new_file) < 0) TEST_ERROR + + /* Close dataset creation property lists */ + if(H5Pclose(dcpl) < 0) TEST_ERROR + if(H5Pclose(dcpl1) < 0) TEST_ERROR + if(H5Pclose(dcpl2) < 0) TEST_ERROR + if(H5Pclose(dcpl1_copy) < 0) TEST_ERROR + if(H5Pclose(dcpl2_copy) < 0) TEST_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dsid1); + H5Dclose(dsid2); + H5Dclose(new_dsid1); + H5Dclose(new_dsid2); + H5Sclose(sid); + H5Pclose(dcpl); + H5Pclose(dcpl1); + H5Pclose(dcpl2); + H5Pclose(dcpl1_copy); + H5Pclose(dcpl2_copy); + } H5E_END_TRY; + return -1; +} /* end test_copy_dcpl() */ + + +/*------------------------------------------------------------------------- * Function: test_filter_delete * * Purpose: Tests deletion of filters from a dataset creation property list @@ -7385,6 +7521,7 @@ main(void) nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); + nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); nerrors += (test_filter_delete(file) < 0 ? 1 : 0); nerrors += (test_filters_endianess() < 0 ? 1 : 0); nerrors += (test_zero_dims(file) < 0 ? 1 : 0); |