[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Add channel_tls_num_cells_writeable_method() coverage to channeltls/num_bytes_queued unit test



commit 5e9a88e001f66092b8b3fd5fd14877214d038027
Author: Andrea Shepard <andrea@xxxxxxxxxxxxxx>
Date:   Thu Jan 23 07:11:13 2014 -0800

    Add channel_tls_num_cells_writeable_method() coverage to channeltls/num_bytes_queued unit test
---
 src/test/test_channeltls.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/test/test_channeltls.c b/src/test/test_channeltls.c
index b70d0fd..4dcf4c5 100644
--- a/src/test/test_channeltls.c
+++ b/src/test/test_channeltls.c
@@ -100,7 +100,7 @@ test_channeltls_num_bytes_queued(void *arg)
     0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14 };
   channel_tls_t *tlschan = NULL;
   size_t len;
-  int fake_outbuf = 0;
+  int fake_outbuf = 0, n;
 
   (void)arg;
 
@@ -141,6 +141,15 @@ test_channeltls_num_bytes_queued(void *arg)
   MOCK(buf_datalen, tlschan_buf_datalen_mock);
   len = ch->num_bytes_queued(ch);
   test_eq(len, tlschan_buf_datalen_mock_size);
+  /*
+   * We also cover num_cells_writeable here; since wide_circ_ids = 0 on
+   * the fake tlschans, cell_network_size returns 512, and so with
+   * tlschan_buf_datalen_mock_size == 1024, we should be able to write
+   * ceil((OR_CONN_HIGHWATER - 1024) / 512) = ceil(OR_CONN_HIGHWATER / 512)
+   * - 2 cells.
+   */
+  n = ch->num_cells_writeable(ch);
+  test_eq(n, CEIL_DIV(OR_CONN_HIGHWATER, 512) - 2);
   UNMOCK(buf_datalen);
   tlschan_buf_datalen_mock_target = NULL;
   tlschan_buf_datalen_mock_size = 0;



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits