aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_oom.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test_oom.c')
-rw-r--r--src/test/test_oom.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/test_oom.c b/src/test/test_oom.c
index 989ca1203..32f4803bb 100644
--- a/src/test/test_oom.c
+++ b/src/test/test_oom.c
@@ -6,13 +6,16 @@
#define RELAY_PRIVATE
#define BUFFERS_PRIVATE
#define CIRCUITLIST_PRIVATE
+#define CONNECTION_PRIVATE
#include "or.h"
#include "buffers.h"
#include "circuitlist.h"
#include "compat_libevent.h"
#include "connection.h"
#include "config.h"
+#ifdef ENABLE_MEMPOOLS
#include "mempool.h"
+#endif
#include "relay.h"
#include "test.h"
@@ -130,7 +133,10 @@ test_oom_circbuf(void *arg)
(void) arg;
MOCK(circuit_mark_for_close_, circuit_mark_for_close_dummy_);
+
+#ifdef ENABLE_MEMPOOLS
init_cell_pool();
+#endif /* ENABLE_MEMPOOLS */
/* Far too low for real life. */
options->MaxMemInQueues = 256*packed_cell_mem_cost();
@@ -149,8 +155,13 @@ test_oom_circbuf(void *arg)
tor_gettimeofday_cache_set(&tv);
c2 = dummy_or_circuit_new(20, 20);
+#ifdef ENABLE_MEMPOOLS
tt_int_op(packed_cell_mem_cost(), ==,
sizeof(packed_cell_t) + MP_POOL_ITEM_OVERHEAD);
+#else
+ tt_int_op(packed_cell_mem_cost(), ==,
+ sizeof(packed_cell_t));
+#endif /* ENABLE_MEMPOOLS */
tt_int_op(cell_queues_get_total_allocation(), ==,
packed_cell_mem_cost() * 70);
tt_int_op(cell_queues_check_size(), ==, 0); /* We are still not OOM */
@@ -216,11 +227,15 @@ test_oom_streambuf(void *arg)
struct timeval tv = { 1389641159, 0 };
uint32_t tvms;
int i;
+ smartlist_t *edgeconns = smartlist_new();
(void) arg;
MOCK(circuit_mark_for_close_, circuit_mark_for_close_dummy_);
+
+#ifdef ENABLE_MEMPOOLS
init_cell_pool();
+#endif /* ENABLE_MEMPOOLS */
/* Far too low for real life. */
options->MaxMemInQueues = 81*packed_cell_mem_cost() + 4096 * 34;
@@ -257,17 +272,21 @@ test_oom_streambuf(void *arg)
tor_gettimeofday_cache_set(&tv);
ec = dummy_edge_conn_new(c1, CONN_TYPE_EXIT, 1000, 1000);
tt_assert(ec);
+ smartlist_add(edgeconns, ec);
tv.tv_usec += 10*1000;
tor_gettimeofday_cache_set(&tv);
ec = dummy_edge_conn_new(c2, CONN_TYPE_AP, 1000, 1000);
tt_assert(ec);
+ smartlist_add(edgeconns, ec);
tv.tv_usec += 10*1000;
tor_gettimeofday_cache_set(&tv);
ec = dummy_edge_conn_new(c4, CONN_TYPE_EXIT, 1000, 1000); /* Yes, 4 twice*/
tt_assert(ec);
+ smartlist_add(edgeconns, ec);
tv.tv_usec += 10*1000;
tor_gettimeofday_cache_set(&tv);
ec = dummy_edge_conn_new(c4, CONN_TYPE_EXIT, 1000, 1000);
+ smartlist_add(edgeconns, ec);
tt_assert(ec);
}
@@ -302,6 +321,7 @@ test_oom_streambuf(void *arg)
tor_gettimeofday_cache_set(&tv);
ec = dummy_edge_conn_new(c4, CONN_TYPE_EXIT, 1000, 1000);
tt_assert(ec);
+ smartlist_add(edgeconns, ec);
}
tt_int_op(buf_get_total_allocation(), ==, 4096*17*2);
tt_int_op(circuit_max_queued_item_age(c4, tvms), ==, 1000);
@@ -337,6 +357,10 @@ test_oom_streambuf(void *arg)
circuit_free(c4);
circuit_free(c5);
+ SMARTLIST_FOREACH(edgeconns, edge_connection_t *, ec,
+ connection_free_(TO_CONN(ec)));
+ smartlist_free(edgeconns);
+
UNMOCK(circuit_mark_for_close_);
}