summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2022-01-20 13:34:43 (GMT)
committerGitHub <noreply@github.com>2022-01-20 13:34:43 (GMT)
commitdd6ad33c75bf084f08d4e84f92ab997c704b2096 (patch)
tree0e720e8cbf79bd99d501c10d57aaf8a03ddfe4b1 /test
parent6c184e28d80dff5ae1efb63ca28043c62f1b7670 (diff)
downloadhdf5-dd6ad33c75bf084f08d4e84f92ab997c704b2096.zip
hdf5-dd6ad33c75bf084f08d4e84f92ab997c704b2096.tar.gz
hdf5-dd6ad33c75bf084f08d4e84f92ab997c704b2096.tar.bz2
Implement H5ESget requests function to retrieve requests from an event set (#1355)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r--test/event_set.c489
1 files changed, 485 insertions, 4 deletions
diff --git a/test/event_set.c b/test/event_set.c
index 5df49e9..22df510 100644
--- a/test/event_set.c
+++ b/test/event_set.c
@@ -19,8 +19,157 @@
#include "h5test.h"
#include "H5srcdir.h"
+#define EVENT_SET_NUM_CONNECTOR_IDS 2
+
const char *FILENAME[] = {"event_set_1", NULL};
+hid_t connector_ids_g[EVENT_SET_NUM_CONNECTOR_IDS];
+
+herr_t fake_wait_request_wait(void *req, uint64_t timeout, H5VL_request_status_t *status);
+herr_t fake_wait_request_free(void *req);
+
+/* A VOL class struct that describes a VOL class with no
+ * functionality, other than a wait that returns success.
+ */
+static const H5VL_class_t fake_wait_vol_g = {
+ H5VL_VERSION, /* VOL class struct version */
+ ((H5VL_class_value_t)501), /* value */
+ "fake_wait", /* name */
+ 0, /* connector version */
+ 0, /* capability flags */
+ NULL, /* initialize */
+ NULL, /* terminate */
+ {
+ /* info_cls */
+ (size_t)0, /* size */
+ NULL, /* copy */
+ NULL, /* compare */
+ NULL, /* free */
+ NULL, /* to_str */
+ NULL, /* from_str */
+ },
+ {
+ /* wrap_cls */
+ NULL, /* get_object */
+ NULL, /* get_wrap_ctx */
+ NULL, /* wrap_object */
+ NULL, /* unwrap_object */
+ NULL, /* free_wrap_ctx */
+ },
+ {
+ /* attribute_cls */
+ NULL, /* create */
+ NULL, /* open */
+ NULL, /* read */
+ NULL, /* write */
+ NULL, /* get */
+ NULL, /* specific */
+ NULL, /* optional */
+ NULL /* close */
+ },
+ {
+ /* dataset_cls */
+ NULL, /* create */
+ NULL, /* open */
+ NULL, /* read */
+ NULL, /* write */
+ NULL, /* get */
+ NULL, /* specific */
+ NULL, /* optional */
+ NULL /* close */
+ },
+ {
+ /* datatype_cls */
+ NULL, /* commit */
+ NULL, /* open */
+ NULL, /* get */
+ NULL, /* specific */
+ NULL, /* optional */
+ NULL /* close */
+ },
+ {
+ /* file_cls */
+ NULL, /* create */
+ NULL, /* open */
+ NULL, /* get */
+ NULL, /* specific */
+ NULL, /* optional */
+ NULL /* close */
+ },
+ {
+ /* group_cls */
+ NULL, /* create */
+ NULL, /* open */
+ NULL, /* get */
+ NULL, /* specific */
+ NULL, /* optional */
+ NULL /* close */
+ },
+ {
+ /* link_cls */
+ NULL, /* create */
+ NULL, /* copy */
+ NULL, /* move */
+ NULL, /* get */
+ NULL, /* specific */
+ NULL /* optional */
+ },
+ {
+ /* object_cls */
+ NULL, /* open */
+ NULL, /* copy */
+ NULL, /* get */
+ NULL, /* specific */
+ NULL /* optional */
+ },
+ {
+ /* introspect_cls */
+ NULL, /* get_conn_cls */
+ NULL, /* get_cap_flags */
+ NULL, /* opt_query */
+ },
+ {
+ /* request_cls */
+ fake_wait_request_wait, /* wait */
+ NULL, /* notify */
+ NULL, /* cancel */
+ NULL, /* specific */
+ NULL, /* optional */
+ fake_wait_request_free /* free */
+ },
+ {
+ /* blob_cls */
+ NULL, /* put */
+ NULL, /* get */
+ NULL, /* specific */
+ NULL /* optional */
+ },
+ {
+ /* token_cls */
+ NULL, /* cmp */
+ NULL, /* to_str */
+ NULL /* from_str */
+ },
+ NULL /* optional */
+};
+
+herr_t
+fake_wait_request_wait(void H5_ATTR_UNUSED *req, uint64_t H5_ATTR_UNUSED timeout,
+ H5VL_request_status_t *status)
+{
+ /* Set status if requested */
+ if (status)
+ *status = H5VL_REQUEST_STATUS_SUCCEED;
+
+ return 0;
+} /* end H5_daos_req_wait() */
+
+herr_t
+fake_wait_request_free(void H5_ATTR_UNUSED *req)
+{
+ return 0;
+} /* end fake_wait_request_free() */
+
/*-------------------------------------------------------------------------
* Function: test_es_create
*
@@ -159,6 +308,324 @@ error:
}
/*-------------------------------------------------------------------------
+ * Function: test_es_get_requests
+ *
+ * Purpose: Tests getting requests from event set.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Wednesday, November 24, 2021
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_es_get_requests(void)
+{
+ hid_t es_id; /* Event set ID */
+ hid_t connector_ids[2]; /* Connector IDs */
+ void * requests[2]; /* Requests */
+ int req_targets[2]; /* Dummy targets for void * requests */
+ size_t count; /* # of events in set */
+ hbool_t op_failed; /* Whether an operation failed (unused) */
+
+ TESTING("event set get requests");
+
+ /* Create an event set */
+ if ((es_id = H5EScreate()) < 0)
+ TEST_ERROR
+
+ /* Get number of requests in event set */
+ count = 3;
+ if (H5ESget_requests(es_id, H5_ITER_NATIVE, NULL, NULL, 0, &count) < 0)
+ TEST_ERROR
+ if (count != 0)
+ TEST_ERROR
+
+ /* Get only connector IDs */
+ count = 3;
+ if (H5ESget_requests(es_id, H5_ITER_NATIVE, connector_ids, NULL, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 0)
+ TEST_ERROR
+
+ /* Get only requests */
+ count = 3;
+ if (H5ESget_requests(es_id, H5_ITER_NATIVE, NULL, requests, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 0)
+ TEST_ERROR
+
+ /* Get both */
+ count = 3;
+ if (H5ESget_requests(es_id, H5_ITER_NATIVE, connector_ids, requests, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 0)
+ TEST_ERROR
+
+ /* Insert event into event set */
+ if (H5ESinsert_request(es_id, connector_ids_g[0], &req_targets[0]) < 0)
+ TEST_ERROR
+
+ /* Get number of requests in event set */
+ count = 0;
+ if (H5ESget_requests(es_id, H5_ITER_NATIVE, NULL, NULL, 0, &count) < 0)
+ TEST_ERROR
+ if (count != 1)
+ TEST_ERROR
+
+ /* Get only connector IDs */
+ count = 0;
+ connector_ids[0] = H5I_INVALID_HID;
+ connector_ids[1] = H5I_INVALID_HID;
+ if (H5ESget_requests(es_id, H5_ITER_NATIVE, connector_ids, NULL, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 1)
+ TEST_ERROR
+ if (connector_ids[0] != connector_ids_g[0])
+ TEST_ERROR
+ if (connector_ids[1] != H5I_INVALID_HID)
+ TEST_ERROR
+
+ /* Get only requests */
+ count = 0;
+ requests[0] = NULL;
+ requests[1] = NULL;
+ if (H5ESget_requests(es_id, H5_ITER_NATIVE, NULL, requests, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 1)
+ TEST_ERROR
+ if (requests[0] != &req_targets[0])
+ TEST_ERROR
+ if (requests[1] != NULL)
+ TEST_ERROR
+
+ /* Get both */
+ count = 0;
+ connector_ids[0] = H5I_INVALID_HID;
+ connector_ids[1] = H5I_INVALID_HID;
+ requests[0] = NULL;
+ requests[1] = NULL;
+ if (H5ESget_requests(es_id, H5_ITER_NATIVE, connector_ids, requests, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 1)
+ TEST_ERROR
+ if (connector_ids[0] != connector_ids_g[0])
+ TEST_ERROR
+ if (connector_ids[1] != H5I_INVALID_HID)
+ TEST_ERROR
+ if (requests[0] != &req_targets[0])
+ TEST_ERROR
+ if (requests[1] != NULL)
+ TEST_ERROR
+
+ /* Insert second event into event set */
+ if (H5ESinsert_request(es_id, connector_ids_g[1], &req_targets[1]) < 0)
+ TEST_ERROR
+
+ /* Get number of requests in event set */
+ count = 0;
+ if (H5ESget_requests(es_id, H5_ITER_NATIVE, NULL, NULL, 0, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+
+ /* Get only connector IDs */
+ count = 0;
+ connector_ids[0] = H5I_INVALID_HID;
+ connector_ids[1] = H5I_INVALID_HID;
+ if (H5ESget_requests(es_id, H5_ITER_INC, connector_ids, NULL, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+ if (connector_ids[0] != connector_ids_g[0])
+ TEST_ERROR
+ if (connector_ids[1] != connector_ids_g[1])
+ TEST_ERROR
+
+ /* Try with H5_ITER_DEC */
+ count = 0;
+ connector_ids[0] = H5I_INVALID_HID;
+ connector_ids[1] = H5I_INVALID_HID;
+ if (H5ESget_requests(es_id, H5_ITER_DEC, connector_ids, NULL, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+ if (connector_ids[0] != connector_ids_g[1])
+ TEST_ERROR
+ if (connector_ids[1] != connector_ids_g[0])
+ TEST_ERROR
+
+ /* Get only requests */
+ count = 0;
+ requests[0] = NULL;
+ requests[1] = NULL;
+ if (H5ESget_requests(es_id, H5_ITER_INC, NULL, requests, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+ if (requests[0] != &req_targets[0])
+ TEST_ERROR
+ if (requests[1] != &req_targets[1])
+ TEST_ERROR
+
+ /* Try with H5_ITER_DEC */
+ count = 0;
+ requests[0] = NULL;
+ requests[1] = NULL;
+ if (H5ESget_requests(es_id, H5_ITER_DEC, NULL, requests, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+ if (requests[0] != &req_targets[1])
+ TEST_ERROR
+ if (requests[1] != &req_targets[0])
+ TEST_ERROR
+
+ /* Get both */
+ count = 0;
+ connector_ids[0] = H5I_INVALID_HID;
+ connector_ids[1] = H5I_INVALID_HID;
+ requests[0] = NULL;
+ requests[1] = NULL;
+ if (H5ESget_requests(es_id, H5_ITER_INC, connector_ids, requests, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+ if (connector_ids[0] != connector_ids_g[0])
+ TEST_ERROR
+ if (connector_ids[1] != connector_ids_g[1])
+ TEST_ERROR
+ if (requests[0] != &req_targets[0])
+ TEST_ERROR
+ if (requests[1] != &req_targets[1])
+ TEST_ERROR
+
+ /* Try with H5_ITER_DEC */
+ count = 0;
+ connector_ids[0] = H5I_INVALID_HID;
+ connector_ids[1] = H5I_INVALID_HID;
+ requests[0] = NULL;
+ requests[1] = NULL;
+ if (H5ESget_requests(es_id, H5_ITER_DEC, connector_ids, requests, 2, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+ if (connector_ids[0] != connector_ids_g[1])
+ TEST_ERROR
+ if (connector_ids[1] != connector_ids_g[0])
+ TEST_ERROR
+ if (requests[0] != &req_targets[1])
+ TEST_ERROR
+ if (requests[1] != &req_targets[0])
+ TEST_ERROR
+
+ /* Get only first connector ID */
+ count = 0;
+ connector_ids[0] = H5I_INVALID_HID;
+ connector_ids[1] = H5I_INVALID_HID;
+ if (H5ESget_requests(es_id, H5_ITER_INC, connector_ids, NULL, 1, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+ if (connector_ids[0] != connector_ids_g[0])
+ TEST_ERROR
+ if (connector_ids[1] != H5I_INVALID_HID)
+ TEST_ERROR
+
+ /* Try with H5_ITER_DEC */
+ count = 0;
+ connector_ids[0] = H5I_INVALID_HID;
+ connector_ids[1] = H5I_INVALID_HID;
+ if (H5ESget_requests(es_id, H5_ITER_DEC, connector_ids, NULL, 1, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+ if (connector_ids[0] != connector_ids_g[1])
+ TEST_ERROR
+ if (connector_ids[1] != H5I_INVALID_HID)
+ TEST_ERROR
+
+ /* Get only first request */
+ count = 0;
+ requests[0] = NULL;
+ requests[1] = NULL;
+ if (H5ESget_requests(es_id, H5_ITER_INC, NULL, requests, 1, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+ if (requests[0] != &req_targets[0])
+ TEST_ERROR
+ if (requests[1] != NULL)
+ TEST_ERROR
+
+ /* Try with H5_ITER_DEC */
+ count = 0;
+ requests[0] = NULL;
+ requests[1] = NULL;
+ if (H5ESget_requests(es_id, H5_ITER_DEC, NULL, requests, 1, &count) < 0)
+ TEST_ERROR
+ if (count != 2)
+ TEST_ERROR
+ if (requests[0] != &req_targets[1])
+ TEST_ERROR
+ if (requests[1] != NULL)
+ TEST_ERROR
+
+ /* Get only first of both */
+ count = 0;
+ connector_ids[0] = H5I_INVALID_HID;
+ connector_ids[1] = H5I_INVALID_HID;
+ requests[0] = NULL;
+ requests[1] = NULL;
+ if (H5ESget_requests(es_id, H5_ITER_INC, connector_ids, requests, 1, &count) < 0)
+ TEST_ERROR
+ if (connector_ids[0] != connector_ids_g[0])
+ TEST_ERROR
+ if (connector_ids[1] != H5I_INVALID_HID)
+ TEST_ERROR
+ if (requests[0] != &req_targets[0])
+ TEST_ERROR
+ if (requests[1] != NULL)
+ TEST_ERROR
+
+ /* Try with H5_ITER_DEC */
+ count = 0;
+ connector_ids[0] = H5I_INVALID_HID;
+ connector_ids[1] = H5I_INVALID_HID;
+ requests[0] = NULL;
+ requests[1] = NULL;
+ if (H5ESget_requests(es_id, H5_ITER_DEC, connector_ids, requests, 1, &count) < 0)
+ TEST_ERROR
+ if (connector_ids[0] != connector_ids_g[1])
+ TEST_ERROR
+ if (connector_ids[1] != H5I_INVALID_HID)
+ TEST_ERROR
+ if (requests[0] != &req_targets[1])
+ TEST_ERROR
+ if (requests[1] != NULL)
+ TEST_ERROR
+
+ /* Close the event set */
+ if (H5ESwait(es_id, 10000000, &count, &op_failed) < 0)
+ TEST_ERROR
+ if (H5ESclose(es_id) < 0)
+ TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5ESclose(es_id);
+ }
+ H5E_END_TRY;
+ return 1;
+}
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Tests event sets
@@ -175,27 +642,41 @@ int
main(void)
{
hid_t fapl_id = H5I_INVALID_HID; /* File access property list */
+ int i; /* Local index variable */
int nerrors = 0; /* Error count */
/* Setup */
h5_reset();
fapl_id = h5_fileaccess();
+ /* Register dummy connector IDs */
+ for (i = 0; i < EVENT_SET_NUM_CONNECTOR_IDS; i++)
+ if ((connector_ids_g[i] = H5VLregister_connector(&fake_wait_vol_g, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
/* Tests */
nerrors += test_es_create();
nerrors += test_es_none();
+ nerrors += test_es_get_requests();
+
+ /* Unregister dummy connectors */
+ for (i = 0; i < EVENT_SET_NUM_CONNECTOR_IDS; i++)
+ if (H5VLunregister_connector(connector_ids_g[i]) < 0)
+ TEST_ERROR
/* Cleanup */
h5_cleanup(FILENAME, fapl_id);
/* Check for any errors */
- if (nerrors) {
- HDputs("***** EVENT SET TESTS FAILED *****");
- HDexit(EXIT_FAILURE);
- } /* end if */
+ if (nerrors)
+ goto error;
/* Report status */
HDputs("All event set tests passed.");
HDexit(EXIT_SUCCESS);
+
+error:
+ HDputs("***** EVENT SET TESTS FAILED *****");
+ HDexit(EXIT_FAILURE);
} /* end main() */