summaryrefslogtreecommitdiffstats
path: root/test/dsets.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/dsets.c')
-rw-r--r--test/dsets.c146
1 files changed, 85 insertions, 61 deletions
diff --git a/test/dsets.c b/test/dsets.c
index 71379cb..707f858 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -582,6 +582,8 @@ test_compact_io(hid_t fapl)
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %d,%d\n", i, j);
+ printf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]);
+ printf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]);
goto error;
}
}
@@ -1282,6 +1284,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
{
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 */
const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
const hssize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */
@@ -1304,6 +1307,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
#else /* H5_WANT_H5_V1_4_COMPAT */
if (H5Pset_buffer (dxpl, (size_t)1000, tconv_buf, NULL)<0) goto error;
#endif /* H5_WANT_H5_V1_4_COMPAT */
+ if ((write_dxpl = H5Pcopy (dxpl))<0) TEST_ERROR;
if (if_fletcher32==DISABLE_FLETCHER32) {
if(H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)<0)
@@ -1361,10 +1365,10 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
}
}
- if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, points)<0)
- goto error;
+ if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points)<0)
+ TEST_ERROR;
- if((*dset_size=H5Dget_storage_size(dataset))==0) goto error;
+ if((*dset_size=H5Dget_storage_size(dataset))==0) TEST_ERROR;
PASSED();
@@ -1377,25 +1381,27 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
/* Read the dataset back */
if(corrupted) {
/* Default behavior is failure when data is corrupted. */
+ /* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check);
+ status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check);
} H5E_END_TRY;
- if(status>=0) goto error;
+ if(status>=0) TEST_ERROR;
/* Callback decides to continue inspite data is corrupted. */
- if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error;
+ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) TEST_ERROR;
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0)
- goto error;
+ TEST_ERROR;
/* Callback decides to fail when data is corrupted. */
- if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error;
+ if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL)<0) TEST_ERROR;
+ /* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check);
+ status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check);
} H5E_END_TRY;
- if(status>=0) goto error;
+ if(status>=0) TEST_ERROR;
} else {
if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0)
- goto error;
+ TEST_ERROR;
/* Check that the values read are the same as the values written */
for (i=0; i<size[0]; i++) {
@@ -1428,31 +1434,33 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
points[i][j] = (int)HDrandom ();
}
}
- if (H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, points)<0)
- goto error;
+ if (H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points)<0)
+ TEST_ERROR;
if(corrupted) {
/* Default behavior is failure when data is corrupted. */
+ /* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check);
+ status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check);
} H5E_END_TRY;
- if(status>=0) goto error;
+ if(status>=0) TEST_ERROR;
/* Callback decides to continue inspite data is corrupted. */
- if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error;
+ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) TEST_ERROR;
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0)
- goto error;
+ TEST_ERROR;
/* Callback decides to fail when data is corrupted. */
- if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error;
+ if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL)<0) TEST_ERROR;
+ /* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check);
+ status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check);
} H5E_END_TRY;
- if(status>=0) goto error;
+ if(status>=0) TEST_ERROR;
} else {
/* Read the dataset back and check it */
if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0)
- goto error;
+ TEST_ERROR;
/* Check that the values read are the same as the values written */
for (i=0; i<size[0]; i++) {
@@ -1468,7 +1476,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
}
}
- if((*dset_size=H5Dget_storage_size(dataset))==0) goto error;
+ if((*dset_size=H5Dget_storage_size(dataset))==0) TEST_ERROR;
PASSED();
/*----------------------------------------------------------------------
@@ -1479,30 +1487,32 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
*/
TESTING(" filters (re-open)");
- if (H5Dclose (dataset)<0) goto error;
- if ((dataset = H5Dopen (fid, name))<0) goto error;
+ if (H5Dclose (dataset)<0) TEST_ERROR;
+ if ((dataset = H5Dopen (fid, name))<0) TEST_ERROR;
if(corrupted) {
/* Default behavior is failure when data is corrupted. */
+ /* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check);
+ status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check);
} H5E_END_TRY;
- if(status>=0) goto error;
+ if(status>=0) TEST_ERROR;
/* Callback decides to continue inspite data is corrupted. */
- if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error;
+ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) TEST_ERROR;
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0)
- goto error;
+ TEST_ERROR;
/* Callback decides to fail when data is corrupted. */
- if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error;
+ if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL)<0) TEST_ERROR;
+ /* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check);
+ status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check);
} H5E_END_TRY;
- if(status>=0) goto error;
+ if(status>=0) TEST_ERROR;
} else {
if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0)
- goto error;
+ TEST_ERROR;
/* Check that the values read are the same as the values written */
for (i=0; i<size[0]; i++) {
@@ -1535,31 +1545,34 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
}
}
if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size,
- NULL)<0) goto error;
+ 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)
- goto error;
+ TEST_ERROR;
if(corrupted) {
/* Default behavior is failure when data is corrupted. */
+ /* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check);
+ status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check);
} H5E_END_TRY;
- if(status>=0) goto error;
+ if(status>=0) TEST_ERROR;
/* Callback decides to continue inspite data is corrupted. */
- if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error;
+ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) TEST_ERROR;
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0)
- goto error;
+ TEST_ERROR;
/* Callback decides to fail when data is corrupted. */
- if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error;
+ if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL)<0) TEST_ERROR;
+ /* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check);
+ status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check);
} H5E_END_TRY;
- if(status>=0) goto error;
+ if(status>=0) TEST_ERROR;
} else {
if (H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check)<0)
- goto error;
+ TEST_ERROR;
/* Check that the values read are the same as the values written */
for (i=0; i<hs_size[0]; i++) {
@@ -1709,7 +1722,7 @@ test_filters(hid_t file)
if (H5Zregister (H5Z_CORRUPT)<0) goto error;
#endif /* H5_WANT_H5_V1_4_COMPAT */
if (H5Pset_filter (dc, H5Z_FILTER_CORRUPT, 0, 3, data_corrupt)<0) goto error;
- if(test_filter_internal(file,DSET_FLETCHER32_NAME_3,dc,ENABLE_FLETCHER32,DATA_CORRUPTED,&fletcher32_size)<0) goto error;
+ if(test_filter_internal(file,DSET_FLETCHER32_NAME_3,dc,DISABLE_FLETCHER32,DATA_CORRUPTED,&fletcher32_size)<0) goto error;
if(fletcher32_size<=null_size) {
H5_FAILED();
puts(" Size after checksumming is incorrect.");
@@ -3123,10 +3136,11 @@ error:
static herr_t
auxread_fdata(hid_t fid, const char *name)
{
- hid_t dset_id; /* dataset ID */
- hid_t space_id=(-1); /* space ID */
- hid_t ftype_id=(-1); /* file data type ID */
- hid_t mtype_id=(-1); /* memory data type ID */
+ hid_t dset_id=-1; /* dataset ID */
+ hid_t dcpl_id=-1; /* dataset creation property list ID */
+ hid_t space_id=-1; /* space ID */
+ hid_t ftype_id=-1; /* file data type ID */
+ hid_t mtype_id=-1; /* memory data type ID */
size_t msize; /* memory size of memory type */
void *buf=NULL; /* data buffer */
hsize_t nelmts; /* number of elements in dataset */
@@ -3140,6 +3154,8 @@ auxread_fdata(hid_t fid, const char *name)
goto error;
if ((ftype_id=H5Dget_type (dset_id))<0)
goto error;
+ if ((dcpl_id=H5Dget_create_plist(dset_id))<0)
+ goto error;
if ( (rank=H5Sget_simple_extent_ndims(space_id))<0)
goto error;
HDmemset(dims, 0, sizeof dims);
@@ -3164,6 +3180,8 @@ auxread_fdata(hid_t fid, const char *name)
goto error;
}
+ if (H5Pclose(dcpl_id)<0)
+ goto error;
if (H5Sclose(space_id)<0)
goto error;
if (H5Dclose(dset_id)<0)
@@ -3175,6 +3193,7 @@ auxread_fdata(hid_t fid, const char *name)
error:
H5E_BEGIN_TRY {
+ H5Pclose(dcpl_id);
H5Sclose(space_id);
H5Dclose(dset_id);
H5Tclose(ftype_id);
@@ -3204,10 +3223,10 @@ error:
static herr_t
test_filters_endianess(void)
{
- hid_t fid; /* file ID */
- hid_t dsid=(-1); /* dataset ID */
- hid_t sid; /* dataspace ID */
- hid_t dcpl=(-1); /* dataset creation property list ID */
+ hid_t fid=-1; /* file ID */
+ hid_t dsid=-1; /* dataset ID */
+ hid_t sid=-1; /* dataspace ID */
+ hid_t dcpl=-1; /* dataset creation property list ID */
hsize_t dims[1]={2}; /* dataspace dimensions */
hsize_t chunk_dims[1]={2}; /* chunk dimensions */
int buf[2];
@@ -3251,11 +3270,13 @@ test_filters_endianess(void)
if (H5Dclose (dsid)<0) goto error;
if (H5Sclose (sid)<0) goto error;
if (H5Fclose (fid)<0) goto error;
+
/*-------------------------------------------------------------------------
* step 2: open a file written on a little-endian machine in step 1
*-------------------------------------------------------------------------
*/
- /* compose the name of the file to open, using the srcdir, if appropriate */
+
+ /* compose the name of the file to open, using the srcdir, if appropriate */
strcpy(data_file, "");
if ( srcdir )
{
@@ -3273,10 +3294,12 @@ test_filters_endianess(void)
/* close */
if (H5Fclose(fid)<0) goto error;
+
/*-------------------------------------------------------------------------
* step 3: open a file written on a big-endian machine in step 1
*-------------------------------------------------------------------------
*/
+
/* compose the name of the file to open, using the srcdir, if appropriate */
strcpy(data_file, "");
if ( srcdir )
@@ -3330,25 +3353,26 @@ int
main(void)
{
hid_t file, grp, fapl;
+ int mdc_nelmts;
+ size_t rdcc_nelmts;
+ size_t rdcc_nbytes;
+ double rdcc_w0;
int nerrors=0;
char filename[1024];
h5_reset();
fapl = h5_fileaccess();
-#if 0
- {
- /* Turn off raw data cache */
- int mdc_nelmts;
- if (H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL)<0) goto error;
- if (H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0)<0) goto error;
- }
-#endif
-
/* Set the random # seed */
HDsrandom((unsigned long)HDtime(NULL));
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+
+ /* 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) goto error;
+ rdcc_nbytes=0;
+ if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0)<0) goto error;
+
if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) {
goto error;
}