diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-06-19 20:38:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-06-19 20:38:49 (GMT) |
commit | dfbc98e349e423addea1a129fb241bc5e12b1c7b (patch) | |
tree | 4b1e015402a3703ac937c97b61cf23a1cc24aff5 /test/fillval.c | |
parent | 6e0eea31fe10f033603b26eef899df9290386352 (diff) | |
download | hdf5-dfbc98e349e423addea1a129fb241bc5e12b1c7b.zip hdf5-dfbc98e349e423addea1a129fb241bc5e12b1c7b.tar.gz hdf5-dfbc98e349e423addea1a129fb241bc5e12b1c7b.tar.bz2 |
[svn-r13887] Description:
Add some additional tests for reading non-contiguous selections from
datasets which haven't had any data written to them (both non-VL and VL
datatype fill values covered)
Tested on:
Mac OS X/32 10.4.9 (amazon)
FreeBSD/32 6.2 (duty)
FreeBSD/64 6.2 (liberty)
Diffstat (limited to 'test/fillval.c')
-rw-r--r-- | test/fillval.c | 79 |
1 files changed, 67 insertions, 12 deletions
diff --git a/test/fillval.c b/test/fillval.c index 1518a1c..ebc3e68 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -732,11 +732,11 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, if((mspace = H5Screate_simple(5, one, NULL)) < 0) goto error; for (i=0; i<1000; i++) { - for (j=0; j<5; j++) { + for (j=0; j<5; j++) hs_offset[j] = rand() % cur_size[j]; - } if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL)<0) goto error; + /* case for atomic datatype */ if (datatype==H5T_INTEGER) { if(H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, @@ -772,7 +772,7 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, } if (H5Sclose(mspace)<0) goto error; - /* Write to all odd data locations */ + /* Select all odd data locations in the file dataset */ for (i=0, nelmts=1; i<5; i++) { hs_size[i] = cur_size[i]/2; hs_offset[i] = 0; @@ -783,28 +783,83 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, hs_stride, hs_size, NULL)<0) goto error; + /* Read non-contiguous selection from empty dataset */ + /* case for atomic datatype */ if(datatype==H5T_INTEGER) { /*check for overflow*/ - HDassert((nelmts*sizeof(int))==(hsize_t)((size_t)(nelmts*sizeof(int)))); + HDassert((nelmts * sizeof(int)) == (hsize_t)((size_t)(nelmts * sizeof(int)))); buf = HDmalloc((size_t)(nelmts * sizeof(int))); + + if(H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf) < 0) + goto error; + + /* Verify values, except if no fill value written */ + if(fill_time != H5D_FILL_TIME_NEVER) { + for(u = 0; u < nelmts; u++) { + if(buf[u] != fillval) { + H5_FAILED(); + puts(" Value read was not a fill value."); + HDfprintf(stdout," Elmt={%Hu, %Hu, %Hu, %Hu, %Hu}, read: %u, " + "Fill value: %u\n", + hs_offset[0], hs_offset[1], + hs_offset[2], hs_offset[3], + hs_offset[4], buf[u], fillval); + goto error; + } /* end if */ + } /* end for */ + } /* end if */ + } + /* case for compound datatype */ + else if(datatype == H5T_COMPOUND) { + /*check for overflow*/ + HDassert((nelmts * sizeof(comp_datatype)) == + (hsize_t)((size_t)(nelmts * sizeof(comp_datatype)))); + buf_c = (comp_datatype *)HDmalloc((size_t)nelmts * sizeof(comp_datatype)); + + if(H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, buf_c) < 0) + goto error; + + /* Verify values, except if no fill value written */ + if(fill_time != H5D_FILL_TIME_NEVER) { + for(u = 0; u < nelmts; u++) { + if(buf_c[u].a != fill_c.a || buf_c[u].x != fill_c.x || + buf_c[u].y != fill_c.y || buf_c[u].z != fill_c.z) { + H5_FAILED(); + puts(" Value read was not a fill value."); + HDfprintf(stdout," Elmt={%Hu, %Hu, %Hu, %Hu, %Hu}, read: %f, %d, %f, %c" + "Fill value: %f, %d, %f, %c\n", + hs_offset[0], hs_offset[1], + hs_offset[2], hs_offset[3], + hs_offset[4], + buf_c[u].a, buf_c[u].x, buf_c[u].y, buf_c[u].z, + fill_c.a, fill_c.x, fill_c.y, fill_c.z); + goto error; + } /* end if */ + } /* end for */ + } /* end if */ + } + + /* Write to all odd data locations */ + + /* case for atomic datatype */ + if(datatype == H5T_INTEGER) { for(u = 0; u < nelmts; u++) buf[u] = 9999; - if (H5Dwrite(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, - buf)<0) goto error; + if(H5Dwrite(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf) < 0) + goto error; } /* case for compound datatype */ - else if(datatype==H5T_COMPOUND) { - HDassert((nelmts*sizeof(comp_datatype))== - (hsize_t)((size_t)(nelmts*sizeof(comp_datatype)))); - buf_c = (comp_datatype*)HDcalloc((size_t)nelmts,sizeof(comp_datatype)); - for (u=0; u<nelmts; u++) { + else if(datatype == H5T_COMPOUND) { + HDmemset(buf_c, 0, ((size_t)nelmts * sizeof(comp_datatype))); + for(u = 0; u < nelmts; u++) { buf_c[u].a = (float)1111.11; buf_c[u].x = 2222; buf_c[u].y = 3333.3333; buf_c[u].z = 'd'; } - if (H5Dwrite(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, buf_c)<0) goto error; + if(H5Dwrite(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, buf_c) < 0) + goto error; } /* Check if space is allocated */ |