diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-03-14 19:00:32 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-03-14 19:00:32 +0300 |
commit | aa047be6b95aa1694c84f326ef78775f97283cb7 (patch) | |
tree | f363b0ae07084e17819a9c63988dcf56dfddbfe1 | |
parent | 612c083579a78c9d51fa9976e46f45b6cbaf93db (diff) | |
download | unit-aa047be6b95aa1694c84f326ef78775f97283cb7.tar.gz unit-aa047be6b95aa1694c84f326ef78775f97283cb7.tar.bz2 |
Zero size memory pool allocations have been disabled in unit test
becuase they are handled incorrectly with the -DNXT_DEBUG_MEMORY=1
option.
-rw-r--r-- | test/nxt_mem_cache_pool_unit_test.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/test/nxt_mem_cache_pool_unit_test.c b/test/nxt_mem_cache_pool_unit_test.c index 6b35f5af..b9da5099 100644 --- a/test/nxt_mem_cache_pool_unit_test.c +++ b/test/nxt_mem_cache_pool_unit_test.c @@ -13,7 +13,7 @@ nxt_mem_cache_pool_unit_test(nxt_thread_t *thr, nxt_uint_t runs, { void **blocks; size_t total; - uint32_t size; + uint32_t value, size; nxt_uint_t i, n; nxt_mem_cache_pool_t *pool; @@ -37,17 +37,23 @@ nxt_mem_cache_pool_unit_test(nxt_thread_t *thr, nxt_uint_t runs, return NXT_ERROR; } - size = 0; + value = 0; for (i = 0; i < runs; i++) { total = 0; for (n = 0; n < nblocks; n++) { - size = nxt_murmur_hash2(&size, sizeof(uint32_t)); + value = nxt_murmur_hash2(&value, sizeof(uint32_t)); - total += size & max_size; - blocks[n] = nxt_mem_cache_alloc(pool, size & max_size); + 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, |