mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-18 15:15:56 +08:00
f29e2a01e3
bug fix in H5Zshuffle.c add more tests to h5repack that exposed the bug Description: when creating a dataset with the shuffle filter and duplicating it in a new dataset (file) the call to H5Z_set_local_shuffle failed. this is because the value of cd_nelmts of the filter structure is set to 1 (H5Z_SHUFFLE_TOTAL_NPARMS) when the original dataset is created, but when the new dataset is created there is a checking instruction that fails if the value of cd_nelmts is not 0 (its original value, H5Z_SHUFFLE_USER_NPARMS) Solution: just remove that check condition, since the value of cd_nelmts is not used anyway. if we decide that the value of cd_nelmts is necessary, then the H5O_pline_copy function must be changed to update this value (a different update for each filter) Platforms tested: linux solaris AIX Misc. update:
905 lines
25 KiB
C
905 lines
25 KiB
C
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
* All rights reserved. *
|
|
* *
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
* is linked from the top-level documents page. It can also be found at *
|
|
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
|
|
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
#include "hdf5.h"
|
|
#include "h5test.h"
|
|
#include "h5repack.h"
|
|
#include "h5diff.h"
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: test_copy
|
|
*
|
|
* Purpose:
|
|
*
|
|
* 1) make a copy with no filters
|
|
* 2) use the h5diff utility to compare the input and output file;
|
|
* it returns RET==0 if the objects have the same data
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: 1
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* September, 19, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static int
|
|
test_copy(void)
|
|
{
|
|
pack_opt_t pack_options;
|
|
diff_opt_t diff_options;
|
|
memset(&diff_options, 0, sizeof (diff_opt_t));
|
|
|
|
|
|
TESTING(" copy with no input filters");
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* file with all kinds of dataset datatypes
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME1,FNAME1OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME1,FNAME1OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME1OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_cmpdcpl(FNAME1,FNAME1OUT)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* file with attributes
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME2,FNAME2OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME2,FNAME2OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME2OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_cmpdcpl(FNAME2,FNAME2OUT)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* file with hardlinks
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME3,FNAME3OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME3,FNAME3OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME3OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_cmpdcpl(FNAME3,FNAME3OUT)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* file with filters
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_cmpdcpl(FNAME4,FNAME4OUT)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
/*-------------------------------------------------------------------------
|
|
* end
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
PASSED();
|
|
return 0;
|
|
|
|
error:
|
|
return 1;
|
|
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: test_filter_none
|
|
*
|
|
* Purpose:
|
|
*
|
|
* 1) remove filters form the filter pipeline
|
|
* 2) use the h5diff utility to compare the input and output file;
|
|
* it returns RET==0 if the objects have the same data
|
|
* 3) use API functions to verify the compression/chunking input on the output file
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: 1
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* September, 19, 2003
|
|
*
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static int
|
|
test_filter_none(void)
|
|
{
|
|
pack_opt_t pack_options;
|
|
diff_opt_t diff_options;
|
|
memset(&diff_options, 0, sizeof (diff_opt_t));
|
|
memset(&pack_options, 0, sizeof (pack_opt_t));
|
|
|
|
TESTING(" removing filters");
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test the NONE global option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("NONE",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test the NONE specific option; uncompress a dataset
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("dset_gzip:NONE",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("dset1:NONE",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
PASSED();
|
|
return 0;
|
|
|
|
error:
|
|
return 1;
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: test_filter_deflate
|
|
*
|
|
* Purpose:
|
|
*
|
|
* 1) compress/chunk FILENAME with the DEFLATE filter
|
|
* 2) use the h5diff utility to compare the input and output file;
|
|
* it returns RET==0 if the objects have the same data
|
|
* 3) use API functions to verify the compression/chunking input on the output file
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: 1
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* September, 19, 2003
|
|
*
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static int
|
|
test_filter_deflate(void)
|
|
{
|
|
pack_opt_t pack_options;
|
|
diff_opt_t diff_options;
|
|
memset(&diff_options, 0, sizeof (diff_opt_t));
|
|
memset(&pack_options, 0, sizeof (pack_opt_t));
|
|
|
|
TESTING(" deflate filter");
|
|
|
|
#ifdef H5_HAVE_FILTER_DEFLATE
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test no object option (preserve old filters)
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test an individual object option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("dset1:GZIP 9",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("dset1:CHUNK 20x10",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test all objects option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("GZIP 9",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("CHUNK 20x10",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
|
|
PASSED();
|
|
#else
|
|
SKIPPED();
|
|
#endif
|
|
return 0;
|
|
|
|
#ifdef H5_HAVE_FILTER_DEFLATE
|
|
error:
|
|
return 1;
|
|
#endif
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: test_filter_szip
|
|
*
|
|
* Purpose:
|
|
*
|
|
* 1) compress/chunk FILENAME with the SZIP filter
|
|
* 2) use the h5diff utility to compare the input and output file;
|
|
* it returns RET==0 if the objects have the same data
|
|
* 3) use API functions to verify the compression/chunking input on the output file
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: 1
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* December, 19, 2003
|
|
*
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static int
|
|
test_filter_szip(void)
|
|
{
|
|
pack_opt_t pack_options;
|
|
diff_opt_t diff_options;
|
|
memset(&diff_options, 0, sizeof (diff_opt_t));
|
|
memset(&pack_options, 0, sizeof (pack_opt_t));
|
|
|
|
TESTING(" szip filter");
|
|
|
|
#ifdef H5_HAVE_FILTER_SZIP
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test an individual object option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("dset2:SZIP 8",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("dset2:CHUNK 20x10",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test all objects option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("SZIP 8",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
PASSED();
|
|
#else
|
|
SKIPPED();
|
|
#endif
|
|
return 0;
|
|
|
|
#ifdef H5_HAVE_FILTER_SZIP
|
|
error:
|
|
return 1;
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: test_filter_shuffle
|
|
*
|
|
* Purpose:
|
|
*
|
|
* 1) compress/chunk FILENAME with the shuffle filter
|
|
* 2) use the h5diff utility to compare the input and output file;
|
|
* it returns RET==0 if the objects have the same data
|
|
* 3) use API functions to verify the compression/chunking input on the output file
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: 1
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* September, 19, 2003
|
|
*
|
|
* Modifications:
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static int
|
|
test_filter_shuffle(void)
|
|
{
|
|
pack_opt_t pack_options;
|
|
diff_opt_t diff_options;
|
|
memset(&diff_options, 0, sizeof (diff_opt_t));
|
|
memset(&pack_options, 0, sizeof (pack_opt_t));
|
|
|
|
TESTING(" shuffle filter");
|
|
|
|
#ifdef H5_HAVE_FILTER_SHUFFLE
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test an individual object option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("dset1:SHUF",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("dset1:CHUNK 20x10",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test all objects option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("SHUF",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("CHUNK 20x10",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
PASSED();
|
|
#else
|
|
SKIPPED();
|
|
#endif
|
|
return 0;
|
|
|
|
#ifdef H5_HAVE_FILTER_SHUFFLE
|
|
error:
|
|
return 1;
|
|
#endif
|
|
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: test_filter_checksum
|
|
*
|
|
* Purpose:
|
|
*
|
|
* 1) compress/chunk FILENAME with the checksum filter
|
|
* 2) use the h5diff utility to compare the input and output file;
|
|
* it returns RET==0 if the objects have the same data
|
|
* 3) use API functions to verify the compression/chunking input on the output file
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: 1
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* September, 19, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static int
|
|
test_filter_checksum(void)
|
|
{
|
|
pack_opt_t pack_options;
|
|
diff_opt_t diff_options;
|
|
memset(&diff_options, 0, sizeof (diff_opt_t));
|
|
memset(&pack_options, 0, sizeof (pack_opt_t));
|
|
|
|
TESTING(" checksum filter");
|
|
|
|
#ifdef H5_HAVE_FILTER_FLETCHER32
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test an individual object option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("dset1:FLET",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("dset1:CHUNK 20x10",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test all objects option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("FLET",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("CHUNK 20x10",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
PASSED();
|
|
#else
|
|
SKIPPED();
|
|
#endif
|
|
return 0;
|
|
|
|
#ifdef H5_HAVE_FILTER_FLETCHER32
|
|
error:
|
|
return 1;
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: test_layout_chunked
|
|
*
|
|
* Purpose:
|
|
*
|
|
* 1) test the CHUNK layout options
|
|
* 2) use the h5diff utility to compare the input and output file;
|
|
* it returns RET==0 if the objects have the same data
|
|
* 3) use API functions to verify the layout input on the output file
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: 1
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* December 30, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static int
|
|
test_layout_chunked(void)
|
|
{
|
|
pack_opt_t pack_options;
|
|
diff_opt_t diff_options;
|
|
memset(&diff_options, 0, sizeof (diff_opt_t));
|
|
memset(&pack_options, 0, sizeof (pack_opt_t));
|
|
|
|
TESTING(" layout chunked");
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test an individual object option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("dset1:CHUNK 20x10",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test all objects option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("CHUNK 20x10",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
PASSED();
|
|
return 0;
|
|
|
|
error:
|
|
return 1;
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: test_layout_contiguous
|
|
*
|
|
* Purpose:
|
|
*
|
|
* 1) test the CONTI layout options
|
|
* 2) use the h5diff utility to compare the input and output file;
|
|
* it returns RET==0 if the objects have the same data
|
|
* 3) use API functions to verify the layout input on the output file
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: 1
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* December 30, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static int
|
|
test_layout_contiguous(void)
|
|
{
|
|
pack_opt_t pack_options;
|
|
diff_opt_t diff_options;
|
|
memset(&diff_options, 0, sizeof (diff_opt_t));
|
|
memset(&pack_options, 0, sizeof (pack_opt_t));
|
|
|
|
TESTING(" layout contiguous");
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test an individual object option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("dset1:CONTI",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test all objects option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("CONTI",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
PASSED();
|
|
return 0;
|
|
|
|
error:
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: test_layout_compact
|
|
*
|
|
* Purpose:
|
|
*
|
|
* 1) test the COMPA layout options
|
|
* 2) use the h5diff utility to compare the input and output file;
|
|
* it returns RET==0 if the objects have the same data
|
|
* 3) use API functions to verify the layout input on the output file
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: 1
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* December 30, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static int
|
|
test_layout_compact(void)
|
|
{
|
|
pack_opt_t pack_options;
|
|
diff_opt_t diff_options;
|
|
memset(&diff_options, 0, sizeof (diff_opt_t));
|
|
memset(&pack_options, 0, sizeof (pack_opt_t));
|
|
|
|
TESTING(" layout compact");
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test an individual object option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("dset1:COMPA",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* test all objects option
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("COMPA",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
PASSED();
|
|
return 0;
|
|
|
|
error:
|
|
return 1;
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: test_filterqueue
|
|
*
|
|
* Purpose:
|
|
*
|
|
* 1) test several filters
|
|
* 2) use the h5diff utility to compare the input and output file;
|
|
* it returns RET==0 if the objects have the same data
|
|
* 3) use API functions to verify the input on the output file
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: 1
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* January 5, 2004
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static int
|
|
test_filterqueue(void)
|
|
{
|
|
pack_opt_t pack_options;
|
|
diff_opt_t diff_options;
|
|
memset(&diff_options, 0, sizeof (diff_opt_t));
|
|
memset(&pack_options, 0, sizeof (pack_opt_t));
|
|
|
|
TESTING(" filter queue");
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* add some filters
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (h5repack_init (&pack_options, 0)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addlayout("dset1:CHUNK 20x10",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("dset1:FLET",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("dset1:SHUF",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("dset1:SZIP 8",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack_addfilter("dset1:GZIP 1",&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5repack(FNAME4,FNAME4OUT,&pack_options)<0)
|
|
TEST_ERROR;
|
|
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) == 1)
|
|
TEST_ERROR;
|
|
if (h5repack_verify(FNAME4OUT,&pack_options)<=0)
|
|
TEST_ERROR;
|
|
if (h5repack_end (&pack_options)<0)
|
|
TEST_ERROR;
|
|
|
|
PASSED();
|
|
return 0;
|
|
|
|
error:
|
|
return 1;
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: main
|
|
*
|
|
* Purpose: Executes h5repack tests
|
|
*
|
|
* Return: Success: zero
|
|
* Failure: non-zero
|
|
*
|
|
* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
|
|
* January, 6, 2004
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
|
|
int main (void)
|
|
{
|
|
int nerrors=0;
|
|
|
|
/* run tests */
|
|
puts("Testing h5repack:");
|
|
|
|
/* make the test files */
|
|
if (make_testfiles()<0)
|
|
goto error;
|
|
|
|
/* test a copy with no filters */
|
|
nerrors += test_copy();
|
|
|
|
/* test a copy with the delete filters option */
|
|
nerrors += test_filter_none();
|
|
|
|
/* test a copy with the deflate filter */
|
|
nerrors += test_filter_deflate();
|
|
|
|
/* test a copy with the szip filter */
|
|
nerrors += test_filter_szip();
|
|
|
|
/* test a copy with the shuffle filter */
|
|
nerrors += test_filter_shuffle();
|
|
|
|
/* test a copy with the checksum filter */
|
|
nerrors += test_filter_checksum();
|
|
|
|
/* test a copy with layout CHUNK options */
|
|
nerrors += test_layout_chunked();
|
|
|
|
/* test a copy with layout CONTI options */
|
|
nerrors += test_layout_contiguous();
|
|
|
|
/* test a copy with layout COMPA options */
|
|
nerrors += test_layout_compact();
|
|
|
|
/* test a copy with all available filters */
|
|
nerrors += test_filterqueue();
|
|
|
|
/* check for errors */
|
|
if (nerrors)
|
|
goto error;
|
|
puts("All h5repack tests passed.");
|
|
|
|
return 0;
|
|
|
|
error:
|
|
puts("***** H5REPACK TESTS FAILED *****");
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|