diff options
author | Pauli <pauli@openssl.org> | 2022-07-27 11:52:17 +1000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2022-08-12 15:44:01 +0100 |
commit | d13c8b7725437490be8c1a2b438936af10f808d0 (patch) | |
tree | 9b81352bc87cdf6b4908b8c1eb935b555a5430be /test/event_queue_test.c | |
parent | 2d46a44ff24173d2cf5ea2196360cb79470d49c7 (diff) | |
download | openssl-d13c8b7725437490be8c1a2b438936af10f808d0.zip openssl-d13c8b7725437490be8c1a2b438936af10f808d0.tar.gz openssl-d13c8b7725437490be8c1a2b438936af10f808d0.tar.bz2 |
Make OSSL_TIME a structure
This prevents misuses creeping in.
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18882)
Diffstat (limited to 'test/event_queue_test.c')
-rw-r--r-- | test/event_queue_test.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/test/event_queue_test.c b/test/event_queue_test.c index 76765c5..686233c 100644 --- a/test/event_queue_test.c +++ b/test/event_queue_test.c @@ -11,7 +11,7 @@ #include "internal/nelem.h" #include "testutil.h" -static OSSL_TIME cur_time = 100; +static OSSL_TIME cur_time = { 100 }; OSSL_TIME ossl_time_now(void) { @@ -31,38 +31,49 @@ static int event_test(void) /* Create an event queue and add some events */ if (!TEST_ptr(q = ossl_event_queue_new()) - || !TEST_ptr(e1 = ossl_event_queue_add_new(q, 1, 10, 1100, "ctx 1", + || !TEST_ptr(e1 = ossl_event_queue_add_new(q, 1, 10, + ossl_ticks2time(1100), + "ctx 1", PAYLOAD(payload))) - || !TEST_ptr(e2 = ossl_event_queue_add_new(q, 2, 5, 1100, "ctx 2", + || !TEST_ptr(e2 = ossl_event_queue_add_new(q, 2, 5, + ossl_ticks2time(1100), + "ctx 2", PAYLOAD("data"))) - || !TEST_true(ossl_event_queue_add(q, &e3, 3, 20, 1200, "ctx 3", + || !TEST_true(ossl_event_queue_add(q, &e3, 3, 20, + ossl_ticks2time(1200), "ctx 3", PAYLOAD("more data"))) - || !TEST_ptr(e4 = ossl_event_queue_add_new(q, 2, 5, 1150, "ctx 2", + || !TEST_ptr(e4 = ossl_event_queue_add_new(q, 2, 5, + ossl_ticks2time(1150), + "ctx 2", PAYLOAD("data"))) /* Verify some event details */ || !TEST_uint_eq(ossl_event_get_type(e1), 1) || !TEST_uint_eq(ossl_event_get_priority(e1), 10) - || !TEST_uint64_t_eq(ossl_event_get_when(e1), 1100) + || !TEST_uint64_t_eq(ossl_time2ticks(ossl_event_get_when(e1)) + , 1100) || !TEST_str_eq(ossl_event_get0_ctx(e1), "ctx 1") || !TEST_ptr(p = ossl_event_get0_payload(e1, &len)) || !TEST_str_eq((char *)p, payload) - || !TEST_uint64_t_eq(ossl_event_time_until(&e3), 1100) - || !TEST_uint64_t_eq(ossl_event_queue_time_until_next(q), 1000) + || !TEST_uint64_t_eq(ossl_time2ticks(ossl_event_time_until(&e3)), + 1100) + || !TEST_uint64_t_eq(ossl_time2ticks(ossl_event_queue_time_until_next(q)), + 1000) /* Modify an event's time */ - || !TEST_true(ossl_event_queue_postpone_until(q, e1, 1200)) - || !TEST_uint64_t_eq(ossl_event_get_when(e1), 1200) + || !TEST_true(ossl_event_queue_postpone_until(q, e1, + ossl_ticks2time(1200))) + || !TEST_uint64_t_eq(ossl_time2ticks(ossl_event_get_when(e1)), 1200) || !TEST_true(ossl_event_queue_remove(q, e4))) goto err; ossl_event_free(e4); /* Execute the queue */ - cur_time = 1000; + cur_time = ossl_ticks2time(1000); if (!TEST_true(ossl_event_queue_get1_next_event(q, &ep)) || !TEST_ptr_null(ep)) goto err; - cur_time = 1100; + cur_time = ossl_ticks2time(1100); if (!TEST_true(ossl_event_queue_get1_next_event(q, &ep)) || !TEST_ptr_eq(ep, e2)) goto err; @@ -72,7 +83,7 @@ static int event_test(void) || !TEST_ptr_null(ep)) goto err; - cur_time = 1250; + cur_time = ossl_ticks2time(1250); if (!TEST_true(ossl_event_queue_get1_next_event(q, &ep)) || !TEST_ptr_eq(ep, &e3)) goto err; |