diff options
author | Andrea Shepard <andrea@torproject.org> | 2014-01-23 07:11:13 -0800 |
---|---|---|
committer | Andrea Shepard <andrea@torproject.org> | 2014-09-30 23:14:25 -0700 |
commit | 5e9a88e001f66092b8b3fd5fd14877214d038027 (patch) | |
tree | dd59275bd83f16ef3985875ab16057600e799043 /src/test/test_channeltls.c | |
parent | 030b0fe1076bd8747e3fecf32740c0b3fd3759eb (diff) | |
download | tor-5e9a88e001f66092b8b3fd5fd14877214d038027.tar.gz tor-5e9a88e001f66092b8b3fd5fd14877214d038027.zip |
Add channel_tls_num_cells_writeable_method() coverage to channeltls/num_bytes_queued unit test
Diffstat (limited to 'src/test/test_channeltls.c')
-rw-r--r-- | src/test/test_channeltls.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/test/test_channeltls.c b/src/test/test_channeltls.c index b70d0fd2fa..4dcf4c5579 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; |