aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2014-05-12 18:23:34 -0700
committerAndrea Shepard <andrea@torproject.org>2014-05-12 18:23:34 -0700
commit39d4e67be8283b2a7141a7aa8342d30e27f47e6f (patch)
treedbc602ce1470c3e8c7b2d13ec89336464b563956 /src/test
parent17435384c050b29cd3c70819ac7176c407f4d1bb (diff)
downloadtor-39d4e67be8283b2a7141a7aa8342d30e27f47e6f.tar
tor-39d4e67be8283b2a7141a7aa8342d30e27f47e6f.tar.gz
Add --disable-mempools configure option
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test.c2
-rw-r--r--src/test/test_cell_queue.c10
-rw-r--r--src/test/test_circuitmux.c4
-rw-r--r--src/test/test_oom.c13
-rw-r--r--src/test/test_util.c8
5 files changed, 37 insertions, 0 deletions
diff --git a/src/test/test.c b/src/test/test.c
index 771725e23..b49f94682 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -51,7 +51,9 @@ double fabs(double x);
#include "rendcommon.h"
#include "test.h"
#include "torgzip.h"
+#ifdef ENABLE_MEMPOOLS
#include "mempool.h"
+#endif
#include "memarea.h"
#include "onion.h"
#include "onion_ntor.h"
diff --git a/src/test/test_cell_queue.c b/src/test/test_cell_queue.c
index 1eac07310..92629823e 100644
--- a/src/test/test_cell_queue.c
+++ b/src/test/test_cell_queue.c
@@ -16,7 +16,10 @@ test_cq_manip(void *arg)
cell_t cell;
(void) arg;
+#ifdef ENABLE_MEMPOOLS
init_cell_pool();
+#endif /* ENABLE_MEMPOOLS */
+
cell_queue_init(&cq);
tt_int_op(cq.n, ==, 0);
@@ -96,7 +99,10 @@ test_cq_manip(void *arg)
packed_cell_free(pc_tmp);
cell_queue_clear(&cq);
+
+#ifdef ENABLE_MEMPOOLS
free_cell_pool();
+#endif /* ENABLE_MEMPOOLS */
}
static void
@@ -108,7 +114,9 @@ test_circuit_n_cells(void *arg)
(void)arg;
+#ifdef ENABLE_MEMPOOLS
init_cell_pool();
+#endif /* ENABLE_MEMPOOLS */
pc1 = packed_cell_new();
pc2 = packed_cell_new();
@@ -137,7 +145,9 @@ test_circuit_n_cells(void *arg)
circuit_free(TO_CIRCUIT(or_c));
circuit_free(TO_CIRCUIT(origin_c));
+#ifdef ENABLE_MEMPOOLS
free_cell_pool();
+#endif /* ENABLE_MEMPOOLS */
}
struct testcase_t cell_queue_tests[] = {
diff --git a/src/test/test_circuitmux.c b/src/test/test_circuitmux.c
index 0f592001c..b9c0436eb 100644
--- a/src/test/test_circuitmux.c
+++ b/src/test/test_circuitmux.c
@@ -36,7 +36,9 @@ test_cmux_destroy_cell_queue(void *arg)
cell_queue_t *cq = NULL;
packed_cell_t *pc = NULL;
+#ifdef ENABLE_MEMPOOLS
init_cell_pool();
+#endif /* ENABLE_MEMPOOLS */
(void) arg;
cmux = circuitmux_alloc();
@@ -74,7 +76,9 @@ test_cmux_destroy_cell_queue(void *arg)
channel_free(ch);
packed_cell_free(pc);
+#ifdef ENABLE_MEMPOOLS
free_cell_pool();
+#endif /* ENABLE_MEMPOOLS */
}
struct testcase_t circuitmux_tests[] = {
diff --git a/src/test/test_oom.c b/src/test/test_oom.c
index 989ca1203..1afe3fd16 100644
--- a/src/test/test_oom.c
+++ b/src/test/test_oom.c
@@ -12,7 +12,9 @@
#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 +132,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 +154,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 */
@@ -220,7 +230,10 @@ test_oom_streambuf(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 = 81*packed_cell_mem_cost() + 4096 * 34;
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 6d6b6dbdf..eadbf730e 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -12,7 +12,9 @@
#include "config.h"
#include "control.h"
#include "test.h"
+#ifdef ENABLE_MEMPOOLS
#include "mempool.h"
+#endif /* ENABLE_MEMPOOLS */
#include "memarea.h"
#ifdef _WIN32
@@ -1899,6 +1901,8 @@ test_util_path_is_relative(void)
;
}
+#ifdef ENABLE_MEMPOOLS
+
/** Run unittests for memory pool allocator */
static void
test_util_mempool(void)
@@ -1957,6 +1961,8 @@ test_util_mempool(void)
mp_pool_destroy(pool);
}
+#endif /* ENABLE_MEMPOOLS */
+
/** Run unittests for memory area allocator */
static void
test_util_memarea(void)
@@ -3656,7 +3662,9 @@ struct testcase_t util_tests[] = {
UTIL_LEGACY(pow2),
UTIL_LEGACY(gzip),
UTIL_LEGACY(datadir),
+#ifdef ENABLE_MEMPOOLS
UTIL_LEGACY(mempool),
+#endif
UTIL_LEGACY(memarea),
UTIL_LEGACY(control_formats),
UTIL_LEGACY(mmap),