mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Add --disable-mempools configure option
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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[] = {
|
||||
|
||||
@@ -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[] = {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user