summaryrefslogtreecommitdiffstats
path: root/test/tselect.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/tselect.c')
-rw-r--r--test/tselect.c158
1 files changed, 117 insertions, 41 deletions
diff --git a/test/tselect.c b/test/tselect.c
index cadd350..c98db5d 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -1666,10 +1666,10 @@ verify_select_hyper_contig_dr__run_test(const uint16_t *cube_buf,
/****************************************************************
**
** test_select_hyper_contig_dr__run_test(): Test H5S (dataspace)
-** selection code with contiguous source and target having
-** different ranks but the same shape. We have already
-** tested H5Sselect_shape_same in isolation, so now we try to do
-** I/O.
+** selection code with contiguous source and target having
+** different ranks but the same shape. We have already
+** tested H5Sselect_shape_same in isolation, so now we try to do
+** I/O.
**
****************************************************************/
static void
@@ -6118,8 +6118,8 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist)
*/
tmpdata = data;
for (j = 0; j < X; j++)
- for (i = 0; i < Y; i++)
- for (k = 0; k < Z; k++)
+ for (i = 0; i < Y; i++)
+ for (k = 0; k < Z; k++)
*tmpdata++ = (short)((k+1)%256);
/*
@@ -6281,8 +6281,8 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist)
tmpdata = data;
tmpdata_out = data_out;
for (j = 0; j < X; j++)
- for (i = 0; i < Y; i++)
- for (k = 0; k < Z; k++,tmpdata++,tmpdata_out++) {
+ for (i = 0; i < Y; i++)
+ for (k = 0; k < Z; k++,tmpdata++,tmpdata_out++) {
if(*tmpdata!=*tmpdata_out)
TestErrPrintf("Line %d: Error! j=%d, i=%d, k=%d, *tmpdata=%x, *tmpdata_out=%x\n",__LINE__,j,i,k,(unsigned)*tmpdata,(unsigned)*tmpdata_out);
} /* end for */
@@ -6350,7 +6350,7 @@ test_select_point_chunk(void)
*/
tmpdata = data;
for (i = 0; i < SPACE7_DIM1; i++)
- for (j = 0; j < SPACE7_DIM1; j++)
+ for (j = 0; j < SPACE7_DIM1; j++)
*tmpdata++ = ((i*SPACE7_DIM2)+j)%256;
/*
@@ -12026,16 +12026,16 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(ret != FAIL) {
/* In this case, rebuild_check should be TRUE. */
rebuild_check = H5Sselect_shape_same(sid_reg1, sid_reg_ori1);
CHECK(rebuild_check, FALSE, "H5Sselect_shape_same");
- } /* end if */
+ }
/* For irregular hyperslab */
sid_irreg1 = H5Screate_simple(SPACERE1_RANK,dims1,NULL);
@@ -12062,11 +12062,11 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
/* No need to do shape comparision */
@@ -12114,7 +12114,7 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
@@ -12123,7 +12123,7 @@ test_space_rebuild(void)
/* In this case, rebuild_check should be TRUE. */
rebuild_check = H5Sselect_shape_same(sid_reg2, sid_reg_ori2);
CHECK(rebuild_check, FALSE, "H5Sselect_shape_same");
- } /* end if */
+ }
/* 2-D irregular case */
sid_irreg2 = H5Screate_simple(SPACERE2_RANK,dims2,NULL);
@@ -12155,11 +12155,11 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
/* No need to do shape comparision */
MESSAGE(7, ("Testing functionality to rebuild 3-D hyperslab selection\n"));
@@ -12212,16 +12212,16 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(ret != FAIL) {
/* In this case, rebuild_check should be TRUE. */
rebuild_check = H5Sselect_shape_same(sid_reg3, sid_reg_ori3);
CHECK(rebuild_check, FALSE, "H5Sselect_shape_same");
- } /* end if */
+ }
sid_irreg3 = H5Screate_simple(SPACERE3_RANK,dims3,NULL);
@@ -12258,11 +12258,11 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
/* No need to do shape comparision */
MESSAGE(7, ("Testing functionality to rebuild 4-D hyperslab selection\n"));
@@ -12323,16 +12323,16 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(ret != FAIL) {
/* In this case, rebuild_check should be TRUE. */
rebuild_check = H5Sselect_shape_same(sid_reg4, sid_reg_ori4);
CHECK(rebuild_check, FALSE, "H5Sselect_shape_same");
- } /* end if */
+ }
/* Testing irregular selection */
sid_irreg4 = H5Screate_simple(SPACERE4_RANK,dims4,NULL);
@@ -12380,11 +12380,11 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
/* No need to do shape comparision */
MESSAGE(7, ("Testing functionality to rebuild 5-D hyperslab selection\n"));
@@ -12449,16 +12449,16 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(ret != FAIL) {
/* In this case, rebuild_check should be TRUE. */
rebuild_check = H5Sselect_shape_same(sid_reg5, sid_reg_ori5);
CHECK(rebuild_check, FALSE, "H5Sselect_shape_same");
- } /* end if */
+ }
sid_irreg5 = H5Screate_simple(SPACERE5_RANK,dims5,NULL);
@@ -12511,11 +12511,11 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
/* No need to do shape comparision */
/* We use 5-D to test a special case with
@@ -12558,11 +12558,11 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
/* No need to do shape comparision */
/* Adding some selections to make it real irregular */
@@ -12586,11 +12586,11 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
/* No need to do shape comparision */
/* Add more selections to make it regular again */
@@ -12614,11 +12614,11 @@ test_space_rebuild(void)
if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) {
ret = FAIL;
CHECK(ret,FAIL,"H5S_hyper_rebuild");
- } /* end if */
+ }
/* No need to do shape comparision */
H5Sclose(sid_reg1);
@@ -15442,14 +15442,14 @@ test_hyper_io_1d(void)
/* Get the dataset's dataspace */
sid = H5Dget_space(did);
- CHECK(sid, H5I_INVALID_HID, "H5Pcreate");
+ CHECK(sid, H5I_INVALID_HID, "H5Dget_space");
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, stride, count, block);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Set up contiguous memory dataspace for the selected elements */
dimsm[0] = count[0];
mid = H5Screate_simple(RANK, dimsm, NULL);
- CHECK(mid, H5I_INVALID_HID, "H5Screate");
+ CHECK(mid, H5I_INVALID_HID, "H5Screate_simple");
/* Read all the selected 10th elements in the dataset into "rdata" */
ret = H5Dread(did, H5T_NATIVE_INT, mid, sid, H5P_DEFAULT, rdata);
@@ -15476,6 +15476,77 @@ test_hyper_io_1d(void)
/****************************************************************
**
+** test_h5s_set_extent_none:
+** Test to verify the behavior of dataspace code when passed
+** a dataspace modified by H5Sset_extent_none().
+**
+****************************************************************/
+static void
+test_h5s_set_extent_none(void)
+{
+ hid_t sid = H5I_INVALID_HID;
+ hid_t dst_sid = H5I_INVALID_HID;
+ hid_t null_sid = H5I_INVALID_HID;
+ int rank = 1;
+ hsize_t current_dims = 123;
+ H5S_class_t cls;
+ int out_rank;
+ hsize_t out_dims;
+ hsize_t out_maxdims;
+ hssize_t out_points;
+ htri_t equal;
+ herr_t ret;
+
+ /* Specific values here don't matter as we're just going to reset */
+ sid = H5Screate_simple(rank, &current_dims, NULL);
+ CHECK(sid, H5I_INVALID_HID, "H5Screate_simple");
+
+ /* Dataspace class will be H5S_NULL after this.
+ * In versions prior to 1.10.7 / 1.12.1 this would produce a
+ * dataspace with the internal H5S_NO_CLASS class.
+ */
+ ret = H5Sset_extent_none(sid);
+ CHECK(ret, FAIL, "H5Sset_extent_none");
+ cls = H5Sget_simple_extent_type(sid);
+ VERIFY(cls, H5S_NULL, "H5Sget_simple_extent_type");
+
+ /* Extent getters should generate normal results and not segfault.
+ */
+ out_rank = H5Sget_simple_extent_dims(sid, &out_dims, &out_maxdims);
+ VERIFY(out_rank, 0, "H5Sget_simple_extent_dims");
+ out_rank = H5Sget_simple_extent_ndims(sid);
+ VERIFY(out_rank, 0, "H5Sget_simple_extent_ndims");
+ out_points = H5Sget_simple_extent_npoints(sid);
+ VERIFY(out_points, 0, "H5Sget_simple_extent_npoints");
+
+ /* Check that copying the new (non-)extent works.
+ */
+ dst_sid = H5Screate_simple(rank, &current_dims, NULL);
+ CHECK(dst_sid, H5I_INVALID_HID, "H5Screate_simple");
+ ret = H5Sextent_copy(dst_sid, sid);
+ CHECK(ret, FAIL, "H5Sextent_copy");
+
+ /* Check that H5Sset_extent_none() produces the same extent as
+ * H5Screate(H5S_NULL).
+ */
+ null_sid = H5Screate(H5S_NULL);
+ CHECK(null_sid, H5I_INVALID_HID, "H5Screate");
+ equal = H5Sextent_equal(sid, null_sid);
+ VERIFY(equal, TRUE, "H5Sextent_equal");
+
+ /* Close */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Sclose(dst_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Sclose(null_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_h5s_set_extent_none() */
+
+
+/****************************************************************
+**
** test_select(): Main H5S selection testing routine.
**
****************************************************************/
@@ -15660,6 +15731,11 @@ test_select(void)
/* Test reading of 1-d disjoint file space to 1-d single block memory space */
test_hyper_io_1d();
+ /* Test H5Sset_extent_none() functionality after we updated it to set
+ * the class to H5S_NULL instead of H5S_NO_CLASS.
+ */
+ test_h5s_set_extent_none();
+
} /* test_select() */