[tor-commits] [tor/master] pubsub test: add a test to make sure typefns can't be changed.

asn at torproject.org asn at torproject.org
Wed Mar 27 12:31:31 UTC 2019


commit 9fb511526ae37cb7c7b5ed4714550f58882ef697
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Mar 13 15:41:36 2019 -0400

    pubsub test: add a test to make sure typefns can't be changed.
---
 src/test/test_dispatch.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/test/test_dispatch.c b/src/test/test_dispatch.c
index ec704c042..061e9df14 100644
--- a/src/test/test_dispatch.c
+++ b/src/test/test_dispatch.c
@@ -170,6 +170,30 @@ test_dispatch_with_types(void *arg)
   dispatcher_in_use = NULL;
 }
 
+static void
+test_dispatch_bad_type_setup(void *arg)
+{
+  (void)arg;
+  static dispatch_typefns_t fns;
+  dispatch_cfg_t *cfg = dcfg_new();
+
+  tt_int_op(0, OP_EQ, dcfg_type_set_fns(cfg, 7, &coord_fns));
+
+  fns = coord_fns;
+  fns.fmt_fn = NULL;
+  tt_int_op(-1, OP_EQ, dcfg_type_set_fns(cfg, 7, &fns));
+
+  fns = coord_fns;
+  fns.free_fn = NULL;
+  tt_int_op(-1, OP_EQ, dcfg_type_set_fns(cfg, 7, &fns));
+
+  fns = coord_fns;
+  tt_int_op(0, OP_EQ, dcfg_type_set_fns(cfg, 7, &fns));
+
+ done:
+  dcfg_free(cfg);
+}
+
 #define T(name)                                                 \
   { #name, test_dispatch_ ## name, TT_FORK, NULL, NULL }
 
@@ -177,5 +201,6 @@ struct testcase_t dispatch_tests[] = {
   T(empty),
   T(simple),
   T(with_types),
+  T(bad_type_setup),
   END_OF_TESTCASES
 };





More information about the tor-commits mailing list