summaryrefslogtreecommitdiffstats
path: root/test/tselect.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-08-19 12:18:37 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-08-19 12:18:37 (GMT)
commitc6ed9cbbae2ab01129261e3fcfa5b5dc927976ea (patch)
treeab0844aab779c1923058671aacb9a433fc24a388 /test/tselect.c
parent9881fa7e34444fdd064306c87d994063b27770cb (diff)
downloadhdf5-c6ed9cbbae2ab01129261e3fcfa5b5dc927976ea.zip
hdf5-c6ed9cbbae2ab01129261e3fcfa5b5dc927976ea.tar.gz
hdf5-c6ed9cbbae2ab01129261e3fcfa5b5dc927976ea.tar.bz2
[svn-r7383] Purpose:
Bug fix Description: I/O on chunked datasets with a scalar dataspace for the memory dataspace was not working correctly. Solution: Translate the scalar dataspace into a n-dimensional (where n is the number of dimensions of the file's dataspace) dataspace of dimensions 1x1x1... Platforms tested: FreeBSD 4.8 (sleipnir) h5committest (modulo modi4 which is not working correctly)
Diffstat (limited to 'test/tselect.c')
-rw-r--r--test/tselect.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/tselect.c b/test/tselect.c
index 8114c13..d7705f5 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -4186,6 +4186,72 @@ test_select_point_chunk(void)
/****************************************************************
**
+** test_select_sclar_chunk(): Test basic H5S (dataspace) selection code.
+** Tests using a scalar dataspace (in memory) to access chunked datasets.
+**
+****************************************************************/
+static void
+test_select_scalar_chunk(void)
+{
+ hid_t file_id; /* File ID */
+ hid_t dcpl; /* Dataset creation property list */
+ hid_t dsid; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t m_sid; /* Memory dataspace */
+ hsize_t dims[] = {2}; /* Dataset dimensions */
+ hsize_t maxdims[] = {H5S_UNLIMITED}; /* Dataset maximum dimensions */
+ hssize_t offset[] = {0}; /* Hyperslab start */
+ hsize_t count[] = {1}; /* Hyperslab count */
+ unsigned data = 2; /* Data to write */
+ herr_t ret;
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Scalar Dataspaces and Chunked Datasets\n"));
+
+ file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(file_id, FAIL, "H5Fcreate");
+
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+
+ dims[0] = 1024U;
+ ret = H5Pset_chunk(dcpl, 1, dims);
+ CHECK(ret, FAIL, "H5Pset_chunk");
+
+ /* Create 1-D dataspace */
+ sid = H5Screate_simple(1, dims, maxdims);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ dsid = H5Dcreate(file_id, "dset", H5T_NATIVE_UINT, sid, dcpl);
+ CHECK(dsid, FAIL, "H5Dcreate");
+
+ /* Select scalar area (offset 0, count 1) */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Create scalar memory dataspace */
+ m_sid = H5Screate(H5S_SCALAR);
+ CHECK(m_sid, FAIL, "H5Screate");
+
+ /* Write out data using scalar dataspace for memory dataspace */
+ ret = H5Dwrite (dsid, H5T_NATIVE_UINT, m_sid, sid, H5P_DEFAULT, &data);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close resources */
+ ret = H5Sclose(m_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Dclose(dsid);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Fclose (file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_select_scalar_chunk() */
+
+/****************************************************************
+**
** test_select_valid(): Test basic H5S (dataspace) selection code.
** Tests selection validity
**
@@ -6468,6 +6534,9 @@ test_select(void)
/* Test point selections in chunked datasets */
test_select_point_chunk();
+ /* Test scalar dataspaces in chunked datasets */
+ test_select_scalar_chunk();
+
} /* test_select() */