[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:
This commit is contained in:
Pedro Vicente Nunes 2004-04-09 09:20:49 -05:00
parent 8c0626ff5b
commit 00235dba7e
3 changed files with 133 additions and 1 deletions

View File

@ -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);

View File

@ -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.");

View File

@ -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;
}