aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2014-04-29 02:18:34 -0700
committerAndrea Shepard <andrea@torproject.org>2014-04-29 02:18:34 -0700
commit91ff10f6be984c6ca00a7240d32e79ab7db09c7c (patch)
treef05158871709b439772283b0828a1110fa8e8513 /src/test
parentcdc64f020c926cd51b037b85b5eba5bf08d66e7d (diff)
downloadtor-91ff10f6be984c6ca00a7240d32e79ab7db09c7c.tar
tor-91ff10f6be984c6ca00a7240d32e79ab7db09c7c.tar.gz
Make --disable-buf-freelists build and pass unit tests
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_buffers.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/test/test_buffers.c b/src/test/test_buffers.c
index 6dd771593..c2cfd2700 100644
--- a/src/test/test_buffers.c
+++ b/src/test/test_buffers.c
@@ -481,13 +481,22 @@ test_buffer_allocation_tracking(void *arg)
fetch_from_buf(junk, 4096, buf1); /* drop a 1k chunk... */
tt_int_op(buf_allocation(buf1), ==, 3*4096); /* now 3 4k chunks */
+#ifdef ENABLE_BUF_FREELISTS
tt_int_op(buf_get_total_allocation(), ==, 16384); /* that chunk went onto
the freelist. */
+#else
+ tt_int_op(buf_get_total_allocation(), ==, 12288); /* that chunk was really
+ freed. */
+#endif
write_to_buf(junk, 4000, buf2);
tt_int_op(buf_allocation(buf2), ==, 4096); /* another 4k chunk. */
- tt_int_op(buf_get_total_allocation(), ==, 16384); /* that chunk came from
- the freelist. */
+ /*
+ * If we're using freelists, size stays at 16384 because we just pulled a
+ * chunk from the freelist. If we aren't, we bounce back up to 16384 by
+ * allocating a new chunk.
+ */
+ tt_int_op(buf_get_total_allocation(), ==, 16384);
write_to_buf(junk, 4000, buf2);
tt_int_op(buf_allocation(buf2), ==, 8192); /* another 4k chunk. */
tt_int_op(buf_get_total_allocation(), ==, 5*4096); /* that chunk was new. */