summaryrefslogtreecommitdiff
path: root/test/pkev.c
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2024-11-04 17:19:45 -0500
committerJonathan Bradley <jcb@pikum.xyz>2024-11-04 17:19:45 -0500
commit20a26c98b9a6708adb651474aa8bda08733342ac (patch)
tree93e9d0a4739c60f66dee632984208ac9b89a8e1d /test/pkev.c
parentf249c81418bc08d5cef7ea33ac5ff2546ba53774 (diff)
pkev: 1st pass: growing event managers
note: creating more than PK_EV_INIT_MGR_COUNT mgrs is unsupported. A mgr is allocated into contiguous memory. When the reserved number of evs or cbs is passed, the offender grows by PK_EV_GROW_RATIO. PK_EV_INIT_MGR_COUNT = 1 PK_EV_INIT_EV_COUNT = 16 PK_EV_INIT_CB_COUNT = 8 PK_EV_GROW_RATIO = 1.5
Diffstat (limited to 'test/pkev.c')
-rw-r--r--test/pkev.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/test/pkev.c b/test/pkev.c
index 675de4b..c3bfeb9 100644
--- a/test/pkev.c
+++ b/test/pkev.c
@@ -24,13 +24,14 @@ handle_ev_two()
ev_two.handled = true;
}
-struct pk_ev_mgr*
+const pk_ev_mgr_id_T
test_setup()
{
memset(&ev_one, 0, sizeof(struct ev));
memset(&ev_two, 0, sizeof(struct ev));
- struct pk_ev_mgr *evmgr = pk_ev_create();
- if (evmgr == NULL) {
+ pk_ev_init();
+ const pk_ev_mgr_id_T evmgr = pk_ev_create_mgr();
+ if (evmgr >= 64) {
PK_LOGV_ERR("%s: failed to create pk_ev_mgr\n", __FILE__);
exit(1);
}
@@ -42,21 +43,20 @@ int main(int argc, char *argv[])
(void)argc;
(void)argv;
(void)stdout;
- pk_ev_id_T custom_ev_one = 1;
- pk_ev_id_T custom_ev_two = 2;
+ pk_ev_id_T custom_ev_one;
+ pk_ev_id_T custom_ev_two;
// register, emit, catch
{
- // TODO
- struct pk_ev_mgr *evmgr = test_setup();
- pk_ev_register_ev(evmgr, custom_ev_one);
- pk_ev_register_ev(evmgr, custom_ev_two);
+ const pk_ev_mgr_id_T evmgr = test_setup();
+ custom_ev_one = pk_ev_register_ev(evmgr);
+ custom_ev_two = pk_ev_register_ev(evmgr);
pk_ev_register_cb(evmgr, custom_ev_one, handle_ev_one);
- pk_ev_register_cb(evmgr, custom_ev_one, handle_ev_two);
+ pk_ev_register_cb(evmgr, custom_ev_two, handle_ev_two);
pk_ev_emit(evmgr, custom_ev_one);
pk_ev_emit(evmgr, custom_ev_two);
PK_LOGV_INF("%s: ev_one: %b, ev_two: %b\n", __FILE__, ev_one.handled, ev_two.handled);
- free(evmgr);
+ pk_ev_teardown();
if (ev_one.handled == false || ev_two.handled == false) exit(1);
}