summaryrefslogtreecommitdiffstats
path: root/tools/h5repack
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2003-12-18 16:18:09 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2003-12-18 16:18:09 (GMT)
commit8f65e4252d4f8eea059fcdbe5efc14546175c864 (patch)
treeade9d7df10060156d25aa6a5d0e5c6581eaf8cbc /tools/h5repack
parent1f0ca5b200c1e20050265d40d26f9bc29333fb74 (diff)
downloadhdf5-8f65e4252d4f8eea059fcdbe5efc14546175c864.zip
hdf5-8f65e4252d4f8eea059fcdbe5efc14546175c864.tar.gz
hdf5-8f65e4252d4f8eea059fcdbe5efc14546175c864.tar.bz2
[svn-r7969] Purpose:
h5repack new features Description: addded the copy routines for hard links changed the traversal structure to store information about the hard links added tests Solution: Platforms tested: linux solaris IRIX Misc. update:
Diffstat (limited to 'tools/h5repack')
-rw-r--r--tools/h5repack/h5repack.h62
-rw-r--r--tools/h5repack/h5repack_copy.c132
-rw-r--r--tools/h5repack/h5repack_refs.c76
-rw-r--r--tools/h5repack/testh5repack_filters.c160
-rw-r--r--tools/h5repack/testh5repack_main.c29
5 files changed, 279 insertions, 180 deletions
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h
index 546ae3a..a372a6f 100644
--- a/tools/h5repack/h5repack.h
+++ b/tools/h5repack/h5repack.h
@@ -134,52 +134,39 @@ void print_objlist(const char *filename,
int do_copy_file(hid_t fidin,
hid_t fidout,
- int nobjects,
- trav_info_t *info,
+ trav_table_t *travt,
pack_opt_t *options);
int copy_attr(hid_t loc_in,
hid_t loc_out,
pack_opt_t *options,
- int nobjects, /* number of objects */
- trav_info_t *travi, /* array of object names */
- hid_t fidout /*for saving references */
+ trav_table_t *travt,
+ hid_t fidout /* for saving references */
);
-
-void read_info(const char *filename,pack_opt_t *options);
-
-
-void close_obj(H5G_obj_t obj_type, hid_t obj_id);
-
const char* MapIdToName(hid_t refobj_id,
- int nobjects, /* number of objects */
- trav_info_t *travi, /* array of object names */
+ trav_table_t *travt,
pack_opt_t *options) /* repack options */;
-
-
int do_copy_refobjs(hid_t fidin,
hid_t fidout,
- int nobjects, /* number of objects */
- trav_info_t *travi, /* array of object names */
+ trav_table_t *travt,
pack_opt_t *options); /* repack options */
int do_copy_refobjs_inattr(hid_t loc_in,
hid_t loc_out,
pack_opt_t *options,
- int nobjects, /* number of objects */
- trav_info_t *travi, /* array of object names */
+ trav_table_t *travt,
hid_t fidout /* for saving references */
);
+void read_info(const char *filename,pack_opt_t *options);
+void close_obj(H5G_obj_t obj_type, hid_t obj_id);
/*-------------------------------------------------------------------------
* options table
*-------------------------------------------------------------------------
*/
-
-
int options_table_init( pack_opttbl_t **tbl );
int options_table_free( pack_opttbl_t *table );
int options_add_chunk ( obj_list_t *obj_list,
@@ -194,9 +181,6 @@ int options_add_comp ( obj_list_t *obj_list,
pack_info_t* options_get_object( const char *path,
pack_opttbl_t *table);
-
-
-
/*-------------------------------------------------------------------------
* parse functions
*-------------------------------------------------------------------------
@@ -217,46 +201,36 @@ int parse_number(char *str);
*-------------------------------------------------------------------------
*/
-
-#define FNAME1 "testcopy.h5"
-#define FNAME1OUT "testcopyout.h5"
-#define FNAME2 "testfilters.h5"
-#define FNAME2OUT "testfiltersout.h5"
-
-
-
-#define FNAME1 "testcopy.h5"
-#define FNAME1OUT "testcopyout.h5"
-#define FNAME2 "testfilters.h5"
-#define FNAME2OUT "testfiltersout.h5"
-
+#define FNAME1 "test1.h5"
+#define FNAME1OUT "test1out.h5"
+#define FNAME2 "test2.h5"
+#define FNAME2OUT "test2out.h5"
+#define FNAME3 "test3.h5"
+#define FNAME3OUT "test3out.h5"
+#define FNAME4 "test4.h5"
+#define FNAME4OUT "test4out.h5"
int make_testfiles(void);
-
int make_all_objects(hid_t fid);
-
+int make_attributes(hid_t fid);
+int make_special_objects(hid_t loc_id);
int make_attr(hid_t fid);
-
int write_dset( hid_t loc_id,
int rank,
hsize_t *dims,
const char *dset_name,
hid_t type_id,
void *buf );
-
int write_attr(hid_t loc_id,
int rank,
hsize_t *dims,
const char *attr_name,
hid_t type_id,
void *buf);
-
-
void write_attr_in(hid_t loc_id,
const char* dset_name, /* for saving reference to dataset*/
hid_t fid, /* for reference create */
int make_diffs /* flag to modify data buffers */);
-
void write_dset_in(hid_t loc_id,
const char* dset_name, /* for saving reference to dataset*/
hid_t file_id,
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index f7d5016..2afc94b 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -37,10 +37,10 @@ int copy_file(const char* fnamein,
const char* fnameout,
pack_opt_t *options)
{
- hid_t fidin;
- hid_t fidout;
- int nobjects;
- trav_info_t *travi=NULL;
+ hid_t fidin;
+ hid_t fidout;
+ int nobjects=0;
+ trav_table_t *travt=NULL;
/*-------------------------------------------------------------------------
* open the files
@@ -67,65 +67,66 @@ int copy_file(const char* fnamein,
printf("Making file <%s>...\n",fnameout);
-/*-------------------------------------------------------------------------
- * get the number of objects in the file
- *-------------------------------------------------------------------------
- */
+ /* init table */
+ trav_table_init(&travt);
- if ((nobjects = h5trav_getinfo(fidin, NULL ))<0) {
- printf("h5repack: <%s>: Could not obtain object list\n", fnamein );
- return -1;
- }
+ /* get the list of objects in the file */
+ if (h5trav_gettable(fidin,travt)<0)
+ goto out;
-/*-------------------------------------------------------------------------
- * get the list of objects in the file
- *-------------------------------------------------------------------------
- */
-
- if ((travi = (trav_info_t*) malloc( nobjects * sizeof(trav_info_t)))==NULL){
- printf("h5repack: <%s>: Could not allocate object list\n", fnamein );
- return -1;
- }
- if (h5trav_getinfo(fidin, travi )<0) {
- printf("h5repack: <%s>: Could not obtain object list\n", fnamein );
- return -1;
- }
+#if defined (H5_REPACK_DEBUG)
+ h5trav_printtable(travt);
+#endif
/*-------------------------------------------------------------------------
* do the copy
*-------------------------------------------------------------------------
*/
- if(do_copy_file(fidin,fidout,nobjects,travi,options)<0) {
+ if(do_copy_file(fidin,fidout,travt,options)<0) {
printf("h5repack: <%s>: Could not copy data to: %s\n", fnamein, fnameout);
- return -1;
+ goto out;
}
/*-------------------------------------------------------------------------
* do the copy of referenced objects
+ * and create hard links
*-------------------------------------------------------------------------
*/
- if(do_copy_refobjs(fidin,fidout,nobjects,travi,options)<0) {
+ if(do_copy_refobjs(fidin,fidout,travt,options)<0) {
printf("h5repack: <%s>: Could not copy data to: %s\n", fnamein, fnameout);
- return -1;
+ goto out;
}
-#if defined (H5_REPACK_DEBUG)
- h5trav_printinfo(nobjects,travi);
-#endif
-
+ /* free table */
+ trav_table_free(travt);
/*-------------------------------------------------------------------------
- * free
+ * close
*-------------------------------------------------------------------------
*/
+
H5Fclose(fidin);
H5Fclose(fidout);
- h5trav_freeinfo(travi,nobjects);
return 0;
+
+/*-------------------------------------------------------------------------
+ * out
+ *-------------------------------------------------------------------------
+ */
+
+out:
+ H5E_BEGIN_TRY {
+ H5Fclose(fidin);
+ H5Fclose(fidout);
+ trav_table_free(travt);
+ } H5E_END_TRY;
+
+ return -1;
}
+
/*-------------------------------------------------------------------------
* Function: do_copy_file
*
@@ -142,8 +143,7 @@ int copy_file(const char* fnamein,
int do_copy_file(hid_t fidin,
hid_t fidout,
- int nobjects, /* number of objects */
- trav_info_t *travi, /* array of object names */
+ trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
hid_t grp_in; /* group ID */
@@ -168,10 +168,10 @@ int do_copy_file(hid_t fidin,
*-------------------------------------------------------------------------
*/
- for ( i = 0; i < nobjects; i++)
+ for ( i = 0; i < travt->nobjs; i++)
{
- switch ( travi[i].type )
+ switch ( travt->objs[i].type )
{
/*-------------------------------------------------------------------------
* H5G_GROUP
@@ -179,19 +179,19 @@ int do_copy_file(hid_t fidin,
*/
case H5G_GROUP:
if (options->verbose)
- printf(" %-10s %s\n", "group",travi[i].name );
+ printf(" %-10s %s\n", "group",travt->objs[i].name );
- if ((grp_out=H5Gcreate(fidout,travi[i].name, 0))<0)
+ if ((grp_out=H5Gcreate(fidout,travt->objs[i].name, 0))<0)
goto error;
- if((grp_in = H5Gopen (fidin,travi[i].name))<0)
+ if((grp_in = H5Gopen (fidin,travt->objs[i].name))<0)
goto error;
-/*-------------------------------------------------------------------------
- * copy attrs
- *-------------------------------------------------------------------------
- */
- if (copy_attr(grp_in,grp_out,options,nobjects,travi,fidout)<0)
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
+ */
+ if (copy_attr(grp_in,grp_out,options,travt,fidout)<0)
goto error;
if (H5Gclose(grp_out)<0)
@@ -199,6 +199,7 @@ int do_copy_file(hid_t fidin,
if (H5Gclose(grp_in)<0)
goto error;
+
break;
/*-------------------------------------------------------------------------
@@ -207,9 +208,9 @@ int do_copy_file(hid_t fidin,
*/
case H5G_DATASET:
if (options->verbose)
- printf(" %-10s %s\n", "dataset",travi[i].name );
+ printf(" %-10s %s\n", "dataset",travt->objs[i].name );
- if ((dset_in=H5Dopen(fidin,travi[i].name))<0)
+ if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
goto error;
if ((space_id=H5Dget_space(dset_in))<0)
goto error;
@@ -256,7 +257,7 @@ int do_copy_file(hid_t fidin,
* create/write dataset/close
*-------------------------------------------------------------------------
*/
- if ((dset_out=H5Dcreate(fidout,travi[i].name,ftype_id,space_id,dcpl_id))<0)
+ if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,ftype_id,space_id,dcpl_id))<0)
goto error;
if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
goto error;
@@ -264,8 +265,8 @@ int do_copy_file(hid_t fidin,
/*-------------------------------------------------------------------------
* copy attrs
*-------------------------------------------------------------------------
- */
- if (copy_attr(dset_in,dset_out,options,nobjects,travi,fidout)<0)
+ */
+ if (copy_attr(dset_in,dset_out,options,travt,fidout)<0)
goto error;
/*close */
@@ -274,6 +275,7 @@ int do_copy_file(hid_t fidin,
if (buf)
free(buf);
+
}/*H5T_STD_REF_OBJ*/
@@ -293,8 +295,6 @@ int do_copy_file(hid_t fidin,
goto error;
if (H5Dclose(dset_in)<0)
goto error;
-
-
break;
@@ -304,20 +304,20 @@ int do_copy_file(hid_t fidin,
*/
case H5G_TYPE:
- if ((type_in = H5Topen (fidin,travi[i].name))<0)
+ if ((type_in = H5Topen (fidin,travt->objs[i].name))<0)
goto error;
if ((type_out = H5Tcopy(type_in))<0)
goto error;
- if ((H5Tcommit(fidout,travi[i].name,type_out))<0)
+ if ((H5Tcommit(fidout,travt->objs[i].name,type_out))<0)
goto error;
/*-------------------------------------------------------------------------
* copy attrs
*-------------------------------------------------------------------------
*/
- if (copy_attr(type_in,type_out,options,nobjects,travi,fidout)<0)
+ if (copy_attr(type_in,type_out,options,travt,fidout)<0)
goto error;
if (H5Tclose(type_in)<0)
@@ -326,7 +326,7 @@ int do_copy_file(hid_t fidin,
goto error;
if (options->verbose)
- printf(" %-10s %s\n","datatype",travi[i].name );
+ printf(" %-10s %s\n","datatype",travt->objs[i].name );
break;
@@ -343,32 +343,32 @@ int do_copy_file(hid_t fidin,
H5G_stat_t statbuf;
char *targbuf=NULL;
- if (H5Gget_objinfo(fidin,travi[i].name,FALSE,&statbuf)<0)
+ if (H5Gget_objinfo(fidin,travt->objs[i].name,FALSE,&statbuf)<0)
goto error;
targbuf = malloc(statbuf.linklen);
- if (H5Gget_linkval(fidin,travi[i].name,statbuf.linklen,targbuf)<0)
+ if (H5Gget_linkval(fidin,travt->objs[i].name,statbuf.linklen,targbuf)<0)
goto error;
if (H5Glink(fidout,
H5G_LINK_SOFT,
targbuf, /* current name of object */
- travi[i].name /* new name of object */
+ travt->objs[i].name /* new name of object */
)<0)
goto error;
free(targbuf);
if (options->verbose)
- printf(" %-10s %s\n","link",travi[i].name );
+ printf(" %-10s %s\n","link",travt->objs[i].name );
}
break;
default:
if (options->verbose)
- printf(" %-10s %s\n","User defined object",travi[i].name);
+ printf(" %-10s %s\n","User defined object",travt->objs[i].name);
break;
}
}
@@ -389,7 +389,7 @@ int do_copy_file(hid_t fidin,
if ((grp_in = H5Gopen(fidin,"/"))<0)
goto error;
- if (copy_attr(grp_in,grp_out,options,nobjects,travi,fidout)<0)
+ if (copy_attr(grp_in,grp_out,options,travt,fidout)<0)
goto error;
if (H5Gclose(grp_out)<0)
@@ -439,8 +439,7 @@ error:
int copy_attr(hid_t loc_in,
hid_t loc_out,
pack_opt_t *options,
- int nobjects, /* number of objects */
- trav_info_t *travi, /* array of object names */
+ trav_table_t *travt,
hid_t fidout /* for saving references */
)
{
@@ -577,4 +576,3 @@ error:
return -1;
}
-
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index cd5fe80..81bafab 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -24,6 +24,7 @@
* Function: do_copy_refobjs
*
* Purpose: duplicate all referenced HDF5 objects in the file
+ * and create hard links
*
* Return: 0, ok, -1 no
*
@@ -36,8 +37,7 @@
int do_copy_refobjs(hid_t fidin,
hid_t fidout,
- int nobjects, /* number of objects */
- trav_info_t *travi, /* array of object names */
+ trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
hid_t grp_in; /* group ID */
@@ -62,22 +62,32 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
- for ( i = 0; i < nobjects; i++)
+ for ( i = 0; i < travt->nobjs; i++)
{
- switch ( travi[i].type )
+ switch ( travt->objs[i].type )
{
/*-------------------------------------------------------------------------
* H5G_GROUP
*-------------------------------------------------------------------------
*/
case H5G_GROUP:
-
- if((grp_in = H5Gopen (fidin,travi[i].name))<0)
- goto error;
+
+ /*-------------------------------------------------------------------------
+ * check for hard links
+ *-------------------------------------------------------------------------
+ */
- if (H5Gclose(grp_in)<0)
- goto error;
+ if (travt->objs[i].nlinks)
+ {
+ for ( j=0; j<travt->objs[i].nlinks; j++)
+ {
+ H5Glink(fidout,
+ H5G_LINK_HARD,
+ travt->objs[i].name,
+ travt->objs[i].links[j].new_name);
+ }
+ }
break;
@@ -87,7 +97,7 @@ int do_copy_refobjs(hid_t fidin,
*/
case H5G_DATASET:
- if ((dset_in=H5Dopen(fidin,travi[i].name))<0)
+ if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
goto error;
if ((space_id=H5Dget_space(dset_in))<0)
goto error;
@@ -149,14 +159,14 @@ int do_copy_refobjs(hid_t fidin,
/* get the name. a valid name could only occur in the
second traversal of the file */
- if ((refname=MapIdToName(refobj_id,nobjects,travi,options))!=NULL)
+ if ((refname=MapIdToName(refobj_id,travt,options))!=NULL)
{
/* create the reference */
if (H5Rcreate(&refbuf[j],fidout,refname,H5R_OBJECT,-1)<0)
goto error;
if (options->verbose)
- printf("object <%s> reference created to <%s>\n",travi[i].name,refname);
+ printf("object <%s> reference created to <%s>\n",travt->objs[i].name,refname);
}
close_obj(obj_type,refobj_id);
}/* j */
@@ -167,7 +177,7 @@ int do_copy_refobjs(hid_t fidin,
* create/write dataset/close
*-------------------------------------------------------------------------
*/
- if ((dset_out=H5Dcreate(fidout,travi[i].name,ftype_id,space_id,dcpl_id))<0)
+ if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,ftype_id,space_id,dcpl_id))<0)
goto error;
if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,refbuf)<0)
goto error;
@@ -185,7 +195,7 @@ int do_copy_refobjs(hid_t fidin,
else
{
- if ((dset_out=H5Dopen(fidout,travi[i].name))<0)
+ if ((dset_out=H5Dopen(fidout,travt->objs[i].name))<0)
goto error;
}
@@ -194,8 +204,24 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
- if (do_copy_refobjs_inattr(dset_in,dset_out,options,nobjects,travi,fidout)<0)
+ if (do_copy_refobjs_inattr(dset_in,dset_out,options,travt,fidout)<0)
goto error;
+
+
+ /*-------------------------------------------------------------------------
+ * check for hard links
+ *-------------------------------------------------------------------------
+ */
+ if (travt->objs[i].nlinks)
+ {
+ for ( j=0; j<travt->objs[i].nlinks; j++)
+ {
+ H5Glink(fidout,
+ H5G_LINK_HARD,
+ travt->objs[i].name,
+ travt->objs[i].links[j].new_name);
+ }
+ }
/*-------------------------------------------------------------------------
@@ -225,7 +251,7 @@ int do_copy_refobjs(hid_t fidin,
*/
case H5G_TYPE:
- if ((type_in = H5Topen (fidin,travi[i].name))<0)
+ if ((type_in = H5Topen (fidin,travt->objs[i].name))<0)
goto error;
if (H5Tclose(type_in)<0)
@@ -267,7 +293,7 @@ int do_copy_refobjs(hid_t fidin,
if ((grp_in = H5Gopen(fidin,"/"))<0)
goto error;
- if (do_copy_refobjs_inattr(grp_in,grp_out,options,nobjects,travi,fidout)<0)
+ if (do_copy_refobjs_inattr(grp_in,grp_out,options,travt,fidout)<0)
goto error;
if (H5Gclose(grp_out)<0)
@@ -314,8 +340,7 @@ error:
int do_copy_refobjs_inattr(hid_t loc_in,
hid_t loc_out,
pack_opt_t *options,
- int nobjects, /* number of objects */
- trav_info_t *travi, /* array of object names */
+ trav_table_t *travt,
hid_t fidout /* for saving references */
)
{
@@ -414,7 +439,7 @@ int do_copy_refobjs_inattr(hid_t loc_in,
/* get the name. a valid name could only occur in the
second traversal of the file */
- if ((refname=MapIdToName(refobj_id,nobjects,travi,options))!=NULL)
+ if ((refname=MapIdToName(refobj_id,travt,options))!=NULL)
{
/* create the reference */
if (H5Rcreate(&refbuf[i],fidout,refname,H5R_OBJECT,-1)<0)
@@ -506,8 +531,7 @@ static void close_obj(H5G_obj_t obj_type, hid_t obj_id)
*/
const char* MapIdToName(hid_t refobj_id,
- int nobjects, /* number of objects */
- trav_info_t *travi, /* array of object names */
+ trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
hid_t id;
@@ -521,9 +545,9 @@ const char* MapIdToName(hid_t refobj_id,
}
- for ( i=0; i<nobjects; i++)
+ for ( i=0; i<travt->nobjs; i++)
{
- switch ( travi[i].type )
+ switch ( travt->objs[i].type )
{
/*-------------------------------------------------------------------------
@@ -543,7 +567,7 @@ const char* MapIdToName(hid_t refobj_id,
case H5G_DATASET:
- if ((id = H5Dopen(fid,travi[i].name))<0)
+ if ((id = H5Dopen(fid,travt->objs[i].name))<0)
{
assert(0);
return NULL;
@@ -558,7 +582,7 @@ const char* MapIdToName(hid_t refobj_id,
if (id==refobj_id)
{
H5Fclose(fid);
- return travi[i].name;
+ return travt->objs[i].name;
}
diff --git a/tools/h5repack/testh5repack_filters.c b/tools/h5repack/testh5repack_filters.c
index 36abc06..dd72813 100644
--- a/tools/h5repack/testh5repack_filters.c
+++ b/tools/h5repack/testh5repack_filters.c
@@ -22,12 +22,6 @@
*
* Purpose: make a dataset using DEFLATE (GZIP) compression in FID
*
- * Return: Success: zero
- * Failure: 1
- *
- * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
- * September, 19, 2003
- *
*-------------------------------------------------------------------------
*/
static int
@@ -82,12 +76,6 @@ error:
*
* Purpose: make a dataset using SZIP compression in FID
*
- * Return: Success: zero
- * Failure: 1
- *
- * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
- * September, 19, 2003
- *
*-------------------------------------------------------------------------
*/
static int
@@ -152,12 +140,6 @@ error:
* Purpose: make a test file with all types of HDF5 objects,
* datatypes and filters
*
- * Return: Success: zero
- * Failure: 1
- *
- * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
- * September, 19, 2003
- *
*-------------------------------------------------------------------------
*/
int make_testfiles(void)
@@ -167,23 +149,35 @@ int make_testfiles(void)
TESTING(" generating datasets");
- /* create a file for the copy test */
+ /* create a file for general copy test */
if((fid = H5Fcreate(FNAME1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
TEST_ERROR;
-
nerrors += make_all_objects(fid);
+ /* close */
+ if(H5Fclose(fid)<0)
+ TEST_ERROR;
+ /* create a file for attributes copy test */
+ if((fid = H5Fcreate(FNAME2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
+ TEST_ERROR;
+ nerrors += make_attributes(fid);
/* close */
if(H5Fclose(fid)<0)
TEST_ERROR;
+ /* create a file for special items test */
+ if((fid = H5Fcreate(FNAME3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
+ TEST_ERROR;
+ nerrors += make_special_objects(fid);
+ /* close */
+ if(H5Fclose(fid)<0)
+ TEST_ERROR;
+
/* create a file for the filters test */
- if((fid = H5Fcreate(FNAME2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
+ if((fid = H5Fcreate(FNAME4,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
TEST_ERROR;
-
nerrors += make_deflate(fid);
nerrors += make_szip(fid);
-
/* close */
if(H5Fclose(fid)<0)
TEST_ERROR;
@@ -199,20 +193,11 @@ error:
}
-
-
-
/*-------------------------------------------------------------------------
* Function: make_all_objects
*
* Purpose: make a test file with all types of HDF5 objects, datatypes
*
- * Return: Success: zero
- * Failure: 1
- *
- * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
- * September, 19, 2003
- *
*-------------------------------------------------------------------------
*/
int make_all_objects(hid_t fid)
@@ -267,22 +252,63 @@ int make_all_objects(hid_t fid)
H5Glink(fid, H5G_LINK_SOFT, "dset", "link");
/*-------------------------------------------------------------------------
- * write a series of attributes on the dataset, group, and root group
+ * write a series of datasetes on the group, and root group
*-------------------------------------------------------------------------
*/
- write_attr_in(dset_id,"dset_ref",fid,0);
- write_attr_in(group_id,"dset_ref",fid,0);
- write_attr_in(root_id,"dset_ref",fid,0);
+ write_dset_in(root_id,"dset_ref",fid,0);
+ write_dset_in(group_id,"dset_ref",fid,0);
+
+
+ /* Close */
+ H5Dclose(dset_id);
+ H5Gclose(group_id);
+ H5Gclose(root_id);
+
+ return 0;
+
+}
+
/*-------------------------------------------------------------------------
- * write a series of datasetes on the group, and root group
+ * Function: make_attributes
+ *
+ * Purpose: make a test file with all types of attributes
+ *
+ *-------------------------------------------------------------------------
+ */
+int make_attributes(hid_t fid)
+{
+ hid_t dset_id;
+ hid_t group_id;
+ hid_t root_id;
+ hid_t space_id;
+ hsize_t dims[1]={2};
+
+/*-------------------------------------------------------------------------
+ * H5G_DATASET
*-------------------------------------------------------------------------
*/
- write_dset_in(root_id,"dset_ref",fid,0);
- write_dset_in(group_id,"dset_ref",fid,0);
+ space_id = H5Screate_simple(1,dims,NULL);
+ dset_id = H5Dcreate(fid,"dset",H5T_NATIVE_INT,space_id,H5P_DEFAULT);
+ H5Sclose(space_id);
+
+/*-------------------------------------------------------------------------
+ * H5G_GROUP
+ *-------------------------------------------------------------------------
+ */
+ group_id = H5Gcreate(fid,"g1",0);
+ root_id = H5Gopen(fid, "/");
+
+/*-------------------------------------------------------------------------
+ * write a series of attributes on the dataset, group, and root group
+ *-------------------------------------------------------------------------
+ */
+ write_attr_in(dset_id,"dset",fid,0);
+ write_attr_in(group_id,"dset",fid,0);
+ write_attr_in(root_id,"dset",fid,0);
/* Close */
H5Dclose(dset_id);
@@ -293,3 +319,59 @@ int make_all_objects(hid_t fid)
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: make_special_objects
+ *
+ * Purpose: make a test file with non common items
+ *
+ *-------------------------------------------------------------------------
+ */
+int make_special_objects(hid_t loc_id)
+{
+ hid_t group1_id;
+ hid_t group2_id;
+ hid_t group3_id;
+ hsize_t dims[1]={2};
+ int buf[2]= {1,2};
+
+
+/*-------------------------------------------------------------------------
+ * create a dataset and some hard links to it
+ *-------------------------------------------------------------------------
+ */
+
+ if (write_dset(loc_id,1,dims,"dset",H5T_NATIVE_INT,buf)<0)
+ return -1;
+ if (H5Glink(loc_id, H5G_LINK_HARD, "dset", "link1 to dset")<0)
+ return -1;
+ if (H5Glink(loc_id, H5G_LINK_HARD, "dset", "link2 to dset")<0)
+ return -1;
+ if (H5Glink(loc_id, H5G_LINK_HARD, "dset", "link3 to dset")<0)
+ return -1;
+
+/*-------------------------------------------------------------------------
+ * create a group and some hard links to it
+ *-------------------------------------------------------------------------
+ */
+
+ if ((group1_id = H5Gcreate(loc_id,"g1",0))<0)
+ return -1;
+ if ((group2_id = H5Gcreate(group1_id,"g2",0))<0)
+ return -1;
+ if ((group3_id = H5Gcreate(group2_id,"g3",0))<0)
+ return -1;
+ if (H5Glink(loc_id, H5G_LINK_HARD, "g1", "link1 to g1")<0)
+ return -1;
+ if (H5Glink(loc_id, H5G_LINK_HARD, "g1", "link2 to g1")<0)
+ return -1;
+
+
+ H5Gclose(group1_id);
+ H5Gclose(group2_id);
+
+ return 0;
+
+}
+
diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c
index 0acd632..83b9b77 100644
--- a/tools/h5repack/testh5repack_main.c
+++ b/tools/h5repack/testh5repack_main.c
@@ -42,7 +42,6 @@ test_copy(void)
memset(&diff_options, 0, sizeof (diff_opt_t));
TESTING(" copy with no filters");
-
if (h5repack_init (&pack_options, 0)<0)
TEST_ERROR;
if (h5repack(FNAME1,FNAME1OUT,&pack_options)<0)
@@ -51,8 +50,30 @@ test_copy(void)
TEST_ERROR;
if (h5diff(FNAME1,FNAME1OUT,NULL,NULL,&diff_options) == 1)
TEST_ERROR;
+ PASSED();
+
+ TESTING(" copy of attributes");
+ if (h5repack_init (&pack_options, 0)<0)
+ TEST_ERROR;
+ if (h5repack(FNAME2,FNAME2OUT,&pack_options)<0)
+ TEST_ERROR;
+ if (h5repack_end (&pack_options)<0)
+ TEST_ERROR;
+ if (h5diff(FNAME2,FNAME2OUT,NULL,NULL,&diff_options) == 1)
+ TEST_ERROR;
+ PASSED();
+
+ TESTING(" copy of hardlinks");
+ if (h5repack_init (&pack_options, 0)<0)
+ TEST_ERROR;
+ if (h5repack(FNAME3,FNAME3OUT,&pack_options)<0)
+ TEST_ERROR;
+ if (h5repack_end (&pack_options)<0)
+ TEST_ERROR;
+ if (h5diff(FNAME3,FNAME3OUT,NULL,NULL,&diff_options) == 1)
+ TEST_ERROR;
+ PASSED();
- PASSED();
return 0;
error:
@@ -97,11 +118,11 @@ test_filter_deflate(void)
TEST_ERROR;
if (h5repack_addchunk("dset_gzip:5x4",&pack_options)<0)
TEST_ERROR;
- if (h5repack(FNAME2,FNAME2OUT,&pack_options)<0)
+ if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
TEST_ERROR;
if (h5repack_end (&pack_options)<0)
TEST_ERROR;
- if (h5diff(FNAME2,FNAME2OUT,NULL,NULL,&diff_options) == 1)
+ if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
TEST_ERROR;
PASSED();