aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_dispatch.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-03-14 11:50:45 -0400
committerNick Mathewson <nickm@torproject.org>2019-03-25 16:35:34 -0400
commitb11b4b7bb77c87d2673e816fde114e25a5482a6f (patch)
treef3403d5bc317a8046d34e5a984feee7f9322d120 /src/test/test_dispatch.c
parentab6ddc7a33f7ae6611ebaa00b6bc526d9c286b41 (diff)
downloadtor-b11b4b7bb77c87d2673e816fde114e25a5482a6f.tar.gz
tor-b11b4b7bb77c87d2673e816fde114e25a5482a6f.zip
Add test for dispatch_send() fast path.
Diffstat (limited to 'src/test/test_dispatch.c')
-rw-r--r--src/test/test_dispatch.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/test_dispatch.c b/src/test/test_dispatch.c
index 886f45868e..d6fe7e781a 100644
--- a/src/test/test_dispatch.c
+++ b/src/test/test_dispatch.c
@@ -107,6 +107,38 @@ test_dispatch_simple(void *arg)
tor_free(recv2_received);
}
+/* Construct a dispatch_t with a message and no reciever; make sure that it
+ * gets dropped properly. */
+static void
+test_dispatch_no_recipient(void *arg)
+{
+ (void)arg;
+
+ dispatch_t *d=NULL;
+ dispatch_cfg_t *cfg=NULL;
+ int r;
+
+ cfg = dcfg_new();
+ r = dcfg_msg_set_type(cfg,0,0);
+ r += dcfg_msg_set_chan(cfg,0,0);
+ tt_int_op(r, OP_EQ, 0);
+
+ d = dispatch_new(cfg);
+ tt_assert(d);
+ dispatcher_in_use = d;
+
+ msg_aux_data_t data = { .u64 = 7};
+ r = dispatch_send(d, 99, 0, 0, 0, data);
+ tt_int_op(r, OP_EQ, 0);
+
+ r = dispatch_flush(d, 0, INT_MAX);
+ tt_int_op(r, OP_EQ, 0);
+
+ done:
+ dispatch_free(d);
+ dcfg_free(cfg);
+}
+
struct coord { int x; int y; };
static void
free_coord(msg_aux_data_t d)
@@ -210,6 +242,7 @@ test_dispatch_bad_type_setup(void *arg)
struct testcase_t dispatch_tests[] = {
T(empty),
T(simple),
+ T(no_recipient),
T(with_types),
T(bad_type_setup),
END_OF_TESTCASES