diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-08-31 22:59:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-08-31 22:59:49 (GMT) |
commit | 20ea68f5c4ea9d2e7708b5b4a9f6f2ba8d94e558 (patch) | |
tree | 8d855a1f506b0b94e3e8d6de6f295601681989b6 /test | |
parent | e65aa8c36566febd00da128e64cc90f3c8ffbc70 (diff) | |
download | hdf5-20ea68f5c4ea9d2e7708b5b4a9f6f2ba8d94e558.zip hdf5-20ea68f5c4ea9d2e7708b5b4a9f6f2ba8d94e558.tar.gz hdf5-20ea68f5c4ea9d2e7708b5b4a9f6f2ba8d94e558.tar.bz2 |
[svn-r19328] Description:
Add some extra range checking for invalid chunk sizes.
Tweak default chunk sizes to be zero, so that it's more likely that
application developers will be forced to set them correctly.
Add a few tests to verify these checks.
Tested on:
Mac OS X/32 10.6.4 (amazon) w/debug & production
(too minor to require h5committest)
Diffstat (limited to 'test')
-rw-r--r-- | test/dsets.c | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/test/dsets.c b/test/dsets.c index 8a474b4..e686fa0 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -876,6 +876,7 @@ test_layout_extend(hid_t fapl) hsize_t cur_size[1] = {10}; /* Current size of dataspace */ hsize_t max_unlim[1] = {H5S_UNLIMITED}; /* Maximum size of dataspace (unlimited) */ hsize_t max_fix[1] = {100}; /* Maximum size of dataspace (fixed) */ + hsize_t chunk_dim[1] = {10}; /* Chunk size */ TESTING("extendible dataset with various layout"); @@ -931,6 +932,7 @@ test_layout_extend(hid_t fapl) FAIL_STACK_ERROR if(H5Pset_layout(dcpl_chunked, H5D_CHUNKED) < 0) FAIL_STACK_ERROR + if(H5Pset_chunk(dcpl_chunked, 1, chunk_dim) < 0) FAIL_STACK_ERROR /* Create dataset with extendible dataspace (fixed max_dims) should succeed */ if((did_fixed = H5Dcreate2(fid, "chunked_fixed", H5T_NATIVE_INT, sid_fix, H5P_DEFAULT, dcpl_chunked, H5P_DEFAULT)) < 0) @@ -6326,8 +6328,6 @@ error: * Programmer: Quincey Koziol * Tuesday, July 27, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -6335,19 +6335,41 @@ test_zero_dims(hid_t file) { hid_t s=-1, d=-1, dcpl=-1; hsize_t dsize=0, dmax=H5S_UNLIMITED, csize=5; + herr_t ret; TESTING("I/O on datasets with zero-sized dims"); - if((s = H5Screate_simple(1, &dsize, &dmax)) < 0) TEST_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if(H5Pset_chunk(dcpl, 1, &csize) < 0) TEST_ERROR; - if((d = H5Dcreate2(file, ZERODIM_DATASET, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR; + if((s = H5Screate_simple(1, &dsize, &dmax)) < 0) FAIL_STACK_ERROR - if(H5Dwrite(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, (void*)911) < 0) TEST_ERROR; + /* Try creating chunked dataset with zero-sized chunk dimensions */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if(H5Pset_layout(dcpl, H5D_CHUNKED) < 0) FAIL_STACK_ERROR + H5E_BEGIN_TRY { + d = H5Dcreate2(file, ZERODIM_DATASET, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT); + } H5E_END_TRY; + if(d > 0) { + H5Dclose(d); + FAIL_PUTS_ERROR("created dataset with undefined chunk dimensions") + } /* end if */ - if(H5Pclose(dcpl) < 0) TEST_ERROR; - if(H5Sclose(s) < 0) TEST_ERROR; - if(H5Dclose(d) < 0) TEST_ERROR; + H5E_BEGIN_TRY { + ret = H5Pset_chunk(dcpl, 1, &dsize); + } H5E_END_TRY; + if(ret > 0) + FAIL_PUTS_ERROR("set zero-sized chunk dimensions") + + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if(H5Pset_chunk(dcpl, 1, &csize) < 0) FAIL_STACK_ERROR + if((d = H5Dcreate2(file, ZERODIM_DATASET, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + if(H5Dwrite(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, (void*)911) < 0) FAIL_STACK_ERROR + + if(H5Dclose(d) < 0) FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + + if(H5Sclose(s) < 0) FAIL_STACK_ERROR PASSED(); return 0; @@ -6460,7 +6482,7 @@ error: H5Sclose(s); } H5E_END_TRY; return -1; -} /* end test_zero_dims() */ +} /* end test_missing_chunk() */ /*------------------------------------------------------------------------- |