mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-12-15 07:40:23 +08:00
HDFFV-10143 clean up format and function return
This commit is contained in:
parent
f9199536d0
commit
ed98dc0419
362
test/plugin.c
362
test/plugin.c
@ -78,19 +78,16 @@ int points_deflate[DSET_DIM1][DSET_DIM2],
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: -1
|
||||
*
|
||||
* Programmer: Raymond Lu
|
||||
* 27 February 2013
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
{
|
||||
hid_t dataset; /* Dataset ID */
|
||||
hid_t dxpl; /* Dataset xfer property list ID */
|
||||
hid_t write_dxpl; /* Dataset xfer property list ID for writing */
|
||||
hid_t sid; /* Dataspace ID */
|
||||
herr_t ret_value = -1;
|
||||
hid_t dataset = -1; /* Dataset ID */
|
||||
hid_t dxpl = -1; /* Dataset xfer property list ID */
|
||||
hid_t write_dxpl = -1; /* Dataset xfer property list ID for writing */
|
||||
hid_t sid = -1; /* Dataspace ID */
|
||||
const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
|
||||
const hsize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */
|
||||
const hsize_t hs_size[2] = {FILTER_HS_SIZE1, FILTER_HS_SIZE2}; /* Hyperslab size */
|
||||
@ -121,8 +118,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
} /* end if */
|
||||
|
||||
/* Create the dataset */
|
||||
if((dataset = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT,
|
||||
dcpl, H5P_DEFAULT)) < 0) TEST_ERROR
|
||||
if((dataset = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR
|
||||
|
||||
PASSED();
|
||||
|
||||
@ -132,20 +128,16 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
*/
|
||||
TESTING(" filters (uninitialized read)");
|
||||
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0)
|
||||
TEST_ERROR;
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR;
|
||||
|
||||
for(i=0; i<(size_t)size[0]; i++) {
|
||||
for(j=0; j<(size_t)size[1]; j++) {
|
||||
for(i=0; i<(size_t)size[0]; i++)
|
||||
for(j=0; j<(size_t)size[1]; j++)
|
||||
if(0 != check[i][j]) {
|
||||
H5_FAILED();
|
||||
HDprintf(" Read a non-zero value.\n");
|
||||
HDprintf(" At index %lu,%lu\n",
|
||||
(unsigned long)i, (unsigned long)j);
|
||||
HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
|
||||
TEST_ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* end if */
|
||||
PASSED();
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
@ -156,14 +148,11 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
TESTING(" filters (write)");
|
||||
|
||||
n = 0;
|
||||
for(i=0; i<size[0]; i++) {
|
||||
for(j=0; j<size[1]; j++) {
|
||||
for(i=0; i<size[0]; i++)
|
||||
for(j=0; j<size[1]; j++)
|
||||
points[i][j] = (int)(n++);
|
||||
}
|
||||
}
|
||||
|
||||
if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0)
|
||||
TEST_ERROR;
|
||||
if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0) TEST_ERROR;
|
||||
|
||||
PASSED();
|
||||
|
||||
@ -174,12 +163,11 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
TESTING(" filters (read)");
|
||||
|
||||
/* Read the dataset back */
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0)
|
||||
TEST_ERROR;
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR;
|
||||
|
||||
/* Check that the values read are the same as the values written */
|
||||
for(i=0; i<size[0]; i++) {
|
||||
for(j=0; j<size[1]; j++) {
|
||||
for(i=0; i<size[0]; i++)
|
||||
for(j=0; j<size[1]; j++)
|
||||
if(points[i][j] != check[i][j]) {
|
||||
H5_FAILED();
|
||||
HDfprintf(stderr," Read different values than written.\n");
|
||||
@ -187,9 +175,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
HDfprintf(stderr," At original: %d\n", (int)points[i][j]);
|
||||
HDfprintf(stderr," At returned: %d\n", (int)check[i][j]);
|
||||
TEST_ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* end if */
|
||||
|
||||
PASSED();
|
||||
|
||||
@ -202,30 +188,24 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
*/
|
||||
TESTING(" filters (modify)");
|
||||
|
||||
for(i=0; i<size[0]; i++) {
|
||||
for(j=0; j<size[1]/2; j++) {
|
||||
for(i=0; i<size[0]; i++)
|
||||
for(j=0; j<size[1]/2; j++)
|
||||
points[i][j] = (int)HDrandom () % RANDOM_LIMIT;
|
||||
}
|
||||
}
|
||||
if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0) TEST_ERROR;
|
||||
|
||||
/* Read the dataset back and check it */
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0)
|
||||
TEST_ERROR;
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR;
|
||||
|
||||
/* Check that the values read are the same as the values written */
|
||||
for(i=0; i<size[0]; i++) {
|
||||
for(j=0; j<size[1]; j++) {
|
||||
for(i=0; i<size[0]; i++)
|
||||
for(j=0; j<size[1]; j++)
|
||||
if(points[i][j] != check[i][j]) {
|
||||
H5_FAILED();
|
||||
HDprintf(" Read different values than written.\n");
|
||||
HDprintf(" At index %lu,%lu\n",
|
||||
(unsigned long)i, (unsigned long)j);
|
||||
HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
|
||||
TEST_ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* end if */
|
||||
|
||||
PASSED();
|
||||
|
||||
@ -240,8 +220,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
if(H5Dclose(dataset) < 0) TEST_ERROR;
|
||||
if((dataset = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) TEST_ERROR;
|
||||
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0)
|
||||
TEST_ERROR;
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR;
|
||||
|
||||
/* Check that the values read are the same as the values written */
|
||||
for(i = 0; i < size[0]; i++)
|
||||
@ -249,8 +228,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
if(points[i][j] != check[i][j]) {
|
||||
H5_FAILED();
|
||||
HDprintf(" Read different values than written.\n");
|
||||
HDprintf(" At index %lu,%lu\n",
|
||||
(unsigned long)i, (unsigned long)j);
|
||||
HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
|
||||
TEST_ERROR
|
||||
} /* end if */
|
||||
|
||||
@ -264,89 +242,72 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
*/
|
||||
TESTING(" filters (partial I/O)");
|
||||
|
||||
for(i=0; i<(size_t)hs_size[0]; i++) {
|
||||
for(j=0; j<(size_t)hs_size[1]; j++) {
|
||||
for(i=0; i<(size_t)hs_size[0]; i++)
|
||||
for(j=0; j<(size_t)hs_size[1]; j++)
|
||||
points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] = (int)HDrandom() % RANDOM_LIMIT;
|
||||
}
|
||||
}
|
||||
if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size,
|
||||
NULL) < 0) TEST_ERROR;
|
||||
/* (Use the "read" DXPL because partial I/O on corrupted data test needs to ignore errors during writing) */
|
||||
if(H5Dwrite (dataset, H5T_NATIVE_INT, sid, sid, dxpl, points) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
if(H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check) < 0)
|
||||
TEST_ERROR;
|
||||
if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) TEST_ERROR;
|
||||
/* (Use the "read" DXPL because partial I/O on corrupted data test needs to ignore errors during writing) */
|
||||
if(H5Dwrite(dataset, H5T_NATIVE_INT, sid, sid, dxpl, points) < 0) TEST_ERROR;
|
||||
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, sid, sid, dxpl, check) < 0) TEST_ERROR;
|
||||
|
||||
/* Check that the values read are the same as the values written */
|
||||
for(i=0; i<(size_t)hs_size[0]; i++) {
|
||||
for(j=0; j<(size_t)hs_size[1]; j++) {
|
||||
if(points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] !=
|
||||
check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]) {
|
||||
for(i=0; i<(size_t)hs_size[0]; i++)
|
||||
for(j=0; j<(size_t)hs_size[1]; j++)
|
||||
if(points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] != check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]) {
|
||||
H5_FAILED();
|
||||
HDfprintf(stderr," Read different values than written.\n");
|
||||
HDfprintf(stderr," At index %lu,%lu\n",
|
||||
(unsigned long)((size_t)hs_offset[0]+i),
|
||||
(unsigned long)((size_t)hs_offset[1]+j));
|
||||
HDfprintf(stderr," At original: %d\n",
|
||||
(int)points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]);
|
||||
HDfprintf(stderr," At returned: %d\n",
|
||||
(int)check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]);
|
||||
HDfprintf(stderr," At index %lu,%lu\n", (unsigned long)((size_t)hs_offset[0]+i), (unsigned long)((size_t)hs_offset[1]+j));
|
||||
HDfprintf(stderr," At original: %d\n", (int)points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]);
|
||||
HDfprintf(stderr," At returned: %d\n", (int)check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]);
|
||||
TEST_ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* end if */
|
||||
|
||||
PASSED();
|
||||
|
||||
/* Save the data written to the file for later comparison when the file
|
||||
* is reopened for read test */
|
||||
for(i=0; i<size[0]; i++) {
|
||||
for(j=0; j<size[1]; j++) {
|
||||
if(!HDstrcmp(name, DSET_DEFLATE_NAME)) {
|
||||
for(i=0; i<size[0]; i++)
|
||||
for(j=0; j<size[1]; j++)
|
||||
if(!HDstrcmp(name, DSET_DEFLATE_NAME))
|
||||
points_deflate[i][j] = points[i][j];
|
||||
} else if(!HDstrcmp(name, DSET_DYNLIB1_NAME)) {
|
||||
else if(!HDstrcmp(name, DSET_DYNLIB1_NAME))
|
||||
points_dynlib1[i][j] = points[i][j];
|
||||
} else if(!HDstrcmp(name, DSET_DYNLIB2_NAME)) {
|
||||
else if(!HDstrcmp(name, DSET_DYNLIB2_NAME))
|
||||
points_dynlib2[i][j] = points[i][j];
|
||||
} else if(!HDstrcmp(name, DSET_DYNLIB4_NAME)) {
|
||||
else if(!HDstrcmp(name, DSET_DYNLIB4_NAME))
|
||||
points_dynlib4[i][j] = points[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Clean up objects used for this test */
|
||||
if(H5Dclose (dataset) < 0) TEST_ERROR
|
||||
if(H5Sclose (sid) < 0) TEST_ERROR
|
||||
if(H5Pclose (dxpl) < 0) TEST_ERROR
|
||||
free (tconv_buf);
|
||||
|
||||
return(0);
|
||||
ret_value = 0;
|
||||
|
||||
error:
|
||||
/* Clean up objects used for this test */
|
||||
H5E_BEGIN_TRY {
|
||||
H5Dclose(dataset);
|
||||
H5Sclose(sid);
|
||||
H5Pclose(dxpl);
|
||||
} H5E_END_TRY
|
||||
|
||||
if(tconv_buf)
|
||||
free (tconv_buf);
|
||||
return -1;
|
||||
HDfree(tconv_buf);
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: test_filters_for_datasets
|
||||
*
|
||||
* Purpose: Tests creating datasets and writing data with dynamically
|
||||
* loaded filters
|
||||
* Purpose: Tests creating datasets and writing data with dynamically loaded filters
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: -1
|
||||
*
|
||||
* Programmer: Raymond Lu
|
||||
* 14 March 2013
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_filters_for_datasets(hid_t file)
|
||||
{
|
||||
hid_t dc; /* Dataset creation property list ID */
|
||||
herr_t ret_value = -1;
|
||||
hid_t dc = -1; /* Dataset creation property list ID */
|
||||
const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */
|
||||
unsigned int compress_level = 9;
|
||||
unsigned int dynlib4_values[4];
|
||||
@ -428,10 +389,15 @@ test_filters_for_datasets(hid_t file)
|
||||
* for this filter. */
|
||||
if(H5Zunregister(H5Z_FILTER_DYNLIB4) < 0) TEST_ERROR
|
||||
|
||||
return 0;
|
||||
ret_value = 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
/* Clean up objects used for this test */
|
||||
H5E_BEGIN_TRY {
|
||||
H5Pclose(dc);
|
||||
} H5E_END_TRY
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -441,26 +407,22 @@ error:
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: -1
|
||||
*
|
||||
* Programmer: Raymond Lu
|
||||
* 14 March 2013
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_read_data(hid_t dataset, int *origin_data)
|
||||
{
|
||||
herr_t ret_value = -1;
|
||||
int check[DSET_DIM1][DSET_DIM2];
|
||||
const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
|
||||
int *data_p = origin_data;
|
||||
size_t i, j; /* Local index variables */
|
||||
|
||||
/* Read the dataset back */
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0)
|
||||
TEST_ERROR;
|
||||
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) TEST_ERROR;
|
||||
|
||||
/* Check that the values read are the same as the values written */
|
||||
for(i=0; i<size[0]; i++) {
|
||||
for(i=0; i<size[0]; i++)
|
||||
for(j=0; j<size[1]; j++) {
|
||||
if(*data_p != check[i][j]) {
|
||||
H5_FAILED();
|
||||
@ -469,16 +431,15 @@ test_read_data(hid_t dataset, int *origin_data)
|
||||
HDfprintf(stderr," At original: %d\n", *data_p);
|
||||
HDfprintf(stderr," At returned: %d\n", (int)check[i][j]);
|
||||
TEST_ERROR
|
||||
}
|
||||
} /* end if */
|
||||
data_p++;
|
||||
}
|
||||
}
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
ret_value = 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -488,16 +449,13 @@ error:
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: -1
|
||||
*
|
||||
* Programmer: Raymond Lu
|
||||
* 14 March 2013
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_read_with_filters(hid_t file)
|
||||
{
|
||||
hid_t dset; /* Dataset ID */
|
||||
herr_t ret_value = -1;
|
||||
hid_t dset = -1; /* Dataset ID */
|
||||
|
||||
/*----------------------------------------------------------
|
||||
* STEP 1: Test deflation by itself.
|
||||
@ -556,10 +514,15 @@ test_read_with_filters(hid_t file)
|
||||
|
||||
if(H5Dclose(dset) < 0) TEST_ERROR
|
||||
|
||||
return 0;
|
||||
ret_value = 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
/* Clean up objects used for this test */
|
||||
H5E_BEGIN_TRY {
|
||||
H5Dclose(dset);
|
||||
} H5E_END_TRY
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -575,8 +538,9 @@ error:
|
||||
static herr_t
|
||||
test_noread_data(hid_t dataset)
|
||||
{
|
||||
herr_t ret_value = -1;
|
||||
int check[DSET_DIM1][DSET_DIM2];
|
||||
herr_t ret;
|
||||
herr_t ret = -1;
|
||||
|
||||
/* Read the dataset back */
|
||||
H5E_BEGIN_TRY {
|
||||
@ -586,10 +550,10 @@ test_noread_data(hid_t dataset)
|
||||
TEST_ERROR
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
ret_value = 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -599,14 +563,15 @@ error:
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: -1
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_noread_with_filters(hid_t file)
|
||||
{
|
||||
hid_t dset; /* Dataset ID */
|
||||
herr_t ret_value = -1;
|
||||
hid_t dset = -1; /* Dataset ID */
|
||||
unsigned plugin_state; /* status of plugins */
|
||||
|
||||
TESTING("DYNLIB1 filter with plugins disabled");
|
||||
|
||||
/* disable filter plugin */
|
||||
@ -620,17 +585,19 @@ test_noread_with_filters(hid_t file)
|
||||
|
||||
if(H5Dclose(dset) < 0) TEST_ERROR
|
||||
|
||||
/* re-enable filter plugin */
|
||||
plugin_state = plugin_state | H5PL_FILTER_PLUGIN;
|
||||
if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
|
||||
|
||||
return 0;
|
||||
ret_value = 0;
|
||||
|
||||
error:
|
||||
/* re-enable filter plugin */
|
||||
plugin_state = plugin_state | H5PL_FILTER_PLUGIN;
|
||||
if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
|
||||
return -1;
|
||||
H5PLset_loading_state(plugin_state);
|
||||
|
||||
/* Clean up objects used for this test */
|
||||
H5E_BEGIN_TRY {
|
||||
H5Dclose(dset);
|
||||
} H5E_END_TRY
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -640,16 +607,15 @@ error:
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: -1
|
||||
*
|
||||
* Programmer: Raymond Lu
|
||||
* 1 April 2013
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_filters_for_groups(hid_t file)
|
||||
{
|
||||
hid_t gcpl, gid, group;
|
||||
herr_t ret_value = -1;
|
||||
hid_t gcpl = -1;
|
||||
hid_t gid = -1;
|
||||
hid_t group = -1;
|
||||
int i;
|
||||
char gname[256];
|
||||
|
||||
@ -678,10 +644,17 @@ test_filters_for_groups(hid_t file)
|
||||
|
||||
PASSED();
|
||||
|
||||
return 0;
|
||||
ret_value = 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
/* Clean up objects used for this test */
|
||||
H5E_BEGIN_TRY {
|
||||
H5Gclose(group);
|
||||
H5Gclose(gid);
|
||||
H5Pclose(gcpl);
|
||||
} H5E_END_TRY
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -700,7 +673,9 @@ error:
|
||||
static herr_t
|
||||
test_groups_with_filters(hid_t file)
|
||||
{
|
||||
hid_t gid, group;
|
||||
herr_t ret_value = -1;
|
||||
hid_t gid;
|
||||
hid_t group;
|
||||
int i;
|
||||
char gname[256];
|
||||
|
||||
@ -721,10 +696,16 @@ test_groups_with_filters(hid_t file)
|
||||
|
||||
PASSED();
|
||||
|
||||
return 0;
|
||||
ret_value = 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
/* Clean up objects used for this test */
|
||||
H5E_BEGIN_TRY {
|
||||
H5Gclose(group);
|
||||
H5Gclose(gid);
|
||||
} H5E_END_TRY
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
|
||||
@ -735,12 +716,12 @@ error:
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: -1
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_filter_path_apis(void)
|
||||
{
|
||||
herr_t ret_value = -1;
|
||||
unsigned int i;
|
||||
unsigned int ndx;
|
||||
herr_t ret;
|
||||
@ -756,12 +737,11 @@ test_filter_path_apis(void)
|
||||
|
||||
TESTING(" remove");
|
||||
/* Remove all existing paths*/
|
||||
for (i=ndx; i > 0; i--) {
|
||||
for(i=ndx; i > 0; i--)
|
||||
if(H5PLremove(i-1) < 0) {
|
||||
HDfprintf(stderr," at %d: %s\n", i, pathname);
|
||||
TEST_ERROR
|
||||
}
|
||||
}
|
||||
} /* end if */
|
||||
/* Verify the table is empty */
|
||||
if(H5PLsize() > 0) TEST_ERROR
|
||||
PASSED();
|
||||
@ -771,8 +751,7 @@ test_filter_path_apis(void)
|
||||
H5E_BEGIN_TRY {
|
||||
ret = H5PLremove(0);
|
||||
} H5E_END_TRY
|
||||
if (ret >= 0)
|
||||
TEST_ERROR
|
||||
if(ret >= 0) TEST_ERROR
|
||||
PASSED();
|
||||
|
||||
TESTING(" append");
|
||||
@ -794,16 +773,14 @@ test_filter_path_apis(void)
|
||||
HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM);
|
||||
ret = H5PLappend(pathname);
|
||||
} H5E_END_TRY
|
||||
if (ret >= 0)
|
||||
TEST_ERROR
|
||||
if(ret >= 0) TEST_ERROR
|
||||
|
||||
TESTING(" remove (exceed max)");
|
||||
/* Exceed the max path removal */
|
||||
H5E_BEGIN_TRY {
|
||||
ret = H5PLremove(H5PL_MAX_PATH_NUM);
|
||||
} H5E_END_TRY
|
||||
if (ret >= 0)
|
||||
TEST_ERROR
|
||||
if(ret >= 0) TEST_ERROR
|
||||
PASSED();
|
||||
|
||||
TESTING(" get (path name)");
|
||||
@ -811,9 +788,8 @@ test_filter_path_apis(void)
|
||||
HDfprintf(stderr," get path 0 length failed\n");
|
||||
TEST_ERROR
|
||||
}
|
||||
if (pathlen != 8) {
|
||||
TEST_ERROR
|
||||
}
|
||||
if(pathlen != 8) TEST_ERROR
|
||||
|
||||
if((pathlen = H5PLget(0, pathname, 256)) <= 0) {
|
||||
HDfprintf(stderr," get 0 len: %d : %s\n", pathlen, pathname);
|
||||
TEST_ERROR
|
||||
@ -825,14 +801,12 @@ test_filter_path_apis(void)
|
||||
PASSED();
|
||||
|
||||
TESTING(" get (bounds)");
|
||||
if ((pathlen = H5PLget(1, pathname, 256)) <= 0)
|
||||
TEST_ERROR
|
||||
if((pathlen = H5PLget(1, pathname, 256)) <= 0) TEST_ERROR
|
||||
if(HDstrcmp(pathname, "a_path_1") != 0) {
|
||||
HDfprintf(stderr," get 1: %s\n", pathname);
|
||||
TEST_ERROR
|
||||
}
|
||||
if ((pathlen = H5PLget(H5PL_MAX_PATH_NUM - 1, pathname, 256)) <= 0)
|
||||
TEST_ERROR
|
||||
if((pathlen = H5PLget(H5PL_MAX_PATH_NUM - 1, pathname, 256)) <= 0) TEST_ERROR
|
||||
HDsprintf(tempname, "a_path_%d", H5PL_MAX_PATH_NUM - 1);
|
||||
if(HDstrcmp(pathname, tempname) != 0) {
|
||||
HDfprintf(stderr," get %d: %s\n", H5PL_MAX_PATH_NUM - 1, pathname);
|
||||
@ -844,8 +818,7 @@ test_filter_path_apis(void)
|
||||
H5E_BEGIN_TRY {
|
||||
pathlen = H5PLget(H5PL_MAX_PATH_NUM, NULL, 0);
|
||||
} H5E_END_TRY
|
||||
if (pathlen > 0)
|
||||
TEST_ERROR
|
||||
if(pathlen > 0) TEST_ERROR
|
||||
PASSED();
|
||||
|
||||
TESTING(" remove (verify for prepend)");
|
||||
@ -853,8 +826,7 @@ test_filter_path_apis(void)
|
||||
if(H5PLremove(8) < 0) TEST_ERROR
|
||||
|
||||
/* Verify that the entries were moved */
|
||||
if ((pathlen = H5PLget(8, pathname, 256)) <= 0)
|
||||
TEST_ERROR
|
||||
if((pathlen = H5PLget(8, pathname, 256)) <= 0) TEST_ERROR
|
||||
if(HDstrcmp(pathname, "a_path_9") != 0) {
|
||||
HDfprintf(stderr," get 8: %s\n", pathname);
|
||||
TEST_ERROR
|
||||
@ -876,14 +848,12 @@ test_filter_path_apis(void)
|
||||
if(H5PLsize() != H5PL_MAX_PATH_NUM) TEST_ERROR
|
||||
|
||||
/* Verify that the entries were moved */
|
||||
if (H5PLget(8, pathname, 256) <= 0)
|
||||
TEST_ERROR
|
||||
if(H5PLget(8, pathname, 256) <= 0) TEST_ERROR
|
||||
if(HDstrcmp(pathname, "a_path_7") != 0) {
|
||||
HDfprintf(stderr," get 8: %s\n", pathname);
|
||||
TEST_ERROR
|
||||
}
|
||||
if (H5PLget(0, pathname, 256) <= 0)
|
||||
TEST_ERROR
|
||||
if(H5PLget(0, pathname, 256) <= 0) TEST_ERROR
|
||||
HDsprintf(tempname, "a_path_%d", H5PL_MAX_PATH_NUM + 1);
|
||||
if(HDstrcmp(pathname, tempname) != 0) {
|
||||
HDfprintf(stderr," get 0: %s\n", pathname);
|
||||
@ -897,8 +867,7 @@ test_filter_path_apis(void)
|
||||
HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 2);
|
||||
ret = H5PLprepend(pathname);
|
||||
} H5E_END_TRY
|
||||
if (ret >= 0)
|
||||
TEST_ERROR
|
||||
if(ret >= 0) TEST_ERROR
|
||||
PASSED();
|
||||
|
||||
TESTING(" replace");
|
||||
@ -913,15 +882,13 @@ test_filter_path_apis(void)
|
||||
if(H5PLsize() != H5PL_MAX_PATH_NUM) TEST_ERROR
|
||||
|
||||
/* Verify that the entries were not moved */
|
||||
if (H5PLget(0, pathname, 256) <= 0)
|
||||
TEST_ERROR
|
||||
if(H5PLget(0, pathname, 256) <= 0) TEST_ERROR
|
||||
HDsprintf(tempname, "a_path_%d", H5PL_MAX_PATH_NUM + 1);
|
||||
if(HDstrcmp(pathname, tempname) != 0) {
|
||||
HDfprintf(stderr," get 0: %s\n", pathname);
|
||||
TEST_ERROR
|
||||
}
|
||||
if (H5PLget(2, pathname, 256) <= 0)
|
||||
TEST_ERROR
|
||||
if(H5PLget(2, pathname, 256) <= 0) TEST_ERROR
|
||||
if(HDstrcmp(pathname, "a_path_1") != 0) {
|
||||
HDfprintf(stderr," get 2: %s\n", pathname);
|
||||
TEST_ERROR
|
||||
@ -930,11 +897,10 @@ test_filter_path_apis(void)
|
||||
|
||||
TESTING(" remove (verify for insert)");
|
||||
/* Remove one path*/
|
||||
if (H5PLremove(4) < 0) TEST_ERROR
|
||||
if H5PLremove(4) < 0) TEST_ERROR
|
||||
|
||||
/* Verify that the entries were moved */
|
||||
if (H5PLget(4, pathname, 256) <= 0)
|
||||
TEST_ERROR
|
||||
if H5PLget(4, pathname, 256) <= 0) TEST_ERROR
|
||||
if(HDstrcmp(pathname, "a_path_4") != 0) {
|
||||
HDfprintf(stderr," get 4: %s\n", pathname);
|
||||
TEST_ERROR
|
||||
@ -953,8 +919,7 @@ test_filter_path_apis(void)
|
||||
}
|
||||
|
||||
/* Verify that the entries were moved */
|
||||
if (H5PLget(4, pathname, 256) <= 0)
|
||||
TEST_ERROR
|
||||
if(H5PLget(4, pathname, 256) <= 0) TEST_ERROR
|
||||
if(HDstrcmp(pathname, "a_path_2") != 0) {
|
||||
HDfprintf(stderr," get 4: %s\n", pathname);
|
||||
TEST_ERROR
|
||||
@ -970,15 +935,14 @@ test_filter_path_apis(void)
|
||||
HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 6);
|
||||
ret = H5PLinsert(pathname, 12);
|
||||
} H5E_END_TRY
|
||||
if (ret >= 0)
|
||||
TEST_ERROR
|
||||
if(ret >= 0) TEST_ERROR
|
||||
|
||||
PASSED();
|
||||
|
||||
return 0;
|
||||
ret_value = 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
|
||||
@ -1000,7 +964,9 @@ int
|
||||
main(void)
|
||||
{
|
||||
char filename[FILENAME_BUF_SIZE];
|
||||
hid_t file, fapl, fapl2;
|
||||
hid_t file = -1;
|
||||
hid_t fapl = -1;
|
||||
hid_t fapl2 = -1;
|
||||
unsigned new_format;
|
||||
int mdc_nelmts;
|
||||
size_t rdcc_nelmts;
|
||||
@ -1013,11 +979,9 @@ main(void)
|
||||
fapl = h5_fileaccess();
|
||||
|
||||
/* Turn off the chunk cache, so all the chunks are immediately written to disk */
|
||||
if(H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0)
|
||||
TEST_ERROR
|
||||
if(H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) TEST_ERROR
|
||||
rdcc_nbytes = 0;
|
||||
if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0)
|
||||
TEST_ERROR
|
||||
if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) TEST_ERROR
|
||||
|
||||
/* Copy the file access property list */
|
||||
if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
|
||||
@ -1042,8 +1006,7 @@ main(void)
|
||||
} /* end else */
|
||||
|
||||
/* Create the file for this test */
|
||||
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0)
|
||||
TEST_ERROR
|
||||
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR
|
||||
|
||||
/* Test dynamically loaded filters for chunked dataset */
|
||||
nerrors += (test_filters_for_datasets(file) < 0 ? 1 : 0);
|
||||
@ -1051,8 +1014,7 @@ main(void)
|
||||
/* Test dynamically loaded filters for groups */
|
||||
nerrors += (test_filters_for_groups(file) < 0 ? 1 : 0);
|
||||
|
||||
if(H5Fclose(file) < 0)
|
||||
TEST_ERROR
|
||||
if(H5Fclose(file) < 0) TEST_ERROR
|
||||
} /* end for */
|
||||
|
||||
/* Close FAPL */
|
||||
@ -1069,8 +1031,7 @@ main(void)
|
||||
fapl = h5_fileaccess();
|
||||
|
||||
/* Reopen the file for testing data reading */
|
||||
if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
|
||||
TEST_ERROR
|
||||
if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
|
||||
|
||||
/* Read the data with filters */
|
||||
nerrors += (test_read_with_filters(file) < 0 ? 1 : 0);
|
||||
@ -1086,20 +1047,18 @@ main(void)
|
||||
fapl = h5_fileaccess();
|
||||
|
||||
/* Reopen the file for testing data reading */
|
||||
if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
|
||||
TEST_ERROR
|
||||
if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
|
||||
|
||||
/* Read the data with disabled filters */
|
||||
nerrors += (test_noread_with_filters(file) < 0 ? 1 : 0);
|
||||
|
||||
if(H5Fclose(file) < 0)
|
||||
TEST_ERROR
|
||||
if(H5Fclose(file) < 0) TEST_ERROR
|
||||
|
||||
/* Test the APIs for access to the filter plugin path table */
|
||||
nerrors += (test_filter_path_apis() < 0 ? 1 : 0);
|
||||
|
||||
if(nerrors)
|
||||
TEST_ERROR
|
||||
if(nerrors) TEST_ERROR
|
||||
|
||||
HDprintf("All plugin tests passed.\n");
|
||||
h5_cleanup(FILENAME, fapl);
|
||||
|
||||
@ -1107,8 +1066,7 @@ main(void)
|
||||
|
||||
error:
|
||||
nerrors = MAX(1, nerrors);
|
||||
HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n",
|
||||
nerrors, 1 == nerrors ? "" : "S");
|
||||
HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user