diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-03-13 15:41:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-03-25 16:35:34 -0400 |
commit | 9fb511526ae37cb7c7b5ed4714550f58882ef697 (patch) | |
tree | f93ff44f36081c713cfb6fcaea71403688fb6631 /src | |
parent | beedadbeacc00222e1bdebec638c1e8cd48a8b14 (diff) | |
download | tor-9fb511526ae37cb7c7b5ed4714550f58882ef697.tar.gz tor-9fb511526ae37cb7c7b5ed4714550f58882ef697.zip |
pubsub test: add a test to make sure typefns can't be changed.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test_dispatch.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/test_dispatch.c b/src/test/test_dispatch.c index ec704c042a..061e9df14a 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 }; |