diff options
author | David Goulet <dgoulet@torproject.org> | 2019-10-22 11:04:35 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2019-10-28 13:17:11 -0400 |
commit | a41ec8491480ea27588225c8db108503b2d7f757 (patch) | |
tree | 400b1eceaf809d78cd2f9dd2bb9a73ddc74547d5 /src/test/test_circuitmux.c | |
parent | d2e51aca7da8851e81d4ed0edb2a093652817385 (diff) | |
download | tor-a41ec8491480ea27588225c8db108503b2d7f757.tar.gz tor-a41ec8491480ea27588225c8db108503b2d7f757.zip |
test: Implement cmux allocate unit test
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_circuitmux.c')
-rw-r--r-- | src/test/test_circuitmux.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/test_circuitmux.c b/src/test/test_circuitmux.c index cb57b1bd60..d4d99660cc 100644 --- a/src/test/test_circuitmux.c +++ b/src/test/test_circuitmux.c @@ -117,6 +117,31 @@ test_cmux_compute_ticks(void *arg) ; } +static void +test_cmux_allocate(void *arg) +{ + circuitmux_t *cmux = NULL; + + (void) arg; + + cmux = circuitmux_alloc(); + tt_assert(cmux); + tt_assert(cmux->chanid_circid_map); + tt_int_op(HT_SIZE(cmux->chanid_circid_map), OP_EQ, 0); + tt_uint_op(cmux->n_circuits, OP_EQ, 0); + tt_uint_op(cmux->n_active_circuits, OP_EQ, 0); + tt_uint_op(cmux->n_cells, OP_EQ, 0); + tt_uint_op(cmux->last_cell_was_destroy, OP_EQ, 0); + tt_int_op(cmux->destroy_ctr, OP_EQ, 0); + tt_ptr_op(cmux->policy, OP_EQ, NULL); + tt_ptr_op(cmux->policy_data, OP_EQ, NULL); + + tt_assert(TOR_SIMPLEQ_EMPTY(&cmux->destroy_cell_queue.head)); + + done: + circuitmux_free(cmux); +} + static void * cmux_setup_test(const struct testcase_t *tc) { @@ -148,6 +173,10 @@ static struct testcase_setup_t cmux_test_setup = { { #name, test_cmux_##name, TT_FORK, &cmux_test_setup, NULL } struct testcase_t circuitmux_tests[] = { + /* Test circuitmux_t object */ + TEST_CMUX(allocate), + + /* Misc. */ TEST_CMUX(compute_ticks), TEST_CMUX(destroy_cell_queue), |