summaryrefslogtreecommitdiffstats
path: root/tools/h5copy
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-02-13 23:45:13 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-02-13 23:45:13 (GMT)
commita5662c497884c2d182294b9aceabe3cbded28358 (patch)
tree60ca9a2ef9a3948f7f62773f2f52e6cc4c7a7da8 /tools/h5copy
parentc6b3059a92b61a119da49c04fbdcd54545d95242 (diff)
downloadhdf5-a5662c497884c2d182294b9aceabe3cbded28358.zip
hdf5-a5662c497884c2d182294b9aceabe3cbded28358.tar.gz
hdf5-a5662c497884c2d182294b9aceabe3cbded28358.tar.bz2
[svn-r13294] Description:
Add empty & "full" groups to source HDF5 file and test copying them. Test renaming objects during copy Test specifying root group path for source & destination objects Tested on: Linux/32 2.6 (chicago) Too minor to require more tests
Diffstat (limited to 'tools/h5copy')
-rw-r--r--tools/h5copy/h5copygentest.c90
-rw-r--r--tools/h5copy/testh5copy.sh27
2 files changed, 93 insertions, 24 deletions
diff --git a/tools/h5copy/h5copygentest.c b/tools/h5copy/h5copygentest.c
index 79f43ef..c9dc01f 100644
--- a/tools/h5copy/h5copygentest.c
+++ b/tools/h5copy/h5copygentest.c
@@ -19,16 +19,16 @@
#include <stdlib.h>
#include "hdf5.h"
-#define FILENAME "h5copytst.h5"
-#define DATASET_SIMPLE "simple"
-#define DATASET_CHUNK "chunk"
-#define DATASET_COMPACT "compact"
-#define DATASET_COMPOUND "compound"
-#define DATASET_COMPRESSED "compressed"
-#define DATASET_NAMED_VL "named_vl"
-#define DATASET_NESTED_VL "nested_vl"
-
-
+#define FILENAME "h5copytst.h5"
+#define DATASET_SIMPLE "simple"
+#define DATASET_CHUNK "chunk"
+#define DATASET_COMPACT "compact"
+#define DATASET_COMPOUND "compound"
+#define DATASET_COMPRESSED "compressed"
+#define DATASET_NAMED_VL "named_vl"
+#define DATASET_NESTED_VL "nested_vl"
+#define GROUP_EMPTY "grp_empty"
+#define GROUP_DATASETS "grp_dsets"
/*-------------------------------------------------------------------------
@@ -306,6 +306,64 @@ static void gent_nested_vl(hid_t loc_id)
/*-------------------------------------------------------------------------
+ * Function: gent_datasets
+ *
+ * Purpose: Generate all datasets in a particular location
+ *
+ *-------------------------------------------------------------------------
+ */
+static void gent_datasets(hid_t loc_id)
+{
+ gent_simple(loc_id);
+ gent_chunked(loc_id);
+ gent_compact(loc_id);
+ gent_compound(loc_id);
+ gent_compressed(loc_id);
+ gent_named_vl(loc_id);
+ gent_nested_vl(loc_id);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: gent_empty_group
+ *
+ * Purpose: Generate an empty group in a location
+ *
+ *-------------------------------------------------------------------------
+ */
+static void gent_empty_group(hid_t loc_id)
+{
+ hid_t gid;
+
+ /* Create group in location */
+ gid = H5Gcreate(loc_id, GROUP_EMPTY, (size_t)0);
+
+ /* Release resources */
+ H5Gclose(gid);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: gent_nested_datasets
+ *
+ * Purpose: Generate a group in a location and populate it with the "standard"
+ * datasets
+ *
+ *-------------------------------------------------------------------------
+ */
+static void gent_nested_datasets(hid_t loc_id)
+{
+ hid_t gid;
+
+ /* Create group in location */
+ gid = H5Gcreate(loc_id, GROUP_DATASETS, (size_t)0);
+
+ /* Add datasets to group created */
+ gent_datasets(gid);
+
+ /* Release resources */
+ H5Gclose(gid);
+}
+
+/*-------------------------------------------------------------------------
* Function: main
*
*-------------------------------------------------------------------------
@@ -317,17 +375,11 @@ int main(void)
/* Create source file */
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- gent_simple(fid);
- gent_chunked(fid);
- gent_compact(fid);
- gent_compound(fid);
- gent_compressed(fid);
- gent_named_vl(fid);
- gent_nested_vl(fid);
+ gent_datasets(fid);
+ gent_empty_group(fid);
+ gent_nested_datasets(fid);
H5Fclose(fid);
- /* Create destination file with all datasets in root group */
-
return 0;
}
diff --git a/tools/h5copy/testh5copy.sh b/tools/h5copy/testh5copy.sh
index e0056ac..a905148 100644
--- a/tools/h5copy/testh5copy.sh
+++ b/tools/h5copy/testh5copy.sh
@@ -164,14 +164,14 @@ H5LSTEST()
fi
}
-# Copy single datasets of various forms from one root group to another,
-# adding new object to the destination file each time
+# Copy single datasets of various forms from one group to another,
+# adding object copied to the destination file each time
#
# Assumed arguments:
-# $1 is test "variation"
+# $1 is test "variation" (a single letter, normally)
# $2 is group within source file
# $3 is group within destination file
-SIMPLETEST()
+COPYOBJECTS()
{
TESTFILE=$srcdir/../testfiles/$SRCFILE
FILEOUT="../testfiles/`basename $SRCFILE .h5`.$1.out.h5"
@@ -179,6 +179,7 @@ SIMPLETEST()
# Remove any output file left over from previous test run
rm -f $FILEOUT
+ # Test copying various forms of datasets
TOOLTEST -i $TESTFILE -o $FILEOUT -v -s "$2"simple -d "$3"simple
TOOLTEST -i $TESTFILE -o $FILEOUT -v -s "$2"chunk -d "$3"chunk
TOOLTEST -i $TESTFILE -o $FILEOUT -v -s "$2"compact -d "$3"compact
@@ -187,6 +188,16 @@ SIMPLETEST()
TOOLTEST -i $TESTFILE -o $FILEOUT -v -s "$2"named_vl -d "$3"named_vl
TOOLTEST -i $TESTFILE -o $FILEOUT -v -s "$2"nested_vl -d "$3"nested_vl
+ # Test copying & renaming dataset
+ TOOLTEST -i $TESTFILE -o $FILEOUT -v -s "$2"compound -d "$3"rename
+
+ # Test copying empty & "full" groups
+ TOOLTEST -i $TESTFILE -o $FILEOUT -v -s "$2"grp_empty -d "$3"grp_empty
+ TOOLTEST -i $TESTFILE -o $FILEOUT -v -s "$2"grp_dsets -d "$3"grp_dsets
+
+ # Test copying & renaming group
+ TOOLTEST -i $TESTFILE -o $FILEOUT -v -s "$2"grp_dsets -d "$3"grp_rename
+
# Verify that the file created above is correct
H5LSTEST $FILEOUT
@@ -201,7 +212,13 @@ SIMPLETEST()
### T H E T E S T S ###
##############################################################################
-SIMPLETEST a "" ""
+# Copy objects from root group of source file to root of destination file
+# (with implicit root group paths)
+COPYOBJECTS a "" ""
+
+# Copy objects from root group of source file to root of destination file
+# (with explicit root group paths)
+COPYOBJECTS b "/" "/"
if test $nerrors -eq 0 ; then