summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST2
-rw-r--r--src/H5R.c27
-rw-r--r--test/Makefile.am5
-rw-r--r--test/Makefile.in32
-rw-r--r--test/getname.c562
-rw-r--r--test/ref.c301
-rw-r--r--test/refreg_name.c183
7 files changed, 532 insertions, 580 deletions
diff --git a/MANIFEST b/MANIFEST
index 1b01ea9..c4a05c4 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -749,8 +749,6 @@
./test/ntypes.c
./test/ohdr.c
./test/objcopy.c
-./test/ref.c
-./test/refreg_name.c
./test/reserved.c
./test/pool.c
./test/set_extent.c
diff --git a/src/H5R.c b/src/H5R.c
index e355dee..d2b75fe 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -211,11 +211,11 @@ H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5
if(NULL == (buf = H5MM_malloc((size_t)buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- /* Serialize information for dataset OID */
+ /* Serialize information for dataset OID into heap buffer */
p = (uint8_t *)buf;
H5F_addr_encode(loc->oloc->file, &p, obj_loc.oloc->addr);
- /* Serialize the selection */
+ /* Serialize the selection into heap buffer */
if(H5S_SELECT_SERIALIZE(space, p) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection")
@@ -829,15 +829,26 @@ H5R_get_name(H5F_t *f, hid_t dxpl_id, hid_t id, H5R_type_t ref_type,
case H5R_DATASET_REGION:
{
- const uint8_t *p; /* Pointer to reference to decode */
+ const hdset_reg_ref_t *ref = (const hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */
+ H5HG_t hobjid; /* Heap object ID */
+ uint8_t *buf; /* Buffer to store serialized selection in */
+ const uint8_t *p; /* Pointer to OID to store */
- /* Skip over the heap ID for the dataset region */
- p = (const uint8_t *)_ref;
- p += H5F_SIZEOF_ADDR(f);
- p += 4;
+ /* Get the heap ID for the dataset region */
+ p = (const uint8_t *)ref;
+ H5F_addr_decode(oloc.file, &p, &(hobjid.addr));
+ INT32DECODE(p, hobjid.idx);
+
+ /* Get the dataset region from the heap (allocate inside routine) */
+ if((buf = H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information")
/* Get the object oid for the dataset */
- H5F_addr_decode(oloc.file, &p, &oloc.addr);
+ p = buf;
+ H5F_addr_decode(oloc.file, &p, &(oloc.addr));
+
+ /* Free the buffer allocated in H5HG_read() */
+ H5MM_xfree(buf);
} /* end case */
break;
diff --git a/test/Makefile.am b/test/Makefile.am
index 031a629..c290b8e 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 refreg_name vfd ntypes dangle dtransform reserved cross_read \
+ getname vfd ntypes dangle dtransform reserved cross_read \
btree2 fheap
# List programs to be built when testing here. error_test and err_compat are
@@ -116,8 +116,7 @@ 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\
- refreg_name.h5
+ objcopy_src.h5 objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.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 f0d9930..7e6dbea 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -80,8 +80,7 @@ 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) refreg_name$(EXEEXT) \
- vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \
+ getname$(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) \
@@ -268,14 +267,6 @@ pool_SOURCES = pool.c
pool_OBJECTS = pool.$(OBJEXT)
pool_LDADD = $(LDADD)
pool_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1)
-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)
@@ -345,8 +336,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 refreg_name.c \
- reserved.c set_extent.c space_overflow.c stab.c stream_test.c \
+ mtime.c ntypes.c objcopy.c ohdr.c pool.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 \
@@ -357,8 +348,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 refreg_name.c \
- reserved.c set_extent.c space_overflow.c stab.c stream_test.c \
+ mtime.c ntypes.c objcopy.c ohdr.c pool.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
@@ -621,8 +612,7 @@ 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 \
- refreg_name.h5
+ objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5
INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src
# Test script for error_test and err_compat
@@ -642,7 +632,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 refreg_name vfd ntypes dangle dtransform reserved cross_read \
+ getname vfd ntypes dangle dtransform reserved cross_read \
btree2 fheap
@@ -885,12 +875,6 @@ ohdr$(EXEEXT): $(ohdr_OBJECTS) $(ohdr_DEPENDENCIES)
pool$(EXEEXT): $(pool_OBJECTS) $(pool_DEPENDENCIES)
@rm -f pool$(EXEEXT)
$(LINK) $(pool_LDFLAGS) $(pool_OBJECTS) $(pool_LDADD) $(LIBS)
-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)
@@ -974,8 +958,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/objcopy.Po@am__quote@
@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/getname.c b/test/getname.c
index 5a6c176..ff8eebc 100644
--- a/test/getname.c
+++ b/test/getname.c
@@ -43,13 +43,17 @@ const char *FILENAME[] = {
NULL
};
-#define RANK 2
-#define NX 4
-#define NY 5
-
#define NAME_BUF_SIZE 64
#define SMALL_NAME_BUF_SIZE 2
+/* Object reference macros */
+#define SPACE1_RANK 1
+#define SPACE1_DIM1 8
+
+/* Dataset region reference macros */
+#define REFREG_DSETNAMEV "MATRIX"
+#define REFREG_DSETNAMER "REGION_REFERENCES"
+
static int
check_name(hid_t id, const char *chk_name, const char *chk_user_path)
{
@@ -83,43 +87,26 @@ error:
return -1;
}
-int main( void )
+static int
+test_main(hid_t file_id, hid_t fapl)
{
- char filename0[1024];
- char filename1[1024];
- char filename2[1024];
- char filename3[1024];
- hid_t fapl;
- hid_t file_id, file1_id, file2_id, file3_id;
- hid_t group_id, group2_id, group3_id, group4_id, group5_id, group6_id, group7_id;
- hid_t dataset_id, dataset2_id;
- hid_t space_id;
- hid_t type_id, type2_id;
- hsize_t dims[1] = { 5 };
- const char *envval = NULL;
-
- envval = HDgetenv("HDF5_DRIVER");
- if (envval == NULL)
- envval = "nomatch";
- if (HDstrcmp(envval, "split")) {
- /* Name length */
- size_t name_len;
-
- /* Reset the library and get the file access property list */
- h5_reset();
- fapl = h5_fileaccess();
+ char filename1[1024];
+ char filename2[1024];
+ char filename3[1024];
+ hid_t file1_id, file2_id, file3_id;
+ hid_t group_id, group2_id, group3_id, group4_id, group5_id, group6_id, group7_id;
+ hid_t dataset_id, dataset2_id;
+ hid_t space_id;
+ hid_t type_id, type2_id;
+ hsize_t dims[1] = { 5 };
+ size_t name_len; /* Name length */
/* Initialize the file names */
- h5_fixname(FILENAME[0], fapl, filename0, sizeof filename0);
h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1);
h5_fixname(FILENAME[2], fapl, filename2, sizeof filename2);
h5_fixname(FILENAME[3], fapl, filename3, sizeof filename3);
- /* Create a new file_id using default properties. */
- if ((file_id = H5Fcreate( filename0, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR;
-
-
-/*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* Test H5Iget_name with H5Gcreate, one group
*-------------------------------------------------------------------------
*/
@@ -139,7 +126,7 @@ int main( void )
-/*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* Test H5Iget_name with H5Gcreate, more than one group
*-------------------------------------------------------------------------
*/
@@ -164,7 +151,7 @@ int main( void )
PASSED();
-/*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* Test H5Iget_name with H5Gopen
*-------------------------------------------------------------------------
*/
@@ -192,7 +179,7 @@ int main( void )
-/*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* Test H5Iget_name with H5Dcreate
*-------------------------------------------------------------------------
*/
@@ -229,7 +216,7 @@ int main( void )
-/*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* Test H5Iget_name with H5Dopen
*-------------------------------------------------------------------------
*/
@@ -1237,12 +1224,12 @@ PASSED();
/* Get name for non commited datatype, it should fail */
H5E_BEGIN_TRY {
- if(H5Iget_name( type_id, name, NAME_BUF_SIZE) > 0) TEST_ERROR;
+ if(H5Iget_name( type_id, name, NAME_BUF_SIZE) > 0) TEST_ERROR;
} H5E_END_TRY;
/* Get name for dataspace, it should fail */
H5E_BEGIN_TRY {
- if(H5Iget_name( space_id, name, NAME_BUF_SIZE) > 0) TEST_ERROR;
+ if(H5Iget_name( space_id, name, NAME_BUF_SIZE) > 0) TEST_ERROR;
} H5E_END_TRY;
}
@@ -2368,26 +2355,485 @@ PASSED();
PASSED();
- /*-------------------------------------------------------------------------
- * end tests
- *-------------------------------------------------------------------------
- */
+ return(0);
+
+error:
+ return(1);
+}
+
+static int
+test_obj_ref(hid_t fapl)
+{
+ char filename1[1024];
+ char filename2[1024];
+ hid_t fid1, fid2; /* HDF5 File IDs */
+ hid_t dataset, dataset2; /* Dataset ID */
+ hid_t group, group2; /* Group ID */
+ hid_t sid1; /* Dataspace ID */
+ hid_t tid1; /* Datatype ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ hobj_ref_t wbuf[SPACE1_DIM1]; /* Buffer to write to disk */
+ int tu32[SPACE1_DIM1]; /* Int data */
+ int i; /* counting variables */
+ char buf[100];
+ /* Initialize the file names */
+ h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[2], fapl, filename2, sizeof filename2);
+
+ /* Create files */
+ if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+ if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Create dataspace for datasets */
+ if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0)
+ TEST_ERROR
+
+ /* Create a group */
+ if((group = H5Gcreate(fid1, "Group1", (size_t)0)) < 0)
+ TEST_ERROR
+
+ /* Create a single dataset inside the second file, which will be mounted
+ * and used to mask objects in the first file */
+ if((dataset = H5Dcreate(fid2, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dclose(dataset) < 0)
+ TEST_ERROR
+
+ /* Create a dataset (inside Group1) */
+ if((dataset = H5Dcreate(group, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Initialize data buffer */
+ for(i = 0; i < SPACE1_DIM1; i++)
+ tu32[i] = i * 3;
+
+ /* Write selection to disk */
+ if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, tu32) < 0)
+ TEST_ERROR
+
+ /* Close Dataset */
+ if(H5Dclose(dataset) < 0)
+ TEST_ERROR
+
+ /* Create another dataset (inside Group1) */
+ if((dataset = H5Dcreate(group, "Dataset2", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Close Dataset */
+ if(H5Dclose(dataset) < 0)
+ TEST_ERROR
+
+ /* Create a datatype to refer to */
+ if((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0)
+ TEST_ERROR
+ /* Insert fields */
+ if(H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT) < 0)
+ TEST_ERROR
+ if(H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT) < 0)
+ TEST_ERROR
+ if(H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT) < 0)
+ TEST_ERROR
+
+ /* Save datatype for later */
+ if(H5Tcommit(group, "Datatype1", tid1) < 0)
+ TEST_ERROR
+
+ /* Close datatype */
+ if(H5Tclose(tid1) < 0)
+ TEST_ERROR
+
+ /* Create a new group in group1 */
+ if((group2 = H5Gcreate(group, "Group2", (size_t)0)) < 0)
+ TEST_ERROR
+
+ /* Create a hard link to group1 in group2 */
+ if(H5Glink(fid1, H5G_LINK_HARD, "/Group1", "/Group1/Group2/Link") < 0)
+ TEST_ERROR
+
+ /* Create dataset in that group */
+ if((dataset = H5Dcreate(group2, "Dataset4", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Close Dataset */
+ if(H5Dclose(dataset) < 0)
+ TEST_ERROR
+
+ /* Close group */
+ if(H5Gclose(group) < 0)
+ TEST_ERROR
+ if(H5Gclose(group2) < 0)
+ TEST_ERROR
+
+ /* Open up that hard link and make a new dataset there */
+ if((group = H5Gopen(fid1, "/Group1/Group2/Link")) < 0)
+ TEST_ERROR
+ if((dataset = H5Dcreate(group, "Dataset5", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ if(H5Dclose(dataset) < 0)
+ TEST_ERROR
+ if(H5Gclose(group) < 0)
+ TEST_ERROR
+
+
+ /* Create a dataset to store references */
+ if((dataset = H5Dcreate(fid1, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Create reference to dataset */
+ if(H5Rcreate(&wbuf[0], fid1, "/Dataset3", H5R_OBJECT, -1) < 0)
+ TEST_ERROR
+
+ /* Create reference to dataset */
+ if(H5Rcreate(&wbuf[1], fid1, "/Group1/Dataset2", H5R_OBJECT, -1) < 0)
+ TEST_ERROR
+
+ /* Create reference to group */
+ if(H5Rcreate(&wbuf[2], fid1, "/Group1", H5R_OBJECT, -1) < 0)
+ TEST_ERROR
+
+ /* Create reference to named datatype */
+ if(H5Rcreate(&wbuf[3], fid1, "/Group1/Datatype1", H5R_OBJECT, -1) < 0)
+ TEST_ERROR
+
+ if(H5Rcreate(&wbuf[4], fid1, "/Group1/Group2/Dataset4", H5R_OBJECT, -1) < 0)
+ TEST_ERROR
+ if(H5Rcreate(&wbuf[5], fid1, "/Group1/Group2", H5R_OBJECT, -1) < 0)
+ TEST_ERROR
+ if(H5Rcreate(&wbuf[6], fid1, "/Group1/Group2/Link/Dataset5", H5R_OBJECT, -1) < 0)
+ TEST_ERROR
+
+ /* Create reference to root group */
+ if(H5Rcreate(&wbuf[7], fid1, "/", H5R_OBJECT, -1) < 0)
+ TEST_ERROR
+
+ /* Write selection to disk */
+ if(H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0)
+ TEST_ERROR
+
+ TESTING("getting path to normal dataset in root group");
+ if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[0])) < 0) TEST_ERROR
+ i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
+ if(H5Dclose(dataset2) < 0) TEST_ERROR
+ if(!((HDstrcmp(buf, "/Dataset3") == 0) && (i == 10))) TEST_ERROR
+ i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0], (char*)buf, sizeof(buf));
+ if(!((HDstrcmp(buf, "/Dataset3") == 0) && (i == 10))) TEST_ERROR
+ PASSED()
+
+ HDmemset(buf, 0, sizeof(buf));
+ TESTING("getting path to dataset in /Group1");
+ if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[1])) < 0) TEST_ERROR
+ i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
+ if(H5Dclose(dataset2) < 0) TEST_ERROR
+ if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) && (i == 17))) TEST_ERROR
+ i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf));
+ if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) && (i == 17))) TEST_ERROR
+ PASSED()
+
+ HDmemset(buf, 0, sizeof(buf));
+ TESTING("getting path to /Group1");
+ if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[2])) < 0) TEST_ERROR
+ i = H5Iget_name(group, (char*)buf, sizeof(buf));
+ if(H5Gclose(group) < 0) TEST_ERROR
+ if(!((HDstrcmp(buf, "/Group1") == 0) && (i == 8))) TEST_ERROR
+ i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[2], (char*)buf, sizeof(buf));
+ if(!((HDstrcmp(buf, "/Group1") == 0) && (i == 8))) TEST_ERROR
+ PASSED()
+
+ HDmemset(buf, 0, sizeof(buf));
+ TESTING("getting path to datatype in /Group1");
+ if((tid1 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[3])) < 0) TEST_ERROR
+ i = H5Iget_name(tid1, (char*)buf, sizeof(buf));
+ if(H5Tclose(tid1) < 0) TEST_ERROR
+ if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) && (i == 18))) TEST_ERROR
+ i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[3], (char*)buf, sizeof(buf));
+ if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) && (i == 18))) TEST_ERROR
+ PASSED()
+
+ HDmemset(buf, 0, sizeof(buf));
+ TESTING("getting path to dataset in nested group");
+ if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[4])) < 0) TEST_ERROR
+ i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
+ if(H5Dclose(dataset2) < 0) TEST_ERROR
+ if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) && (i == 24))) TEST_ERROR
+ i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, sizeof(buf));
+ if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) && (i == 24))) TEST_ERROR
+ PASSED()
+
+ HDmemset(buf, 0, sizeof(buf));
+ TESTING("getting path to nested group");
+ if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[5])) < 0) TEST_ERROR
+ i = H5Iget_name(group, (char*)buf, sizeof(buf));
+ if(H5Gclose(group) < 0) TEST_ERROR
+ if(!((HDstrcmp(buf, "/Group1/Group2") == 0) && (i == 15))) TEST_ERROR
+ i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[5], (char*)buf, sizeof(buf));
+ if(!((HDstrcmp(buf, "/Group1/Group2") == 0) && (i == 15))) TEST_ERROR
+ PASSED()
+
+ HDmemset(buf, 0, sizeof(buf));
+ TESTING("getting path to dataset created via hard link");
+ if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[6])) < 0) TEST_ERROR
+ i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
+ if(H5Dclose(dataset2) < 0) TEST_ERROR
+ if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) && (i == 17))) TEST_ERROR
+ i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[6], (char*)buf, sizeof(buf));
+ if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) && (i == 17))) TEST_ERROR
+ PASSED()
+
+ HDmemset(buf, 0, sizeof(buf));
+ TESTING("getting path to root group");
+ if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[7])) < 0) TEST_ERROR
+ i = H5Iget_name(group, (char*)buf, sizeof(buf));
+ if(H5Gclose(group) < 0) TEST_ERROR
+ if(!((HDstrcmp(buf, "/") == 0) && (i == 2))) TEST_ERROR
+ i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[7], (char*)buf, sizeof(buf));
+ if(!((HDstrcmp(buf, "/") == 0) && (i == 2))) TEST_ERROR
+ PASSED()
+
+ /* Now we mount fid2 at /Group2 and look for dataset4. It shouldn't be found */
+ if(H5Fmount(fid1, "/Group1/Group2", fid2, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ TESTING("getting path to dataset hidden by a mounted file");
+ if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[4])) < 0) TEST_ERROR
+ i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
+ if(H5Dclose(dataset2) < 0) TEST_ERROR
+ if(i != 0) TEST_ERROR
+ i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, sizeof(buf));
+ if(i != 0) TEST_ERROR
+ PASSED()
+
+ /* Now we try unlinking dataset2 from the file and searching for it. It shouldn't be found */
+ if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[1])) < 0)
+ TEST_ERROR
+ if(H5Gunlink(fid1, "/Group1/Dataset2") < 0)
+ TEST_ERROR
+
+ TESTING("getting path to dataset that has been unlinked");
+ i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
+ if(H5Dclose(dataset2) < 0) TEST_ERROR
+ if(i != 0) TEST_ERROR
+ i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf));
+ if(i != 0) TEST_ERROR
+ PASSED()
+
+ /* Close disk dataspace */
+ if(H5Sclose(sid1) < 0)
+ TEST_ERROR
+
+ /* Close Dataset */
+ if(H5Dclose(dataset) < 0)
+ TEST_ERROR
+
/* Close file */
- H5Fclose( file_id );
- puts("All getname tests passed.");
- h5_cleanup(FILENAME, fapl);
- }
- else
- {
- puts("All getname tests skipped - Incompatible with current Virtual File Driver");
- }
- return 0;
-
- error:
- H5Fclose( file_id );
- H5_FAILED();
- return 1;
+ if(H5Fclose(fid1) < 0)
+ TEST_ERROR
+ if(H5Fclose(fid2) < 0)
+ TEST_ERROR
+
+ return 0;
+
+error:
+ return 1;
+}
+
+static int
+test_reg_ref(hid_t fapl)
+{
+ char filename1[1024];
+ 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[NAME_BUF_SIZE], buf2[NAME_BUF_SIZE];
+
+ /* Initialize the file name */
+ h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1);
+
+ /* Create file with default file access and file creation properties */
+ if((file_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 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, REFREG_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, REFREG_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, REFREG_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, REFREG_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(filename1, 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, REFREG_DSETNAMER)) , 0)
+ TEST_ERROR
+
+ if((status = H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_out)) < 0)
+ TEST_ERROR
+
+ /* 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, NAME_BUF_SIZE);
+ if(!((HDstrcmp(buf1, "/MATRIX") == 0) && (name_size1 == 8))) TEST_ERROR
+ PASSED()
+
+ TESTING("H5Iget_name to get name from region reference (hyperslab)");
+
+ /* 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 using H5Iget_name */
+ name_size2 = H5Iget_name(dsetv_id, (char*)buf2, NAME_BUF_SIZE);
+ if(!((HDstrcmp(buf2, "/MATRIX") == 0) && (name_size2 == 8))) TEST_ERROR
+
+ if((status = H5Dclose(dsetv_id)) < 0) TEST_ERROR
+
+ PASSED()
+
+ /* Get name of the dataset the second region reference points to using H5Rget_name */
+ 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, NAME_BUF_SIZE);
+ if(!((HDstrcmp(buf1, "/MATRIX") == 0) && (name_size1 == 8))) TEST_ERROR
+ PASSED()
+
+ TESTING("H5Iget_name to get name from region reference (pnt selec)");
+
+ /* Dereference the second reference */
+ if((dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[1])) < 0) TEST_ERROR
+
+ /* Get name of the dataset the first region reference points using H5Iget_name */
+ name_size2 = H5Iget_name(dsetv_id, (char*)buf2, NAME_BUF_SIZE);
+ if(!((HDstrcmp(buf2, "/MATRIX") == 0) && (name_size2 == 8))) TEST_ERROR
+
+ if((status = H5Dclose(dsetv_id)) < 0) TEST_ERROR
+
+ PASSED()
+
+ if((status = H5Dclose(dsetr_id)) < 0)
+ TEST_ERROR
+ if((status = H5Fclose(file_id)) < 0)
+ TEST_ERROR
+
+ return 0;
+
+error:
+ return 1;
+}
+
+int
+main(void)
+{
+ hid_t file_id = (-1);
+ const char *envval;
+
+ envval = HDgetenv("HDF5_DRIVER");
+ if(envval == NULL)
+ envval = "nomatch";
+ if(HDstrcmp(envval, "split")) {
+ int nerrors = 0;
+ hid_t fapl;
+ char filename0[1024];
+
+ /* Reset the library and get the file access property list */
+ h5_reset();
+ fapl = h5_fileaccess();
+ h5_fixname(FILENAME[0], fapl, filename0, sizeof filename0);
+
+ /* Create a new file_id using default properties. */
+ if((file_id = H5Fcreate(filename0,H5F_ACC_TRUNC, H5P_DEFAULT, fapl )) < 0) TEST_ERROR
+
+ /* Call "main" test routine */
+ nerrors += test_main(file_id, fapl);
+ nerrors += test_obj_ref(fapl);
+ nerrors += test_reg_ref(fapl);
+
+ /* Close file */
+ H5Fclose(file_id);
+
+ if(nerrors)
+ goto error;
+ puts("All getname tests passed.");
+
+ h5_cleanup(FILENAME, fapl);
+ } /* end if */
+ else
+ puts("All getname tests skipped - Incompatible with current Virtual File Driver");
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file_id);
+ } H5E_END_TRY;
+
+ puts("***** GET NAME TESTS FAILED *****");
+
+ return 1;
}
diff --git a/test/ref.c b/test/ref.c
deleted file mode 100644
index 290879b..0000000
--- a/test/ref.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-#include "h5test.h"
-
-/* The file structure tested is as follows:
- * /
- * Group1
- * Dataset1
- * Dataset2
- * Group2
- * Dataset4
- * Hard link to group1
- * Dataset5
- * Datatype1
- *
- * The purpose of the hard link to make sure that the reference lookup code
- * does not infinite loop when looking for Dataset3.
- */
-
-#define FILE1 "trefer1.h5"
-#define FILE2 "trefer2.h5"
-
-/* 1-D dataset with fixed dimensions */
-#define SPACE1_RANK 1
-#define SPACE1_DIM1 8
-
-int
-main(void)
-{
- hid_t fid1, fid2; /* HDF5 File IDs */
- hid_t dataset; /* Dataset ID */
- hid_t group, group2; /* Group ID */
- hid_t sid1; /* Dataspace ID */
- hid_t tid1; /* Datatype ID */
- hid_t ref;
- hsize_t dims1[] = {SPACE1_DIM1};
- hobj_ref_t wbuf[SPACE1_DIM1]; /* Buffer to write to disk */
- int tu32[SPACE1_DIM1]; /* Int data */
- int i; /* counting variables */
- char buf[100];
-
- /* Compound datatype */
- typedef struct s1_t {
- unsigned int a;
- unsigned int b;
- float c;
- } s1_t;
-
- /* Create files */
- if((fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- TEST_ERROR
- if((fid2 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- TEST_ERROR
-
- /* Create dataspace for datasets */
- if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0)
- TEST_ERROR
-
- /* Create a group */
- if((group = H5Gcreate(fid1, "Group1", (size_t)0)) < 0)
- TEST_ERROR
-
- /* Create a single dataset inside the second file, which will be mounted
- * and used to mask objects in the first file */
- if((dataset = H5Dcreate(fid2, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT)) < 0)
- TEST_ERROR
- if(H5Dclose(dataset) < 0)
- TEST_ERROR
-
- /* Create a dataset (inside Group1) */
- if((dataset = H5Dcreate(group, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT)) < 0)
- TEST_ERROR
-
- /* Initialize data buffer */
- for(i = 0; i < SPACE1_DIM1; i++)
- tu32[i] = i * 3;
-
- /* Write selection to disk */
- if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, tu32) < 0)
- TEST_ERROR
-
- /* Close Dataset */
- if(H5Dclose(dataset) < 0)
- TEST_ERROR
-
- /* Create another dataset (inside Group1) */
- if((dataset = H5Dcreate(group, "Dataset2", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT)) < 0)
- TEST_ERROR
-
- /* Close Dataset */
- if(H5Dclose(dataset) < 0)
- TEST_ERROR
-
- /* Create a datatype to refer to */
- if((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0)
- TEST_ERROR
-
- /* Insert fields */
- if(H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT) < 0)
- TEST_ERROR
- if(H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT) < 0)
- TEST_ERROR
- if(H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT) < 0)
- TEST_ERROR
-
- /* Save datatype for later */
- if(H5Tcommit(group, "Datatype1", tid1) < 0)
- TEST_ERROR
-
- /* Close datatype */
- if(H5Tclose(tid1) < 0)
- TEST_ERROR
-
- /* Create a new group in group1 */
- if((group2 = H5Gcreate(group, "Group2", (size_t)0)) < 0)
- TEST_ERROR
-
- /* Create a hard link to group1 in group2 */
- if(H5Glink(fid1, H5G_LINK_HARD, "/Group1", "/Group1/Group2/Link") < 0)
- TEST_ERROR
-
- /* Create dataset in that group */
- if((dataset = H5Dcreate(group2, "Dataset4", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT)) < 0)
- TEST_ERROR
-
- /* Close Dataset */
- if(H5Dclose(dataset) < 0)
- TEST_ERROR
-
- /* Close group */
- if(H5Gclose(group) < 0)
- TEST_ERROR
- if(H5Gclose(group2) < 0)
- TEST_ERROR
-
- /* Open up that hard link and make a new dataset there */
- if((group = H5Gopen(fid1, "/Group1/Group2/Link")) < 0)
- TEST_ERROR
- if((dataset = H5Dcreate(group, "Dataset5", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT)) < 0)
- TEST_ERROR
-
- if(H5Dclose(dataset) < 0)
- TEST_ERROR
- if(H5Gclose(group) < 0)
- TEST_ERROR
-
-
- /* Create a dataset to store references */
- if((dataset = H5Dcreate(fid1, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT)) < 0)
- TEST_ERROR
-
- /* Create reference to dataset */
- if(H5Rcreate(&wbuf[0], fid1, "/Dataset3", H5R_OBJECT, -1) < 0)
- TEST_ERROR
-
- /* Create reference to dataset */
- if(H5Rcreate(&wbuf[1], fid1, "/Group1/Dataset2", H5R_OBJECT, -1) < 0)
- TEST_ERROR
-
- /* Create reference to group */
- if(H5Rcreate(&wbuf[2], fid1, "/Group1", H5R_OBJECT, -1) < 0)
- TEST_ERROR
-
- /* Create reference to named datatype */
- if(H5Rcreate(&wbuf[3], fid1, "/Group1/Datatype1", H5R_OBJECT, -1) < 0)
- TEST_ERROR
-
- if(H5Rcreate(&wbuf[4], fid1, "/Group1/Group2/Dataset4", H5R_OBJECT, -1) < 0)
- TEST_ERROR
- if(H5Rcreate(&wbuf[5], fid1, "/Group1/Group2", H5R_OBJECT, -1) < 0)
- TEST_ERROR
- if(H5Rcreate(&wbuf[6], fid1, "/Group1/Group2/Link/Dataset5", H5R_OBJECT, -1) < 0)
- TEST_ERROR
-
- /* Create reference to root group */
- if(H5Rcreate(&wbuf[7], fid1, "/", H5R_OBJECT, -1) < 0)
- TEST_ERROR
-
- /* Write selection to disk */
- if(H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0)
- TEST_ERROR
-
- TESTING("getting path to normal dataset in root group");
- i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT, &wbuf[0]), (char*)buf, (size_t)100);
- if(!((HDstrcmp(buf, "/Dataset3") == 0) && (i == 10))) TEST_ERROR
- i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0], (char*)buf, (size_t)100);
- if(!((HDstrcmp(buf, "/Dataset3") == 0) && (i == 10))) TEST_ERROR
- PASSED()
-
- HDmemset(buf, 0, (size_t)100);
- TESTING("getting path to dataset in /Group1");
- i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT, &wbuf[1]), (char*)buf, (size_t)100);
- if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) && (i == 17))) TEST_ERROR
- i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, (size_t)100);
- if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) && (i == 17))) TEST_ERROR
- PASSED()
-
- HDmemset(buf, 0, (size_t)100);
- TESTING("getting path to /Group1");
- i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT, &wbuf[2]), (char*)buf, 100);
- if(!((HDstrcmp(buf, "/Group1") == 0) && (i == 8))) TEST_ERROR
- i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[2], (char*)buf, 100);
- if(!((HDstrcmp(buf, "/Group1") == 0) && (i == 8))) TEST_ERROR
- PASSED()
-
- HDmemset(buf, 0, 100);
- TESTING("getting path to datatype in /Group1");
- i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT , &wbuf[3]), (char*)buf, 100);
- if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) && (i == 18))) TEST_ERROR
- i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[3], (char*)buf, 100);
- if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) && (i == 18))) TEST_ERROR
- PASSED()
-
- HDmemset(buf, 0, 100);
- TESTING("getting path to dataset in nested group");
- i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT , &wbuf[4]), (char*)buf, 100);
- if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) && (i == 24))) TEST_ERROR
- i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, 100);
- if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) && (i == 24))) TEST_ERROR
- PASSED()
-
- HDmemset(buf, 0, 100);
- TESTING("getting path to nested group");
- i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT, &wbuf[5]), (char*)buf, 100);
- if(!((HDstrcmp(buf, "/Group1/Group2") == 0) && (i == 15))) TEST_ERROR
- i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[5], (char*)buf, 100);
- if(!((HDstrcmp(buf, "/Group1/Group2") == 0) && (i == 15))) TEST_ERROR
- PASSED()
-
- HDmemset(buf, 0, 100);
- TESTING("getting path to dataset created via hard link");
- i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT, &wbuf[6]), (char*)buf, 100);
- if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) && (i == 17))) TEST_ERROR
- i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[6], (char*)buf, 100);
- if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) && (i == 17))) TEST_ERROR
- PASSED()
-
- HDmemset(buf, 0, 100);
- TESTING("getting path to root group");
- i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT, &wbuf[7]), (char*)buf, 100);
- if(!((HDstrcmp(buf, "/") == 0) && (i == 2))) TEST_ERROR
- i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[7], (char*)buf, 100);
- if(!((HDstrcmp(buf, "/") == 0) && (i == 2))) TEST_ERROR
- PASSED()
-
- /* Now we mount fid2 at /Group2 and look for dataset4. It shouldn't be found */
- if(H5Fmount(fid1, "/Group1/Group2", fid2, H5P_DEFAULT) < 0)
- TEST_ERROR
-
- TESTING("getting path to dataset hidden by a mounted file");
- i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT, &wbuf[4]), (char*)buf, 100);
- if(i != 0) TEST_ERROR
- i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, 100);
- if(i != 0) TEST_ERROR
- PASSED()
-
- /* Now we try unlinking dataset2 from the file and searching for it. It shouldn't be found */
- if((ref = H5Rdereference(dataset, H5R_OBJECT, &wbuf[1])) < 0)
- TEST_ERROR
- if(H5Gunlink(fid1, "/Group1/Dataset2") < 0)
- TEST_ERROR
-
- TESTING("getting path to dataset that has been unlinked");
- i = H5Iget_name(ref, (char*)buf, 100);
- if(i != 0) TEST_ERROR
- i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, 100);
- if(i != 0) TEST_ERROR
- PASSED()
-
- /* Close disk dataspace */
- if(H5Sclose(sid1) < 0)
- TEST_ERROR
-
- /* Close Dataset */
- if(H5Dclose(dataset) < 0)
- TEST_ERROR
-
- /* Close file */
- if(H5Fclose(fid1) < 0)
- TEST_ERROR
- if(H5Fclose(fid2) < 0)
- TEST_ERROR
-
- return 0;
-
-error:
- return 1;
-}
-
diff --git a/test/refreg_name.c b/test/refreg_name.c
deleted file mode 100644
index 6df93b5..0000000
--- a/test/refreg_name.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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;
-}
-
-int main(void)
-{
- int nerrors=0;
- nerrors += basic_test()<0 ?1:0;
-
- if (nerrors){
- printf("***** %d Get name from region reference TEST%s FAILED! *****\n",
- nerrors, nerrors > 1 ? "S" : "");
- return 1;
- }
- printf("Get name from region reference tests passed\n");
- return 0;
-}
-
-
-