Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a quick fix for some egregious chunk_info badness #722

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions test/chunk_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't access the third element of a size 2 array...

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");
Expand All @@ -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
{
Expand Down