summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2024-11-15 09:38:23 -0500
committerJonathan Bradley <jcb@pikum.xyz>2024-11-15 09:39:22 -0500
commita9eb78c53613aa9836e4968843eb1a93c9a5bff2 (patch)
tree7de3710396f505b2158f321a943fbd346bb04b00 /test
parent41ce960b60bbcf2c3d1a91828bd8ea7bc50a4f2d (diff)
pkev: enforce uint8_t size limits
Diffstat (limited to 'test')
-rw-r--r--test/pkev.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/test/pkev.cpp b/test/pkev.cpp
index 5842b94..a1a3036 100644
--- a/test/pkev.cpp
+++ b/test/pkev.cpp
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
if (ev_one.handled == false || ev_two.handled == false) exit(1);
}
- // overload cbs and evs
+ // overload cbs and evs (grow once)
{
const uint64_t cb_count = PK_EV_INIT_CB_COUNT + 2;
const uint64_t ev_count = PK_EV_INIT_EV_COUNT + 2;
@@ -126,5 +126,39 @@ int main(int argc, char *argv[])
if (any_false == true) exit(1);
}
+ // overload cbs and evs (test limits)
+ {
+ const uint64_t cb_count = 255;
+ const uint64_t ev_count = 255;
+ struct ev evs[ev_count] = {{0}};
+ const pk_ev_mgr_id_T evmgr = test_setup();
+ for (i = 0; i < ev_count; ++i) {
+ evs[i].evmgr = evmgr;
+ evs[i].evid = pk_ev_register_ev(evmgr, NULL);
+ for (ii = 0; ii < cb_count; ++ii) {
+ pk_ev_register_cb(evmgr, evs[i].evid, &stress_cb, NULL);
+ }
+ }
+
+ for (i = 0; i < ev_count; ++i) {
+ struct cb_data *d = new struct cb_data{};
+ d->ev = evs;
+ d->i = i;
+ pk_ev_emit(evs[i].evmgr, evs[i].evid, d);
+ }
+
+ bool any_false = false;
+ uint64_t valid_count = 0;
+ for (i = 0; i < ev_count; ++i) {
+ if (evs[i].handled == true && evs[i].count == 0xFF) valid_count += 1;
+ any_false = any_false || !evs[i].handled;
+ }
+ PK_LOGV_INF("%s: #valid: %lu, called count: %i\n", __FILE__, valid_count, evs[0].count);
+ pk_ev_teardown();
+ fflush(stdout);
+ fflush(stderr);
+ if (any_false == true) exit(1);
+ }
+
return 0;
}