summaryrefslogtreecommitdiffhomepage
path: root/test/nxt_mem_zone_unit_test.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-08-30 00:31:02 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-08-30 00:31:02 +0300
commitcdc7e4479ff5aa08df0857a13a7acd7a00b79c89 (patch)
treea57bf9251fc79d9ef7bd3d33b1d05f3813dc3d4a /test/nxt_mem_zone_unit_test.c
parent92f3b852981c739a2e6ff6d50dc646fe86031b27 (diff)
downloadunit-cdc7e4479ff5aa08df0857a13a7acd7a00b79c89.tar.gz
unit-cdc7e4479ff5aa08df0857a13a7acd7a00b79c89.tar.bz2
Lib unit tests have been renamed to tests.
Diffstat (limited to 'test/nxt_mem_zone_unit_test.c')
-rw-r--r--test/nxt_mem_zone_unit_test.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/test/nxt_mem_zone_unit_test.c b/test/nxt_mem_zone_unit_test.c
deleted file mode 100644
index cce9b702..00000000
--- a/test/nxt_mem_zone_unit_test.c
+++ /dev/null
@@ -1,73 +0,0 @@
-
-/*
- * Copyright (C) Igor Sysoev
- * Copyright (C) NGINX, Inc.
- */
-
-#include <nxt_main.h>
-
-
-nxt_int_t
-nxt_mem_zone_unit_test(nxt_thread_t *thr, nxt_uint_t runs, nxt_uint_t nblocks,
- size_t max_size)
-{
- void *start, **blocks;
- size_t total, zone_size;
- uint32_t size;
- nxt_uint_t i, n;
- nxt_mem_zone_t *zone;
- const size_t page_size = 4096;
-
- nxt_thread_time_update(thr);
- nxt_log_error(NXT_LOG_NOTICE, thr->log,
- "mem zone unit test started, max:%uz", max_size);
-
- zone_size = (max_size + 1) * nblocks;
-
- start = nxt_memalign(page_size, zone_size);
- if (start == NULL) {
- return NXT_ERROR;
- }
-
- zone = nxt_mem_zone_init(start, zone_size, page_size);
- if (zone == NULL) {
- return NXT_ERROR;
- }
-
- blocks = nxt_malloc(nblocks * sizeof(void *));
- if (blocks == NULL) {
- return NXT_ERROR;
- }
-
- size = 0;
-
- for (i = 0; i < runs; i++) {
-
- total = 0;
-
- for (n = 0; n < nblocks; n++) {
- size = nxt_murmur_hash2(&size, sizeof(uint32_t));
-
- total += size & max_size;
- blocks[n] = nxt_mem_zone_alloc(zone, size & max_size);
-
- if (blocks[n] == NULL) {
- nxt_log_error(NXT_LOG_NOTICE, thr->log,
- "mem zone unit test failed: %uz", total);
- return NXT_ERROR;
- }
- }
-
- for (n = 0; n < nblocks; n++) {
- nxt_mem_zone_free(zone, blocks[n]);
- }
- }
-
- nxt_free(blocks);
- nxt_free(zone);
-
- nxt_thread_time_update(thr);
- nxt_log_error(NXT_LOG_NOTICE, thr->log, "mem zone unit test passed");
-
- return NXT_OK;
-}