nxt_lvlhsh_test.c (594:c89b29f038c4) nxt_lvlhsh_test.c (595:686246c79c5a)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include "nxt_tests.h"

--- 208 unchanged lines hidden (view full) ---

217 }
218
219 if (i != n) {
220 nxt_log_error(NXT_LOG_NOTICE, thr->log,
221 "lvlhsh peek test failed at %ui of %ui", i, n);
222 return NXT_ERROR;
223 }
224
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include "nxt_tests.h"

--- 208 unchanged lines hidden (view full) ---

217 }
218
219 if (i != n) {
220 nxt_log_error(NXT_LOG_NOTICE, thr->log,
221 "lvlhsh peek test failed at %ui of %ui", i, n);
222 return NXT_ERROR;
223 }
224
225 if (!nxt_lvlhsh_is_empty(&lh)) {
226 nxt_log_error(NXT_LOG_NOTICE, thr->log,
227 "lvlhsh is not empty after deletion");
228 return NXT_ERROR;
229 }
230
231 key = 0;
232 for (i = 0; i < n; i++) {
233 key = nxt_murmur_hash2(&key, sizeof(uint32_t));
234
235 if (nxt_lvlhsh_test_add(&lh, proto, mp, key) != NXT_OK) {
236 nxt_log_error(NXT_LOG_NOTICE, thr->log,
237 "lvlhsh add test failed at %ui", i);
238 return NXT_ERROR;
239 }
240 }
241
242 for (i = 0; i < n; i++) {
243 value = nxt_lvlhsh_retrieve(&lh, proto, mp);
244
245 if (value == NULL) {
246 break;
247 }
248 }
249
250 if (i != n) {
251 nxt_log_error(NXT_LOG_NOTICE, thr->log,
252 "lvlhsh retrieve test failed at %ui of %ui", i, n);
253 return NXT_ERROR;
254 }
255
256 if (!nxt_lvlhsh_is_empty(&lh)) {
257 nxt_log_error(NXT_LOG_NOTICE, thr->log,
258 "lvlhsh is not empty after retrieving");
259 return NXT_ERROR;
260 }
261
225 if (mp != NULL) {
226 if (!nxt_mp_is_empty(mp)) {
227 nxt_log_error(NXT_LOG_NOTICE, thr->log, "mem pool is not empty");
228 return NXT_ERROR;
229 }
230
231 nxt_mp_destroy(mp);
232 }
233
234 nxt_thread_time_update(thr);
235 end = nxt_thread_monotonic_time(thr);
236
237 nxt_log_error(NXT_LOG_NOTICE, thr->log, "lvlhsh test passed: %0.3fs",
238 (end - start) / 1000000000.0);
239
240 return NXT_OK;
241}
262 if (mp != NULL) {
263 if (!nxt_mp_is_empty(mp)) {
264 nxt_log_error(NXT_LOG_NOTICE, thr->log, "mem pool is not empty");
265 return NXT_ERROR;
266 }
267
268 nxt_mp_destroy(mp);
269 }
270
271 nxt_thread_time_update(thr);
272 end = nxt_thread_monotonic_time(thr);
273
274 nxt_log_error(NXT_LOG_NOTICE, thr->log, "lvlhsh test passed: %0.3fs",
275 (end - start) / 1000000000.0);
276
277 return NXT_OK;
278}