summaryrefslogtreecommitdiffstats
path: root/tools/h5copy
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2016-09-14 21:02:43 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2016-09-14 21:02:43 (GMT)
commit7f817fea7c50cea4305bc14fcaf4d80fb3dc42e4 (patch)
treee18b6cefc2cc51c58ebacec1d6a9051742754f71 /tools/h5copy
parentc1c384878ba58193120c3da804d761542c47bd7d (diff)
parent052efd9bde06ea2427beffd3ea493cbc53a17608 (diff)
downloadhdf5-7f817fea7c50cea4305bc14fcaf4d80fb3dc42e4.zip
hdf5-7f817fea7c50cea4305bc14fcaf4d80fb3dc42e4.tar.gz
hdf5-7f817fea7c50cea4305bc14fcaf4d80fb3dc42e4.tar.bz2
Merge branch 'develop' into evict_on_close
Diffstat (limited to 'tools/h5copy')
-rw-r--r--tools/h5copy/CMakeLists.txt2
-rw-r--r--tools/h5copy/CMakeTests.cmake10
-rw-r--r--tools/h5copy/h5copy.c24
-rw-r--r--tools/h5copy/h5copygentest.c84
-rw-r--r--tools/h5copy/testfiles/h5copytst.h5bin30448 -> 15900 bytes
-rw-r--r--tools/h5copy/testfiles/h5copytst_new.h5bin30280 -> 31856 bytes
-rw-r--r--tools/h5copy/testh5copy.sh.in4
7 files changed, 102 insertions, 22 deletions
diff --git a/tools/h5copy/CMakeLists.txt b/tools/h5copy/CMakeLists.txt
index 4c44ac2..219106f 100644
--- a/tools/h5copy/CMakeLists.txt
+++ b/tools/h5copy/CMakeLists.txt
@@ -42,7 +42,7 @@ endif (BUILD_TESTING)
#-----------------------------------------------------------------------------
#INSTALL_PROGRAM_PDB (h5copy ${HDF5_INSTALL_BIN_DIR} toolsapplications)
-
+
install (
TARGETS
h5copy
diff --git a/tools/h5copy/CMakeTests.cmake b/tools/h5copy/CMakeTests.cmake
index 275461f..96dc92b 100644
--- a/tools/h5copy/CMakeTests.cmake
+++ b/tools/h5copy/CMakeTests.cmake
@@ -23,15 +23,9 @@
foreach (listfiles ${LIST_HDF5_TEST_FILES} ${LIST_OTHER_TEST_FILES})
get_filename_component(fname "${listfiles}" NAME)
- set (dest "${PROJECT_BINARY_DIR}/testfiles/${fname}")
- #message (STATUS " Copying ${listfiles}")
- add_custom_command (
- TARGET h5copy
- POST_BUILD
- COMMAND ${CMAKE_COMMAND}
- ARGS -E copy_if_different ${listfiles} ${dest}
- )
+ HDFTEST_COPY_FILE("${listfiles}" "${PROJECT_BINARY_DIR}/testfiles/${fname}" "h5copy_files")
endforeach (listfiles ${LIST_HDF5_TEST_FILES} ${LIST_OTHER_TEST_FILES})
+ add_custom_target(h5copy_files ALL COMMENT "Copying files needed by h5copy tests" DEPENDS ${h5copy_files_list})
##############################################################################
##############################################################################
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c
index f3a0d7a..5371a21 100644
--- a/tools/h5copy/h5copy.c
+++ b/tools/h5copy/h5copy.c
@@ -417,19 +417,19 @@ main (int argc, const char *argv[])
/* create property to pass copy options */
if ( (ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pcreate failed");
/* set options for object copy */
if (flag)
{
if ( H5Pset_copy_object(ocpl_id, flag) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_copy_object failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pset_copy_object failed");
}
/* Create link creation property list */
if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
error_msg("Could not create link creation property list\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pcreate failed");
} /* end if */
/* Check for creating intermediate groups */
@@ -437,7 +437,7 @@ main (int argc, const char *argv[])
/* Set the intermediate group creation property */
if(H5Pset_create_intermediate_group(lcpl_id, 1) < 0) {
error_msg("Could not set property for creating parent groups\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_create_intermediate_group failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pset_create_intermediate_group failed");
} /* end if */
/* Display some output if requested */
@@ -464,7 +464,7 @@ main (int argc, const char *argv[])
{
error_msg("group <%s> doesn't exist. Use -p to create parent groups.\n", str_ptr);
HDfree(str_ptr);
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lexists failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Lexists failed");
}
HDfree(str_ptr);
}
@@ -484,7 +484,7 @@ main (int argc, const char *argv[])
if(H5Lcopy(fid_src, oname_src,
fid_dst, oname_dst,
H5P_DEFAULT, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lcopy failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Lcopy failed");
}
else /* valid link */
{
@@ -494,7 +494,7 @@ main (int argc, const char *argv[])
oname_dst, /* Name of the destination object */
ocpl_id, /* Object copy property list */
lcpl_id)<0) /* Link creation property list */
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Ocopy failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Ocopy failed");
}
/* free link info path */
@@ -503,15 +503,15 @@ main (int argc, const char *argv[])
/* close propertis */
if(H5Pclose(ocpl_id)<0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pclose failed");
if(H5Pclose(lcpl_id)<0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pclose failed");
/* close files */
if (H5Fclose(fid_src)<0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Fclose failed");
if (H5Fclose(fid_dst)<0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed");
+ HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Fclose failed");
leave(EXIT_SUCCESS);
@@ -529,6 +529,6 @@ done:
H5Fclose(fid_dst);
} H5E_END_TRY;
- leave(EXIT_FAILURE);
+ leave(ret_value);
}
diff --git a/tools/h5copy/h5copygentest.c b/tools/h5copy/h5copygentest.c
index 93203c6..7669702 100644
--- a/tools/h5copy/h5copygentest.c
+++ b/tools/h5copy/h5copygentest.c
@@ -35,9 +35,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"
@@ -323,6 +326,86 @@ 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 */
+ tid = H5Tcopy(H5T_NATIVE_INT);
+
+ /* Create a variable length string */
+ vl_str_tid = H5Tcopy(H5T_C_S1);
+ H5Tset_size(vl_str_tid, H5T_VARIABLE);
+
+ /* Create a compound datatype with a variable length string and an integer */
+ cmpd_tid = H5Tcreate(H5T_COMPOUND, sizeof(s1));
+ H5Tinsert(cmpd_tid, "i", HOFFSET(s1, i), tid);
+ H5Tinsert(cmpd_tid, "v", HOFFSET(s1, v), vl_str_tid);
+
+ /* Create a dataset */
+ null_sid = H5Screate(H5S_NULL);
+ did = H5Dcreate2(loc_id, DATASET_ATTR, H5T_NATIVE_INT, null_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Attach an attribute with the compound datatype to the dataset */
+ sid = H5Screate_simple(1, dim, dim);
+ aid = H5Acreate2(did, ATTR, cmpd_tid, sid, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Write the attribute */
+ buf.i = 9;
+ buf.v = "ThisIsAString";
+ H5Awrite(aid, cmpd_tid, &buf);
+
+ /* Close the dataset and its attribute */
+ H5Dclose(did);
+ H5Aclose(aid);
+
+ /* Create a group */
+ gid = H5Gcreate2(loc_id, GROUP_ATTR, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Attach an attribute with the compound datatype to the group */
+ aid = H5Acreate2(gid, ATTR, cmpd_tid, sid, H5P_DEFAULT, H5P_DEFAULT);
+ H5Awrite(aid, cmpd_tid, &buf);
+
+ /* Close the group and its attribute */
+ H5Aclose(aid);
+ H5Gclose(gid);
+
+ /* Close dataspaces */
+ H5Sclose(sid);
+ H5Sclose(null_sid);
+
+ /* Close datatypes */
+ H5Tclose(tid);
+ H5Tclose(vl_str_tid);
+ H5Tclose(cmpd_tid);
+
+} /* gen_att_compound_vlstr() */
+
+/*-------------------------------------------------------------------------
* Function: gent_datasets
*
* Purpose: Generate all datasets in a particular location
@@ -676,6 +759,7 @@ static void Test_Obj_Copy(void)
gent_empty_group(fid);
gent_nested_datasets(fid);
gent_nested_group(fid);
+ gent_att_compound_vlstr(fid);
H5Fclose(fid);
fid = (-1);
diff --git a/tools/h5copy/testfiles/h5copytst.h5 b/tools/h5copy/testfiles/h5copytst.h5
index f407f82..1d1cbf1 100644
--- a/tools/h5copy/testfiles/h5copytst.h5
+++ b/tools/h5copy/testfiles/h5copytst.h5
Binary files differ
diff --git a/tools/h5copy/testfiles/h5copytst_new.h5 b/tools/h5copy/testfiles/h5copytst_new.h5
index 222c511..fd820ca 100644
--- a/tools/h5copy/testfiles/h5copytst_new.h5
+++ b/tools/h5copy/testfiles/h5copytst_new.h5
Binary files differ
diff --git a/tools/h5copy/testh5copy.sh.in b/tools/h5copy/testh5copy.sh.in
index 77c64c4..859d7c8 100644
--- a/tools/h5copy/testh5copy.sh.in
+++ b/tools/h5copy/testh5copy.sh.in
@@ -128,7 +128,7 @@ CLEAN_TESTFILES_AND_TESTDIR()
# skip rm if srcdir is same as destdir
# this occurs when build/test performed in source dir and
# make cp fail
- SDIR=`$DIRNAME $tstfile`
+ SDIR=$SRC_H5COPY_TESTFILES
INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
@@ -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