diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-02-11 15:09:01 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-02-11 15:09:01 -0500 |
commit | d7a1e83f50f201df9ef35f48e31dd3cbdcd653e8 (patch) | |
tree | a7fcb7f3417d36df8402ef2cec83d978b8c6fb27 /src/test | |
parent | caf28519d9a4f7f0a5fa36a0cd94fe9c0ee292dc (diff) | |
parent | 6f331645c75e88ec4f6dbabce5a2d3733894dd78 (diff) | |
download | tor-d7a1e83f50f201df9ef35f48e31dd3cbdcd653e8.tar.gz tor-d7a1e83f50f201df9ef35f48e31dd3cbdcd653e8.zip |
Merge remote-tracking branch 'public/remove_freelist'
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_buffers.c | 18 | ||||
-rw-r--r-- | src/test/test_util.c | 67 |
2 files changed, 1 insertions, 84 deletions
diff --git a/src/test/test_buffers.c b/src/test/test_buffers.c index 101f448472..0ede8081d8 100644 --- a/src/test/test_buffers.c +++ b/src/test/test_buffers.c @@ -193,7 +193,6 @@ test_buffers_basic(void *arg) buf_free(buf); if (buf2) buf_free(buf2); - buf_shrink_freelists(1); } static void @@ -297,12 +296,9 @@ test_buffer_pullup(void *arg) buf_free(buf); buf = NULL; - buf_shrink_freelists(1); - tt_int_op(buf_get_total_allocation(), OP_EQ, 0); done: buf_free(buf); - buf_shrink_freelists(1); tor_free(stuff); tor_free(tmp); } @@ -370,7 +366,6 @@ test_buffer_copy(void *arg) generic_buffer_free(buf); if (buf2) generic_buffer_free(buf2); - buf_shrink_freelists(1); } static void @@ -445,7 +440,6 @@ test_buffer_ext_or_cmd(void *arg) ext_or_cmd_free(cmd); generic_buffer_free(buf); tor_free(tmp); - buf_shrink_freelists(1); } static void @@ -481,20 +475,13 @@ test_buffer_allocation_tracking(void *arg) fetch_from_buf(junk, 4096, buf1); /* drop a 1k chunk... */ tt_int_op(buf_allocation(buf1), OP_EQ, 3*4096); /* now 3 4k chunks */ -#ifdef ENABLE_BUF_FREELISTS - tt_int_op(buf_get_total_allocation(), OP_EQ, 16384); /* that chunk went onto - the freelist. */ -#else tt_int_op(buf_get_total_allocation(), OP_EQ, 12288); /* that chunk was really freed. */ -#endif write_to_buf(junk, 4000, buf2); tt_int_op(buf_allocation(buf2), OP_EQ, 4096); /* another 4k chunk. */ /* - * 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. + * We bounce back up to 16384 by allocating a new chunk. */ tt_int_op(buf_get_total_allocation(), OP_EQ, 16384); write_to_buf(junk, 4000, buf2); @@ -512,17 +499,14 @@ test_buffer_allocation_tracking(void *arg) buf2 = NULL; tt_int_op(buf_get_total_allocation(), OP_LT, 4008000); - buf_shrink_freelists(1); tt_int_op(buf_get_total_allocation(), OP_EQ, buf_allocation(buf1)); buf_free(buf1); buf1 = NULL; - buf_shrink_freelists(1); tt_int_op(buf_get_total_allocation(), OP_EQ, 0); done: buf_free(buf1); buf_free(buf2); - buf_shrink_freelists(1); tor_free(junk); } diff --git a/src/test/test_util.c b/src/test/test_util.c index e5df5b4494..9939bf4e3e 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -6,15 +6,11 @@ #include "orconfig.h" #define COMPAT_PRIVATE #define CONTROL_PRIVATE -#define MEMPOOL_PRIVATE #define UTIL_PRIVATE #include "or.h" #include "config.h" #include "control.h" #include "test.h" -#ifdef ENABLE_MEMPOOLS -#include "mempool.h" -#endif /* ENABLE_MEMPOOLS */ #include "memarea.h" #include "util_process.h" @@ -2644,69 +2640,6 @@ test_util_path_is_relative(void *arg) ; } -#ifdef ENABLE_MEMPOOLS - -/** Run unittests for memory pool allocator */ -static void -test_util_mempool(void *arg) -{ - mp_pool_t *pool = NULL; - smartlist_t *allocated = NULL; - int i; - - (void)arg; - pool = mp_pool_new(1, 100); - tt_assert(pool); - tt_assert(pool->new_chunk_capacity >= 100); - tt_assert(pool->item_alloc_size >= sizeof(void*)+1); - mp_pool_destroy(pool); - pool = NULL; - - pool = mp_pool_new(241, 2500); - tt_assert(pool); - tt_assert(pool->new_chunk_capacity >= 10); - tt_assert(pool->item_alloc_size >= sizeof(void*)+241); - tt_int_op(pool->item_alloc_size & 0x03,OP_EQ, 0); - tt_assert(pool->new_chunk_capacity < 60); - - allocated = smartlist_new(); - for (i = 0; i < 20000; ++i) { - if (smartlist_len(allocated) < 20 || crypto_rand_int(2)) { - void *m = mp_pool_get(pool); - memset(m, 0x09, 241); - smartlist_add(allocated, m); - //printf("%d: %p\n", i, m); - //mp_pool_assert_ok(pool); - } else { - int idx = crypto_rand_int(smartlist_len(allocated)); - void *m = smartlist_get(allocated, idx); - //printf("%d: free %p\n", i, m); - smartlist_del(allocated, idx); - mp_pool_release(m); - //mp_pool_assert_ok(pool); - } - if (crypto_rand_int(777)==0) - mp_pool_clean(pool, 1, 1); - - if (i % 777) - mp_pool_assert_ok(pool); - } - - done: - if (allocated) { - SMARTLIST_FOREACH(allocated, void *, m, mp_pool_release(m)); - mp_pool_assert_ok(pool); - mp_pool_clean(pool, 0, 0); - mp_pool_assert_ok(pool); - smartlist_free(allocated); - } - - if (pool) - mp_pool_destroy(pool); -} - -#endif /* ENABLE_MEMPOOLS */ - /** Run unittests for memory area allocator */ static void test_util_memarea(void *arg) |