summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-06-03 22:24:58 (GMT)
committerGitHub <noreply@github.com>2021-06-03 22:24:58 (GMT)
commit032310b87f5b5a118b3206de9565f153062b8b78 (patch)
tree9a9f0630ea95bd9cbe247990ea03d75188e94bfd /test
parentdd6547db0d3cc69c55bed12f45f4077338ddd56b (diff)
downloadhdf5-032310b87f5b5a118b3206de9565f153062b8b78.zip
hdf5-032310b87f5b5a118b3206de9565f153062b8b78.tar.gz
hdf5-032310b87f5b5a118b3206de9565f153062b8b78.tar.bz2
Adds a quick for for some egregious chunk_info badness (#722)
Diffstat (limited to 'test')
-rw-r--r--test/chunk_info.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/test/chunk_info.c b/test/chunk_info.c
index 7c6dcc1..7440459 100644
--- a/test/chunk_info.c
+++ b/test/chunk_info.c
@@ -1490,21 +1490,24 @@ typedef struct chunk_iter_info_t {
uint32_t nbytes;
} chunk_iter_info_t;
+typedef struct chunk_iter_udata_t {
+ chunk_iter_info_t *chunk_info;
+ int last_index;
+} chunk_iter_udata_t;
+
static int
iter_cb(const hsize_t *offset, uint32_t filter_mask, haddr_t addr, uint32_t nbytes, void *op_data)
{
- chunk_iter_info_t **chunk_info = (chunk_iter_info_t **)op_data;
+ chunk_iter_udata_t *cidata = (chunk_iter_udata_t *)op_data;
+ int idx = cidata->last_index + 1;
- (*chunk_info)->offset[0] = offset[0];
- (*chunk_info)->offset[1] = offset[1];
- (*chunk_info)->filter_mask = filter_mask;
- (*chunk_info)->addr = addr;
- (*chunk_info)->nbytes = nbytes;
+ cidata->chunk_info[idx].offset[0] = offset[0];
+ cidata->chunk_info[idx].offset[1] = offset[1];
+ cidata->chunk_info[idx].filter_mask = filter_mask;
+ cidata->chunk_info[idx].addr = addr;
+ cidata->chunk_info[idx].nbytes = nbytes;
- /* printf("offset: [%lld, %lld], addr: %ld, size: %d, filter mask: %d\n", offset[0], offset[1], addr,
- * nbytes, filter_mask); */
-
- *chunk_info += 1;
+ cidata->last_index++;
return H5_ITER_CONT;
}
@@ -1564,8 +1567,9 @@ test_basic_query(hid_t fapl)
haddr_t addr = 0; /* Address of an allocated/written chunk */
hsize_t chk_index = 0; /* Index of a chunk */
hsize_t ii, jj; /* Array indices */
- chunk_iter_info_t chunk_infos[2]; /* chunk infos filled up by iterator */
- chunk_iter_info_t *cptr; /* pointer to array of chunks */
+ chunk_iter_info_t chunk_infos[2]; /* Chunk infos filled up by iterator */
+ chunk_iter_info_t *cptr; /* Pointer to array of chunks */
+ chunk_iter_udata_t udata; /* udata for iteration */
herr_t ret; /* Temporary returned value for verifying failure */
TESTING("basic operations");
@@ -1674,12 +1678,13 @@ test_basic_query(hid_t fapl)
if (verify_empty_chunk_info(dset, offset) == FAIL)
FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord on empty chunk failed\n");
- /* iterate over all chunks */
- cptr = &(chunk_infos[0]);
- if (H5Dchunk_iter(dset, H5P_DEFAULT, &iter_cb, &cptr) < 0)
+ /* Iterate over all chunks */
+ udata.chunk_info = chunk_infos;
+ udata.last_index = -1;
+ if (H5Dchunk_iter(dset, H5P_DEFAULT, &iter_cb, &udata) < 0)
TEST_ERROR;
- VERIFY(cptr, &(chunk_infos[2]), "Iterator did not iterate all chunks");
+ VERIFY(udata.last_index, 1, "Iterator did not iterate all chunks");
VERIFY(chunk_infos[0].offset[0], 0, "Offset mismatch");
VERIFY(chunk_infos[0].offset[1], 0, "Offset mismatch");
VERIFY(chunk_infos[0].filter_mask, 0, "Filter mismatch");
@@ -1688,13 +1693,13 @@ test_basic_query(hid_t fapl)
VERIFY(chunk_infos[1].offset[0], 1, "Offset mismatch");
VERIFY(chunk_infos[1].offset[1], 1, "Offset mismatch");
- /* iterate and stop after one iteration */
+ /* Iterate and stop after one iteration */
cptr = &(chunk_infos[0]);
if (H5Dchunk_iter(dset, H5P_DEFAULT, &iter_cb_stop, &cptr) < 0)
TEST_ERROR;
VERIFY(cptr, &(chunk_infos[1]), "Verification of halted iterator failed\n");
- /* iterate and fail after one iteration */
+ /* Iterate and fail after one iteration */
cptr = &(chunk_infos[0]);
H5E_BEGIN_TRY
{