[tor-commits] [tor/master] Check queueing case in channel/flushmux unit test too
nickm at torproject.org
nickm at torproject.org
Fri Nov 28 03:58:33 UTC 2014
commit 9740a07b8c5b2608f0a937799f9e24ce0f468de7
Author: Andrea Shepard <andrea at torproject.org>
Date: Wed Jan 22 02:33:27 2014 -0800
Check queueing case in channel/flushmux unit test too
---
src/test/test_channel.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/test/test_channel.c b/src/test/test_channel.c
index 2f5e946..588f698 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;
More information about the tor-commits
mailing list