Add channel_tls_num_cells_writeable_method() coverage to channeltls/num_bytes_queued unit test

This commit is contained in:
Andrea Shepard 2014-01-23 07:11:13 -08:00
parent 030b0fe107
commit 5e9a88e001

View File

@ -100,7 +100,7 @@ test_channeltls_num_bytes_queued(void *arg)
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14 }; 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14 };
channel_tls_t *tlschan = NULL; channel_tls_t *tlschan = NULL;
size_t len; size_t len;
int fake_outbuf = 0; int fake_outbuf = 0, n;
(void)arg; (void)arg;
@ -141,6 +141,15 @@ test_channeltls_num_bytes_queued(void *arg)
MOCK(buf_datalen, tlschan_buf_datalen_mock); MOCK(buf_datalen, tlschan_buf_datalen_mock);
len = ch->num_bytes_queued(ch); len = ch->num_bytes_queued(ch);
test_eq(len, tlschan_buf_datalen_mock_size); 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); UNMOCK(buf_datalen);
tlschan_buf_datalen_mock_target = NULL; tlschan_buf_datalen_mock_target = NULL;
tlschan_buf_datalen_mock_size = 0; tlschan_buf_datalen_mock_size = 0;