summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-04-09 14:20:49 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-04-09 14:20:49 (GMT)
commit00235dba7e54a387783b2a2abb680ac32d7d8985 (patch)
treea14c84ff963a8281337d75b1fafc46c3d8ad9b9a
parent8c0626ff5b52571a237e4890262f258d68545cc3 (diff)
downloadhdf5-00235dba7e54a387783b2a2abb680ac32d7d8985.zip
hdf5-00235dba7e54a387783b2a2abb680ac32d7d8985.tar.gz
hdf5-00235dba7e54a387783b2a2abb680ac32d7d8985.tar.bz2
[svn-r8333] Purpose:
new test Description: add a test that generates a file with "holes" and then uses h5repack to clean the empty space. it works Solution: Platforms tested: linux Misc. update:
-rw-r--r--tools/h5repack/h5repack.h3
-rw-r--r--tools/h5repack/testh5repack_main.c25
-rw-r--r--tools/h5repack/testh5repack_make.c106
3 files changed, 133 insertions, 1 deletions
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h
index 6d67d69..8e7e195 100644
--- a/tools/h5repack/h5repack.h
+++ b/tools/h5repack/h5repack.h
@@ -271,6 +271,9 @@ int parse_number(char *str);
#define FNAME3OUT "test3out.h5"
#define FNAME4 "test4.h5"
#define FNAME4OUT "test4out.h5"
+#define FNAME5 "test5.h5"
+#define FNAME5OUT "test5out.h5"
+#define FNAME6 "test6.h5"
int make_testfiles(void);
diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c
index 2faf20a..ddecd98 100644
--- a/tools/h5repack/testh5repack_main.c
+++ b/tools/h5repack/testh5repack_main.c
@@ -139,6 +139,24 @@ int main (void)
PASSED();
+ TESTING(" copy of allocation early file");
+
+/*-------------------------------------------------------------------------
+ * alloc early test
+ *-------------------------------------------------------------------------
+ */
+ if (h5repack_init (&pack_options, 0)<0)
+ TEST_ERROR;
+ if (h5repack(FNAME5,FNAME5OUT,&pack_options)<0)
+ TEST_ERROR;
+ if (h5diff(FNAME5,FNAME5OUT,NULL,NULL,&diff_options) == 1)
+ TEST_ERROR;
+ if (h5repack_verify(FNAME5OUT,&pack_options)<=0)
+ TEST_ERROR;
+ if (h5repack_end (&pack_options)<0)
+ TEST_ERROR;
+ PASSED();
+
TESTING(" removing all filters");
/*-------------------------------------------------------------------------
@@ -893,8 +911,13 @@ TESTING(" addding shuffle filter to all");
TEST_ERROR;
PASSED();
+
-
+
+/*-------------------------------------------------------------------------
+ * end
+ *-------------------------------------------------------------------------
+ */
puts("All h5repack tests passed.");
diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c
index fbf5cf5..3b8cb5c 100644
--- a/tools/h5repack/testh5repack_make.c
+++ b/tools/h5repack/testh5repack_make.c
@@ -20,6 +20,8 @@
int make_all_objects(hid_t loc_id);
int make_attributes(hid_t loc_id);
int make_special_objects(hid_t loc_id);
+int make_early();
+
/*-------------------------------------------------------------------------
@@ -79,6 +81,14 @@ int make_testfiles(void)
goto out;
if(H5Fclose(loc_id)<0)
return -1;
+
+/*-------------------------------------------------------------------------
+ * create a file for the H5D_ALLOC_TIME_EARLY test
+ *-------------------------------------------------------------------------
+ */
+ if (make_early()<0)
+ goto out;
+
PASSED();
return 0;
@@ -293,3 +303,99 @@ int make_special_objects(hid_t loc_id)
}
+/*-------------------------------------------------------------------------
+ * Function: make_early
+ *
+ * Purpose: create a file for the H5D_ALLOC_TIME_EARLY test
+ *
+ *-------------------------------------------------------------------------
+ */
+int make_early()
+{
+ hsize_t dims[1] ={3000};
+ hsize_t cdims[1]={30};
+ hid_t fid;
+ hid_t dset_id;
+ hid_t sid;
+ hid_t tid;
+ hid_t dcpl;
+ int i;
+ char name[10];
+ int iter=100;
+
+ if ((fid = H5Fcreate(FNAME5,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
+ return -1;
+ if (H5Fclose(fid)<0)
+ goto out;
+
+ if ((sid = H5Screate_simple(1, dims, NULL))<0)
+ goto out;
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0)
+ goto out;
+ if (H5Pset_chunk(dcpl,1,cdims)<0)
+ goto out;
+ if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY)<0)
+ goto out;
+
+ for (i=0; i<iter; i++)
+ {
+ if ((fid = H5Fopen(FNAME5,H5F_ACC_RDWR,H5P_DEFAULT))<0)
+ goto out;
+ if ((dset_id = H5Dcreate(fid,"early",H5T_NATIVE_DOUBLE,sid,dcpl))<0)
+ goto out;
+ if ((tid = H5Tcopy(H5T_NATIVE_DOUBLE))<0)
+ goto out;
+ sprintf(name,"%d", i);
+ if ((H5Tcommit(fid,name,tid))<0)
+ goto out;
+ if (H5Tclose(tid)<0)
+ goto out;
+ if (H5Dclose(dset_id)<0)
+ goto out;
+ if (H5Gunlink(fid,"early")<0)
+ goto out;
+ if (H5Fclose(fid)<0)
+ goto out;
+ }
+
+/*-------------------------------------------------------------------------
+ * do the same without close/opening the file and creating the dataset
+ *-------------------------------------------------------------------------
+ */
+
+ if ((fid = H5Fcreate(FNAME6,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
+ return -1;
+
+ for (i=0; i<iter; i++)
+ {
+ if ((tid = H5Tcopy(H5T_NATIVE_DOUBLE))<0)
+ goto out;
+ sprintf(name,"%d", i);
+ if ((H5Tcommit(fid,name,tid))<0)
+ goto out;
+ if (H5Tclose(tid)<0)
+ goto out;
+ }
+
+ if (H5Sclose(sid)<0)
+ goto out;
+ if (H5Pclose(dcpl)<0)
+ goto out;
+ if (H5Fclose(fid)<0)
+ goto out;
+
+
+ return 0;
+
+out:
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Pclose(dcpl);
+ H5Sclose(sid);
+ H5Dclose(dset_id);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return -1;
+}
+
+