diff options
author | Andrea Shepard <andrea@torproject.org> | 2014-01-22 02:33:27 -0800 |
---|---|---|
committer | Andrea Shepard <andrea@torproject.org> | 2014-09-30 23:14:23 -0700 |
commit | 9740a07b8c5b2608f0a937799f9e24ce0f468de7 (patch) | |
tree | aedcd0240aca85984be06b447f58235784f23599 /src/test/test_channel.c | |
parent | f12f7159a53f191a981104bae3f87d65a581e1f8 (diff) | |
download | tor-9740a07b8c5b2608f0a937799f9e24ce0f468de7.tar.gz tor-9740a07b8c5b2608f0a937799f9e24ce0f468de7.zip |
Check queueing case in channel/flushmux unit test too
Diffstat (limited to 'src/test/test_channel.c')
-rw-r--r-- | src/test/test_channel.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/test/test_channel.c b/src/test/test_channel.c index 2f5e9465a7..588f698854 100644 --- a/src/test/test_channel.c +++ b/src/test/test_channel.c @@ -481,7 +481,7 @@ static void test_channel_flushmux(void *arg) { channel_t *ch = NULL; - int old_count; + int old_count, q_len_before, q_len_after; ssize_t result; (void)arg; @@ -512,6 +512,28 @@ test_channel_flushmux(void *arg) test_eq(test_cells_written, old_count + 1); test_eq(test_cmux_cells, 0); + /* Now try it without accepting to force them into the queue */ + test_chan_accept_cells = 0; + test_cmux_cells = 1; + q_len_before = chan_cell_queue_len(&(ch->outgoing_queue)); + + result = channel_flush_some_cells(ch, 1); + + /* We should not have actually flushed any */ + test_eq(result, 0); + test_eq(test_cells_written, old_count + 1); + /* But we should have gotten to the fake cellgen loop */ + test_eq(test_cmux_cells, 0); + /* ...and we should have a queued cell */ + q_len_after = chan_cell_queue_len(&(ch->outgoing_queue)); + test_eq(q_len_after, q_len_before + 1); + + /* Now accept cells again and drain the queue */ + test_chan_accept_cells = 1; + channel_flush_cells(ch); + test_eq(test_cells_written, old_count + 2); + test_eq(chan_cell_queue_len(&(ch->outgoing_queue)), 0); + test_target_cmux = NULL; test_cmux_cells = 0; |