commit b5d4ef18e172c18dd169570b17dfb14a4a270ae1 Author: Andrea Shepard andrea@torproject.org Date: Tue Jan 21 22:54:40 2014 -0800
Add unknown cell queue entry type case to channel/queue_impossible unit test --- src/test/test_channel.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/src/test/test_channel.c b/src/test/test_channel.c index 2f07413..add57de 100644 --- a/src/test/test_channel.c +++ b/src/test/test_channel.c @@ -896,6 +896,32 @@ test_channel_queue_impossible(void *arg) test_assert(test_cells_written == old_count); test_eq(chan_cell_queue_len(&(ch->outgoing_queue)), 0);
+ /* Unknown cell type case */ + test_chan_accept_cells = 0; + ch->state = CHANNEL_STATE_MAINT; + cell = tor_malloc_zero(sizeof(cell_t)); + make_fake_cell(cell); + channel_write_cell(ch, cell); + + /* Check that it's queued */ + test_eq(chan_cell_queue_len(&(ch->outgoing_queue)),1); + q = TOR_SIMPLEQ_FIRST(&(ch->outgoing_queue)); + test_assert(q); + if (q) { + test_eq(q->type, CELL_QUEUE_FIXED); + test_eq(q->u.fixed.cell, cell); + } + /* Clobber it, including the queue entry type */ + tor_free(q->u.fixed.cell); + q->u.fixed.cell = NULL; + q->type = CELL_QUEUE_PACKED + 1; + + /* Let it drain and check that the bad entry is discarded */ + test_chan_accept_cells = 1; + channel_change_state(ch, CHANNEL_STATE_OPEN); + test_assert(test_cells_written == old_count); + test_eq(chan_cell_queue_len(&(ch->outgoing_queue)), 0); + done: tor_free(ch); free_cell_pool();
tor-commits@lists.torproject.org