summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repacktst.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2009-04-20 16:37:47 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2009-04-20 16:37:47 (GMT)
commit6d13b7a243e968b4ee365a8ea2b54c5f7640e8f6 (patch)
treedcd3cd02916c026c54829261d30a8bd398186ef7 /tools/h5repack/h5repacktst.c
parent22acfa9fe13b5dca4344a8b65c202d47f38b6ef0 (diff)
downloadhdf5-6d13b7a243e968b4ee365a8ea2b54c5f7640e8f6.zip
hdf5-6d13b7a243e968b4ee365a8ea2b54c5f7640e8f6.tar.gz
hdf5-6d13b7a243e968b4ee365a8ea2b54c5f7640e8f6.tar.bz2
[svn-r16800] Purpose: Fix bug 1516
Description: h5repack previously would not take named datatypes into consideration when copying datasets and attributes. This would cause extra anonymous datatypes in the target file at best, and cause errors halfway through the repacking at worst. h5repack should now always handle named datatypes correctly. Named datatypes are also now converted to the native type when -n is given. Tested: jam, linew, smirom (h5committest)
Diffstat (limited to 'tools/h5repack/h5repacktst.c')
-rw-r--r--tools/h5repack/h5repacktst.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index 9a753ef..af4d671 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -72,6 +72,9 @@
/* File w/userblock */
#define FNAME16 "h5repack_ub.h5"
#define FNAME16OUT "h5repack_ub_out.h5"
+/* Named datatypes */
+#define FNAME17 "h5repack_named_dtypes.h5"
+#define FNAME17OUT "h5repack_named_dtypes_out.h5"
#define FNAME_UB "ublock.bin"
@@ -129,6 +132,7 @@ static int make_external(hid_t loc_id);
static int make_userblock(void);
static int verify_userblock( const char* filename);
static int make_userblock_file(void);
+static int make_named_dtype(hid_t loc_id);
/*-------------------------------------------------------------------------
@@ -1487,6 +1491,26 @@ int main (void)
#endif
+ /*-------------------------------------------------------------------------
+ * test file with userblock
+ *-------------------------------------------------------------------------
+ */
+ TESTING(" file with committed datatypes");
+
+ if(h5repack_init(&pack_options, 0) < 0)
+ GOERROR;
+
+ if(h5repack(FNAME17, FNAME17OUT, &pack_options) < 0)
+ GOERROR;
+ if(h5diff(FNAME17, FNAME17OUT, NULL, NULL, &diff_options) > 0)
+ GOERROR;
+ if(h5repack_verify(FNAME17OUT, &pack_options) <= 0)
+ GOERROR;
+ if(h5repack_end(&pack_options) < 0)
+ GOERROR;
+
+
+ PASSED();
@@ -1706,6 +1730,17 @@ int make_testfiles(void)
if(make_userblock_file() < 0)
goto out;
+ /*-------------------------------------------------------------------------
+ * create a file with named datatypes
+ *-------------------------------------------------------------------------
+ */
+ if((fid = H5Fcreate(FNAME17,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ return -1;
+ if (make_named_dtype(fid) < 0)
+ goto out;
+ if(H5Fclose(fid) < 0)
+ return -1;
+
return 0;
out:
@@ -5374,4 +5409,128 @@ out:
}
+/*-------------------------------------------------------------------------
+* Function: make_named_dtype
+*
+* Purpose: create a file with named datatypes in various configurations
+*
+*-------------------------------------------------------------------------
+*/
+static
+int make_named_dtype(hid_t loc_id)
+{
+ hsize_t dims[1] ={3};
+ hid_t did=-1;
+ hid_t aid=-1;
+ hid_t sid=-1;
+ hid_t tid=-1;
+ hid_t gid=-1;
+
+ if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ goto out;
+
+ /* Create a dataset with an anonymous committed datatype as the first thing
+ * h5repack sees */
+ if((tid = H5Tcopy(H5T_STD_I16LE)) < 0)
+ goto out;
+ if(H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+ if ((did = H5Dcreate2(loc_id, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(H5Tclose(tid) < 0)
+ goto out;
+
+ /* Create an attribute on that dataset that uses a committed datatype in
+ * a remote group */
+ if((gid = H5Gcreate2(loc_id, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(H5Gclose(gid) < 0)
+ goto out;
+ if((gid = H5Gcreate2(loc_id, "M/M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(H5Gclose(gid) < 0)
+ goto out;
+ if((tid = H5Tcopy(H5T_STD_I16BE)) < 0)
+ goto out;
+ if(H5Tcommit2(loc_id, "/M/M/A", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+ if((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(H5Aclose(aid) < 0)
+ goto out;
+ if(H5Tclose(tid) < 0)
+ goto out;
+ if(H5Dclose(did) < 0)
+ goto out;
+
+ /* Create a dataset in the remote group that uses a committed datatype in
+ * the root group */
+ if((tid = H5Tcopy(H5T_STD_I32LE)) < 0)
+ goto out;
+ if(H5Tcommit2(loc_id, "N", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+ if((did = H5Dcreate2(loc_id, "M/M/B", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(H5Tclose(tid) < 0)
+ goto out;
+
+ /* Create an attribute on the remote dataset that uses an anonymous
+ * committed datatype */
+ if((tid = H5Tcopy(H5T_STD_I32BE)) < 0)
+ goto out;
+ if(H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+ if((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(H5Aclose(aid) < 0)
+ goto out;
+
+ /* Create another attribute that uses the same anonymous datatype */
+ if((aid = H5Acreate2(did, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(H5Aclose(aid) < 0)
+ goto out;
+ if(H5Tclose(tid) < 0)
+ goto out;
+ if(H5Dclose(did) < 0)
+ goto out;
+
+ /* Create a dataset in the root group that uses the committed datatype in
+ * the root group */
+ if((tid = H5Topen2(loc_id, "N", H5P_DEFAULT)) < 0)
+ goto out;
+ if((did = H5Dcreate2(loc_id, "O", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(H5Dclose(did) < 0)
+ goto out;
+
+ /* Create 2 attributes on the committed datatype that use that datatype */
+ if((aid = H5Acreate2(tid, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(H5Aclose(aid) < 0)
+ goto out;
+ if((aid = H5Acreate2(tid, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(H5Aclose(aid) < 0)
+ goto out;
+ if(H5Tclose(tid) < 0)
+ goto out;
+
+ /* Close */
+ if (H5Sclose(sid) < 0)
+ goto out;
+
+ return 0;
+
+out:
+ H5E_BEGIN_TRY
+ {
+ H5Tclose(tid);
+ H5Aclose(aid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Gclose(gid);
+ } H5E_END_TRY;
+ return -1;
+} /* end make_named_dtype() */