diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-04-26 17:46:33 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-04-26 17:46:33 -0400 |
commit | f09629eac53bc3c122a4319edf1c5b4f5315ec1f (patch) | |
tree | 9cc3f97dc9859f123d047781d79d36043dd4dd7e /test/regress.c | |
parent | 30ea2910d5c4e529bc4d993c0657f3c98ea13582 (diff) | |
download | libevent-f09629eac53bc3c122a4319edf1c5b4f5315ec1f.tar.gz |
A test for event_get_assignment()
Diffstat (limited to 'test/regress.c')
-rw-r--r-- | test/regress.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/regress.c b/test/regress.c index 8de7e7d3..d157c067 100644 --- a/test/regress.c +++ b/test/regress.c @@ -2635,6 +2635,37 @@ end: ; } +static void +test_get_assignment(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct event *ev1 = NULL; + const char *str = "foo"; + + struct event_base *b; + evutil_socket_t s; + short what; + event_callback_fn cb; + void *cb_arg; + + ev1 = event_new(base, data->pair[1], EV_READ, dummy_read_cb, (void*)str); + event_get_assignment(ev1, &b, &s, &what, &cb, &cb_arg); + + tt_ptr_op(b, ==, base); + tt_int_op(s, ==, data->pair[1]); + tt_int_op(what, ==, EV_READ); + tt_ptr_op(cb, ==, dummy_read_cb); + tt_ptr_op(cb_arg, ==, str); + + /* Now make sure this doesn't crash. */ + event_get_assignment(ev1, NULL, NULL, NULL, NULL, NULL); + +end: + if (ev1) + event_free(ev1); +} + struct foreach_helper { int count; const struct event *ev; @@ -2851,6 +2882,7 @@ struct testcase_t main_testcases[] = { { "many_events_slow_add", test_many_events, TT_ISOLATED, &basic_setup, (void*)1 }, { "struct_event_size", test_struct_event_size, 0, NULL, NULL }, + BASIC(get_assignment, TT_FORK|TT_NEED_BASE|TT_NEED_SOCKETPAIR), BASIC(event_foreach, TT_FORK|TT_NEED_BASE), { "gettimeofday_cached", test_gettimeofday_cached, TT_FORK, &basic_setup, (void*)"" }, |