diff options
author | Elena Pourmal <epourmal@hdfgroup.org> | 2006-11-16 23:28:13 (GMT) |
---|---|---|
committer | Elena Pourmal <epourmal@hdfgroup.org> | 2006-11-16 23:28:13 (GMT) |
commit | 7cc88ba656890266f0b5c54180db9f3734f83f7b (patch) | |
tree | 7e6638fe0a4de366a8ea991cf4d17361512acbc4 /test | |
parent | 6b5a918b1e2da1f56d1026704e652a0bc17f1882 (diff) | |
download | hdf5-7cc88ba656890266f0b5c54180db9f3734f83f7b.zip hdf5-7cc88ba656890266f0b5c54180db9f3734f83f7b.tar.gz hdf5-7cc88ba656890266f0b5c54180db9f3734f83f7b.tar.bz2 |
[svn-r12930] Description:
Added new refreg_name.c file to test H5Rget_name and H5Iget_name for region references.
H5Rget_name tests are skipped for now since they do not work (at least for me :-)
Platforms tested:
heping and copper
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 28 | ||||
-rw-r--r-- | test/refreg_name.c | 170 |
3 files changed, 192 insertions, 11 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index ecbce02..031a629 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -40,7 +40,7 @@ TEST_PROG=testhdf5 lheap ohdr stab gheap cache cache_api \ dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \ fillval mount flush1 flush2 enum \ set_extent ttsafe stream_test \ - getname ref vfd ntypes dangle dtransform reserved cross_read \ + getname ref refreg_name vfd ntypes dangle dtransform reserved cross_read \ btree2 fheap # List programs to be built when testing here. error_test and err_compat are @@ -116,7 +116,8 @@ CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5 new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ unlink_chunked.h5 btree2.h5 \ - objcopy_src.h5 objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5 + objcopy_src.h5 objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5\ + refreg_name.h5 # Sources for testhdf5 executable testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ diff --git a/test/Makefile.in b/test/Makefile.in index b984914..f0d9930 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -80,9 +80,10 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ unlink$(EXEEXT) big$(EXEEXT) mtime$(EXEEXT) fillval$(EXEEXT) \ mount$(EXEEXT) flush1$(EXEEXT) flush2$(EXEEXT) enum$(EXEEXT) \ set_extent$(EXEEXT) ttsafe$(EXEEXT) stream_test$(EXEEXT) \ - getname$(EXEEXT) ref$(EXEEXT) vfd$(EXEEXT) ntypes$(EXEEXT) \ - dangle$(EXEEXT) dtransform$(EXEEXT) reserved$(EXEEXT) \ - cross_read$(EXEEXT) btree2$(EXEEXT) fheap$(EXEEXT) + getname$(EXEEXT) ref$(EXEEXT) refreg_name$(EXEEXT) \ + vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \ + dtransform$(EXEEXT) reserved$(EXEEXT) cross_read$(EXEEXT) \ + btree2$(EXEEXT) fheap$(EXEEXT) am__EXEEXT_2 = gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \ gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \ gen_new_group$(EXEEXT) gen_new_mtime$(EXEEXT) \ @@ -271,6 +272,10 @@ ref_SOURCES = ref.c ref_OBJECTS = ref.$(OBJEXT) ref_LDADD = $(LDADD) ref_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1) +refreg_name_SOURCES = refreg_name.c +refreg_name_OBJECTS = refreg_name.$(OBJEXT) +refreg_name_LDADD = $(LDADD) +refreg_name_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1) reserved_SOURCES = reserved.c reserved_OBJECTS = reserved.$(OBJEXT) reserved_LDADD = $(LDADD) @@ -340,8 +345,8 @@ SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c \ gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \ gen_new_super.c gen_noencoder.c gen_nullspace.c gen_udlinks.c \ getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c \ - mtime.c ntypes.c objcopy.c ohdr.c pool.c ref.c reserved.c \ - set_extent.c space_overflow.c stab.c stream_test.c \ + mtime.c ntypes.c objcopy.c ohdr.c pool.c ref.c refreg_name.c \ + reserved.c set_extent.c space_overflow.c stab.c stream_test.c \ $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \ vfd.c DIST_SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c \ @@ -352,8 +357,8 @@ DIST_SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c \ gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \ gen_new_super.c gen_noencoder.c gen_nullspace.c gen_udlinks.c \ getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c \ - mtime.c ntypes.c objcopy.c ohdr.c pool.c ref.c reserved.c \ - set_extent.c space_overflow.c stab.c stream_test.c \ + mtime.c ntypes.c objcopy.c ohdr.c pool.c ref.c refreg_name.c \ + reserved.c set_extent.c space_overflow.c stab.c stream_test.c \ $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \ vfd.c ETAGS = etags @@ -616,7 +621,8 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 \ err_compat.h5 dtransform.h5 test_filters.h5 get_file_name.h5 \ tstint[1-2].h5 unlink_chunked.h5 btree2.h5 objcopy_src.h5 \ - objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5 + objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5 \ + refreg_name.h5 INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src # Test script for error_test and err_compat @@ -636,7 +642,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api \ dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \ fillval mount flush1 flush2 enum \ set_extent ttsafe stream_test \ - getname ref vfd ntypes dangle dtransform reserved cross_read \ + getname ref refreg_name vfd ntypes dangle dtransform reserved cross_read \ btree2 fheap @@ -882,6 +888,9 @@ pool$(EXEEXT): $(pool_OBJECTS) $(pool_DEPENDENCIES) ref$(EXEEXT): $(ref_OBJECTS) $(ref_DEPENDENCIES) @rm -f ref$(EXEEXT) $(LINK) $(ref_LDFLAGS) $(ref_OBJECTS) $(ref_LDADD) $(LIBS) +refreg_name$(EXEEXT): $(refreg_name_OBJECTS) $(refreg_name_DEPENDENCIES) + @rm -f refreg_name$(EXEEXT) + $(LINK) $(refreg_name_LDFLAGS) $(refreg_name_OBJECTS) $(refreg_name_LDADD) $(LIBS) reserved$(EXEEXT): $(reserved_OBJECTS) $(reserved_DEPENDENCIES) @rm -f reserved$(EXEEXT) $(LINK) $(reserved_LDFLAGS) $(reserved_OBJECTS) $(reserved_LDADD) $(LIBS) @@ -966,6 +975,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ohdr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ref.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refreg_name.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reserved.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_extent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/space_overflow.Po@am__quote@ diff --git a/test/refreg_name.c b/test/refreg_name.c new file mode 100644 index 0000000..ac41857 --- /dev/null +++ b/test/refreg_name.c @@ -0,0 +1,170 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group (THG) and * + * The Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://www.hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include "h5test.h" + +#define filename "refreg_name.h5" +#define dsetnamev "MATRIX" +#define dsetnamer "REGION_REFERENCES" + +static int basic_test(void) +{ + hid_t file_id; /* file identifier */ + hid_t dsetv_id; /*dataset identifiers*/ + hid_t dsetr_id; + hid_t space_id, spacer_id; + hsize_t dims[2] = {2,9}; + hsize_t dimsr[1] = {2}; + int rank = 2; + int rankr =1; + herr_t status; + hdset_reg_ref_t ref[2]; + hdset_reg_ref_t ref_out[2]; + int data[2][9] = {{1,1,2,3,3,4,5,5,6},{1,2,2,3,4,4,5,6,6}}; + hsize_t start[2]; + hsize_t count[2]; + hsize_t coord[2][3] = {{0, 0, 1}, {6, 0, 8}}; + unsigned num_points = 3; + size_t name_size1, name_size2; + char buf1[10], buf2[10]; + + /* Create file with default file access and file creation properties */ + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Create dataspace for datasets */ + if((space_id = H5Screate_simple(rank, dims, NULL)) < 0) + TEST_ERROR + if((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) + TEST_ERROR + + /* Create integer dataset */ + if((dsetv_id = H5Dcreate(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Write data to the dataset */ + if((status = H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data)) < 0) + TEST_ERROR + if((status = H5Dclose(dsetv_id)) < 0) + TEST_ERROR + + /* Dataset with references */ + if((dsetr_id = H5Dcreate(file_id, dsetnamer, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* + * Create a reference to the hyperslab. + */ + start[0] = 0; + start[1] = 3; + count[0] = 2; + count[1] = 3; + if((status = H5Sselect_hyperslab(space_id,H5S_SELECT_SET,start,NULL,count,NULL)) < 0) + TEST_ERROR + if((status = H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id)) < 0) + TEST_ERROR + + /* Create a reference to elements selection */ + if((status = H5Sselect_none(space_id)) < 0) + TEST_ERROR + if((status = H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t **)coord)) < 0) + TEST_ERROR + if((status = H5Rcreate(&ref[1], file_id, dsetnamev, H5R_DATASET_REGION, space_id)) < 0) + TEST_ERROR + + /* Write dataset with the references */ + if((status = H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref)) < 0) + TEST_ERROR + + /* Close all objects */ + if((status = H5Sclose(space_id)) < 0) + TEST_ERROR + if((status = H5Sclose(spacer_id)) < 0) + TEST_ERROR + if((status = H5Dclose(dsetr_id)) < 0) + TEST_ERROR + if((status = H5Fclose(file_id)) < 0) + TEST_ERROR + + /* Reopen the file to read selections back */ + if((file_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Reopen the dataset with object references and read references to the buffer */ + if((dsetr_id = H5Dopen (file_id, dsetnamer)) , 0) + TEST_ERROR + + if((status = H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_out)) < 0) + TEST_ERROR + + /* Dereference the first reference */ + dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[0]); + + /* Get name of the dataset the first region reference points to using H5Rget_name */ + + TESTING("H5Rget_name to get name from region reference (hyperslab)"); + name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char*)buf1, 10); +/* if(!((HDstrcmp(buf1, "/MATRIX") == 0) && (name_size1 == 8))) TEST_ERROR + PASSED()*/ + SKIPPED() + + /* Get name of the dataset the first region reference points using H5Iget_name */ + + TESTING("H5Iget_name to get name from region reference (hyperslab)"); + name_size2 = H5Iget_name(dsetv_id, (char*)buf2, 10); + if(!((HDstrcmp(buf2, "/MATRIX") == 0) && (name_size2 == 8))) TEST_ERROR + PASSED() + + if((status = H5Dclose(dsetv_id)) < 0) + TEST_ERROR + + /* Dereference the second reference */ + if((dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[1])) < 0) + TEST_ERROR + + TESTING("H5Rget_name to get name from region reference (pnt selec)"); + name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[1], (char*)buf1, 10); +/* if(!((HDstrcmp(buf1, "/MATRIX") == 0) && (name_size1 == 8))) TEST_ERROR + PASSED() */ + SKIPPED() + + /* Get name of the dataset the first region reference points using H5Iget_name */ + + TESTING("H5Iget_name to get name from region reference (pnt selec)"); + name_size2 = H5Iget_name(dsetv_id, (char*)buf2, 10); + if(!((HDstrcmp(buf2, "/MATRIX") == 0) && (name_size2 == 8))) TEST_ERROR + PASSED() + + if((status = H5Dclose(dsetv_id)) < 0) + TEST_ERROR + + if((status = H5Dclose(dsetr_id)) < 0) + TEST_ERROR + if((status = H5Fclose(file_id)) < 0) + TEST_ERROR + + return 0; + + +error: + return -1; +} + +void main(void) +{ + basic_test(); +} + + + |