summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2019-04-10 22:22:06 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2019-04-10 22:22:06 (GMT)
commit3e30d019214eaee6f345f45eae478e7f464df8ad (patch)
tree1ebdf1b2a1ff48a4edeb453831ad9410ccd2aee0
parent1fb34f7e8cb960bdf8132cd4cf63b5c7cf11a969 (diff)
downloadhdf5-3e30d019214eaee6f345f45eae478e7f464df8ad.zip
hdf5-3e30d019214eaee6f345f45eae478e7f464df8ad.tar.gz
hdf5-3e30d019214eaee6f345f45eae478e7f464df8ad.tar.bz2
Make corresponding changes for hyperslab encoding incorrect length (HDFFV-10271).
This is based on PR #1644 merged to develop branch. The fix for the incorrect length was already checked in to 1.10 on Dec 2017.
-rw-r--r--test/th5s.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/th5s.c b/test/th5s.c
index 9d5273f..fa6bba3 100644
--- a/test/th5s.c
+++ b/test/th5s.c
@@ -2690,6 +2690,83 @@ test_h5s_encode_points_exceed32(void)
/****************************************************************
**
+** test_h5s_encode_length():
+** Test to verify HDFFV-10271 is fixed.
+** Verify that version 2 hyperslab encoding length is correct.
+**
+** See "RFC: H5Sencode/H5Sdecode Format Change" for the
+** description of the encoding format.
+**
+****************************************************************/
+static void
+test_h5s_encode_length(void)
+{
+ hid_t sid; /* Dataspace ID */
+ hid_t decoded_sid; /* Dataspace ID from H5Sdecode2 */
+ size_t sbuf_size=0; /* Buffer size for H5Sencode2/1 */
+ unsigned char *sbuf=NULL; /* Buffer for H5Sencode2/1 */
+ hsize_t dims[1] = {500}; /* Dimension size */
+ hsize_t start, count, block, stride; /* Hyperslab selection specifications */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Version 2 Hyperslab Encoding Length is correct\n"));
+
+ /* Create dataspace */
+ sid = H5Screate_simple(1, dims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Setting H5S_UNLIMITED in count will use version 2 for hyperslab encoding */
+ start = 0;
+ stride = 10;
+ block = 4;
+ count = H5S_UNLIMITED;
+
+ /* Set hyperslab selection */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Encode simple data space in a buffer */
+ ret = H5Sencode(sid, NULL, &sbuf_size);
+ CHECK(ret, FAIL, "H5Sencode");
+
+ /* Allocate the buffer */
+ if(sbuf_size > 0) {
+ sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size);
+ CHECK(sbuf, NULL, "H5Sencode2");
+ }
+
+ /* Encode the dataspace */
+ ret = H5Sencode(sid, sbuf, &sbuf_size);
+ CHECK(ret, FAIL, "H5Sencode");
+
+ /* Verify that length stored at this location in the buffer is correct */
+ VERIFY((uint32_t)sbuf[40], 36, "Length for encoding version 2");
+ VERIFY((uint32_t)sbuf[35], 2, "Hyperslab encoding version is 2");
+
+ /* Decode from the dataspace buffer and return an object handle */
+ decoded_sid = H5Sdecode(sbuf);
+ CHECK(decoded_sid, FAIL, "H5Sdecode");
+
+ /* Verify that the original and the decoded dataspace are equal */
+ VERIFY(H5Sget_select_npoints(sid), H5Sget_select_npoints(decoded_sid), "Compare npoints");
+
+ /* Close the decoded dataspace */
+ ret = H5Sclose(decoded_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Free the buffer */
+ if(sbuf)
+ HDfree(sbuf);
+
+ /* Close the original dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_h5s_encode_length() */
+
+/****************************************************************
+**
** test_h5s(): Main H5S (dataspace) testing routine.
**
****************************************************************/
@@ -2706,6 +2783,7 @@ test_h5s(void)
test_h5s_encode_regular_exceed32(); /* Test encoding regular hyperslab selection that exceeds 32 bits */
test_h5s_encode_irregular_exceed32(); /* Testing encoding irregular hyperslab selection that exceeds 32 bits */
test_h5s_encode_points_exceed32(); /* Testing encoding point selection that exceeds 32 bits */
+ test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */
test_h5s_scalar_write(); /* Test scalar H5S writing code */
test_h5s_scalar_read(); /* Test scalar H5S reading code */