summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2016-10-17 18:44:49 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2016-10-17 18:44:49 (GMT)
commitc6e1b8f6aa46c6eb0186c16ac923761b9764b06a (patch)
treee69e3c6418447af97519e56e4054387e9eda7c1b /tools
parent394c6b8c3a4c781c1ee877f969a146cece3d7831 (diff)
parent36a85b7325767fe5de15d98419303807eb539c15 (diff)
downloadhdf5-c6e1b8f6aa46c6eb0186c16ac923761b9764b06a.zip
hdf5-c6e1b8f6aa46c6eb0186c16ac923761b9764b06a.tar.gz
hdf5-c6e1b8f6aa46c6eb0186c16ac923761b9764b06a.tar.bz2
Merge pull request #15 in HDFFV/hdf5 from ~VCHOI/my_hdf5_fork:hdf5_1_8 to hdf5_1_8
* commit '36a85b7325767fe5de15d98419303807eb539c15': Merge fix for HDFFV-7991 from trunk to 1.18 Modifications to CMakeTests.cmake according to review comments. Merge fix for HDFFV-7991 from trunk to 1.18 Missed one change that should be in previous commit. Tested on mayll, platypus, osx1010test, emu, kituo, kite, quail, moohan, ostrich. Merge fix for HDFFV-7991 from trunk to 1.18 Modifications made based on comments from pull request review. Tested on mayll, platypus, osx1010test, emu, kituo, kite, quail, moohan, ostrich. Merge fix for HDFFV-7991 from trunk to 1.18 [svn-r30308] Fix for HDFFV-7991--error when copying dataset with attribute which is a compound datatype consisting of a variable length string. Tested on mayll, platypus, osx1010test, emu, kituo, kite, quail, moohan, ostrich.
Diffstat (limited to 'tools')
-rw-r--r--tools/h5copy/CMakeTests.cmake2
-rw-r--r--tools/h5copy/h5copygentest.c119
-rw-r--r--tools/h5copy/testfiles/h5copytst.h5bin30448 -> 31856 bytes
-rw-r--r--tools/h5copy/testh5copy.sh.in2
4 files changed, 123 insertions, 0 deletions
diff --git a/tools/h5copy/CMakeTests.cmake b/tools/h5copy/CMakeTests.cmake
index 96dc92b..80b7d10 100644
--- a/tools/h5copy/CMakeTests.cmake
+++ b/tools/h5copy/CMakeTests.cmake
@@ -300,6 +300,7 @@
ADD_H5_TEST (compressed 0 ${HDF_FILE1}.h5 -v -s compressed -d compressed)
ADD_H5_TEST (named_vl 0 ${HDF_FILE1}.h5 -v -s named_vl -d named_vl)
ADD_H5_TEST (nested_vl 0 ${HDF_FILE1}.h5 -v -s nested_vl -d nested_vl)
+ ADD_H5_TEST (dset_attr 0 ${HDF_FILE1}.h5 -v -s dset_attr -d dset_attr)
# "Test copying dataset within group in source file to root of destination"
ADD_H5_TEST (simple_top 0 ${HDF_FILE1}.h5 -v -s grp_dsets/simple -d simple_top)
@@ -311,6 +312,7 @@
ADD_H5_TEST (grp_empty 0 ${HDF_FILE1}.h5 -v -s grp_empty -d grp_empty)
ADD_H5_TEST (grp_dsets 0 ${HDF_FILE1}.h5 -v -s grp_dsets -d grp_dsets)
ADD_H5_TEST (grp_nested 0 ${HDF_FILE1}.h5 -v -s grp_nested -d grp_nested)
+ ADD_H5_TEST (grp_attr 0 ${HDF_FILE1}.h5 -v -s grp_attr -d grp_attr)
# "Test copying dataset within group in source file to group in destination"
ADD_H5_TEST2 (simple_group 0 ${HDF_FILE1}.h5 grp_dsets grp_dsets -v -s /grp_dsets/simple -d /grp_dsets/simple_group)
diff --git a/tools/h5copy/h5copygentest.c b/tools/h5copy/h5copygentest.c
index 49204f5..2a127a7 100644
--- a/tools/h5copy/h5copygentest.c
+++ b/tools/h5copy/h5copygentest.c
@@ -34,9 +34,12 @@
#define DATASET_COMPRESSED "compressed"
#define DATASET_NAMED_VL "named_vl"
#define DATASET_NESTED_VL "nested_vl"
+#define DATASET_ATTR "dset_attr"
+#define ATTR "attr"
#define GROUP_EMPTY "grp_empty"
#define GROUP_DATASETS "grp_dsets"
#define GROUP_NESTED "grp_nested"
+#define GROUP_ATTR "grp_attr"
/* Obj reference */
#define OBJ_REF_DS "Dset1"
@@ -322,6 +325,121 @@ static void gent_nested_vl(hid_t loc_id)
/*-------------------------------------------------------------------------
+ * Function: gent_att_compound_vlstr
+ *
+ * Purpose: Generate a dataset and a group.
+ * Both has an attribute with a compound datatype consisting
+ * of a variable length string
+ *
+ *-------------------------------------------------------------------------
+ */
+static void gent_att_compound_vlstr(hid_t loc_id)
+{
+ typedef struct { /* Compound structure for the attribute */
+ int i;
+ char *v;
+ } s1;
+ hsize_t dim[1] = {1}; /* Dimension size */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t aid = -1; /* Attribute ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t gid = -1; /* Group ID */
+ hid_t vl_str_tid = -1; /* Variable length datatype ID */
+ hid_t cmpd_tid = -1; /* Compound datatype ID */
+ hid_t null_sid = -1; /* Null dataspace ID */
+ s1 buf; /* Buffer */
+
+ buf.i = 9;
+ buf.v = "ThisIsAString";
+
+ /* Create an integer datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)
+ goto error;
+
+ /* Create a variable length string */
+ if((vl_str_tid = H5Tcopy(H5T_C_S1)) < 0)
+ goto error;
+ if(H5Tset_size(vl_str_tid, H5T_VARIABLE) < 0)
+ goto error;
+
+ /* Create a compound datatype with a variable length string and an integer */
+ if((cmpd_tid = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0)
+ goto error;
+ if(H5Tinsert(cmpd_tid, "i", HOFFSET(s1, i), tid) < 0)
+ goto error;
+ if(H5Tinsert(cmpd_tid, "v", HOFFSET(s1, v), vl_str_tid) < 0)
+ goto error;
+
+ /* Create a dataset */
+ if((null_sid = H5Screate(H5S_NULL)) < 0)
+ goto error;
+ if((did = H5Dcreate2(loc_id, DATASET_ATTR, H5T_NATIVE_INT, null_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Attach an attribute with the compound datatype to the dataset */
+ if((sid = H5Screate_simple(1, dim, dim)) < 0)
+ goto error;
+ if((aid = H5Acreate2(did, ATTR, cmpd_tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Write the attribute */
+ buf.i = 9;
+ buf.v = "ThisIsAString";
+ if(H5Awrite(aid, cmpd_tid, &buf) < 0)
+ goto error;
+
+ /* Close the dataset and its attribute */
+ if(H5Dclose(did) < 0)
+ goto error;
+ if(H5Aclose(aid) < 0)
+ goto error;
+
+ /* Create a group */
+ if((gid = H5Gcreate2(loc_id, GROUP_ATTR, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Attach an attribute with the compound datatype to the group */
+ if((aid = H5Acreate2(gid, ATTR, cmpd_tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+ if(H5Awrite(aid, cmpd_tid, &buf) < 0)
+ goto error;
+
+ /* Close the group and its attribute */
+ if(H5Aclose(aid) < 0)
+ goto error;
+ if(H5Gclose(gid) < 0)
+ goto error;
+
+ /* Close dataspaces */
+ if(H5Sclose(sid) < 0)
+ goto error;
+ if(H5Sclose(null_sid) < 0)
+ goto error;
+
+ /* Close datatypes */
+ if(H5Tclose(tid) < 0)
+ goto error;
+ if(H5Tclose(vl_str_tid) < 0)
+ goto error;
+ if(H5Tclose(cmpd_tid) < 0)
+ goto error;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Tclose(vl_str_tid);
+ H5Tclose(cmpd_tid);
+ H5Sclose(null_sid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Aclose(aid);
+ H5Gclose(gid);
+ } H5E_END_TRY;
+
+} /* gen_att_compound_vlstr() */
+
+/*-------------------------------------------------------------------------
* Function: gent_datasets
*
* Purpose: Generate all datasets in a particular location
@@ -658,6 +776,7 @@ static void Test_Obj_Copy(void)
gent_empty_group(fid);
gent_nested_datasets(fid);
gent_nested_group(fid);
+ gent_att_compound_vlstr(fid);
out:
/*-----------------------------------------------------------------------
diff --git a/tools/h5copy/testfiles/h5copytst.h5 b/tools/h5copy/testfiles/h5copytst.h5
index f407f82..759ffa7 100644
--- a/tools/h5copy/testfiles/h5copytst.h5
+++ b/tools/h5copy/testfiles/h5copytst.h5
Binary files differ
diff --git a/tools/h5copy/testh5copy.sh.in b/tools/h5copy/testh5copy.sh.in
index 77c64c4..d8abfd9 100644
--- a/tools/h5copy/testh5copy.sh.in
+++ b/tools/h5copy/testh5copy.sh.in
@@ -490,6 +490,7 @@ COPY_OBJECTS()
TOOLTEST -i $TESTFILE -o $TESTDIR/compressed.out.h5 -v -s compressed -d compressed
TOOLTEST -i $TESTFILE -o $TESTDIR/named_vl.out.h5 -v -s named_vl -d named_vl
TOOLTEST -i $TESTFILE -o $TESTDIR/nested_vl.out.h5 -v -s nested_vl -d nested_vl
+ TOOLTEST -i $TESTFILE -o $TESTDIR/dset_attr.out.h5 -v -s /dset_attr -d /dset_attr
echo "Test copying dataset within group in source file to root of destination"
TOOLTEST -i $TESTFILE -o $TESTDIR/simple_top.out.h5 -v -s grp_dsets/simple -d simple_top
@@ -501,6 +502,7 @@ COPY_OBJECTS()
TOOLTEST -i $TESTFILE -o $TESTDIR/grp_empty.out.h5 -v -s grp_empty -d grp_empty
TOOLTEST -i $TESTFILE -o $TESTDIR/grp_dsets.out.h5 -v -s grp_dsets -d grp_dsets
TOOLTEST -i $TESTFILE -o $TESTDIR/grp_nested.out.h5 -v -s grp_nested -d grp_nested
+ TOOLTEST -i $TESTFILE -o $TESTDIR/grp_attr.out.h5 -v -s grp_attr -d grp_attr
echo "Test copying dataset within group in source file to group in destination"
TOOLTEST_PREFILL -i $TESTFILE -o $TESTDIR/simple_group.out.h5 grp_dsets grp_dsets /grp_dsets/simple /grp_dsets/simple_group