summaryrefslogtreecommitdiffhomepage
path: root/test/nxt_mem_cache_pool_unit_test.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-06-19 16:26:19 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-06-19 16:26:19 +0300
commitb1b9f621a44725509aa7b6eab7305542945893a3 (patch)
treec9925a19d7304f52d9d5e2cc87a5ba5cc72acd4a /test/nxt_mem_cache_pool_unit_test.c
parent7574c64992b98d3dfbc3dd101bd0f7d78bad0823 (diff)
downloadunit-b1b9f621a44725509aa7b6eab7305542945893a3.tar.gz
unit-b1b9f621a44725509aa7b6eab7305542945893a3.tar.bz2
Memory pools refactoring.
Diffstat (limited to 'test/nxt_mem_cache_pool_unit_test.c')
-rw-r--r--test/nxt_mem_cache_pool_unit_test.c83
1 files changed, 0 insertions, 83 deletions
diff --git a/test/nxt_mem_cache_pool_unit_test.c b/test/nxt_mem_cache_pool_unit_test.c
deleted file mode 100644
index b9da5099..00000000
--- a/test/nxt_mem_cache_pool_unit_test.c
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
- * Copyright (C) Igor Sysoev
- * Copyright (C) NGINX, Inc.
- */
-
-#include <nxt_main.h>
-
-
-nxt_int_t
-nxt_mem_cache_pool_unit_test(nxt_thread_t *thr, nxt_uint_t runs,
- nxt_uint_t nblocks, size_t max_size)
-{
- void **blocks;
- size_t total;
- uint32_t value, size;
- nxt_uint_t i, n;
- nxt_mem_cache_pool_t *pool;
-
- const size_t min_chunk_size = 16;
- const size_t page_size = 128;
- const size_t page_alignment = 128;
- const size_t cluster_size = page_size * 8;
-
- nxt_thread_time_update(thr);
- nxt_log_error(NXT_LOG_NOTICE, thr->log,
- "mem cache pool unit test started, max:%uz", max_size);
-
- blocks = nxt_malloc(nblocks * sizeof(void *));
- if (blocks == NULL) {
- return NXT_ERROR;
- }
-
- pool = nxt_mem_cache_pool_create(cluster_size, page_alignment,
- page_size, min_chunk_size);
- if (pool == NULL) {
- return NXT_ERROR;
- }
-
- value = 0;
-
- for (i = 0; i < runs; i++) {
-
- total = 0;
-
- for (n = 0; n < nblocks; n++) {
- value = nxt_murmur_hash2(&value, sizeof(uint32_t));
-
- size = value & max_size;
-
- if (size == 0) {
- size++;
- }
-
- total += size;
- blocks[n] = nxt_mem_cache_alloc(pool, size);
-
- if (blocks[n] == NULL) {
- nxt_log_error(NXT_LOG_NOTICE, thr->log,
- "mem cache pool unit test failed: %uz", total);
- return NXT_ERROR;
- }
- }
-
- for (n = 0; n < nblocks; n++) {
- nxt_mem_cache_free(pool, blocks[n]);
- }
- }
-
- if (!nxt_mem_cache_pool_is_empty(pool)) {
- nxt_log_error(NXT_LOG_NOTICE, thr->log, "mem cache pool is not empty");
- return NXT_ERROR;
- }
-
- nxt_mem_cache_pool_destroy(pool);
-
- nxt_free(blocks);
-
- nxt_thread_time_update(thr);
- nxt_log_error(NXT_LOG_NOTICE, thr->log, "mem cache pool unit test passed");
-
- return NXT_OK;
-}