2016-05-26 21:23:19 +02:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2016-05-26 21:23:19 +02:00
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
2016-05-26 21:23:19 +02:00
|
|
|
*/
|
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
#if HAVE_CMOCKA
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <setjmp.h>
|
2016-05-26 21:23:19 +02:00
|
|
|
|
2018-03-28 14:19:37 +02:00
|
|
|
#include <inttypes.h>
|
2016-05-26 21:23:19 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2018-10-24 01:13:13 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define UNIT_TESTING
|
|
|
|
#include <cmocka.h>
|
2016-05-26 21:23:19 +02:00
|
|
|
|
|
|
|
#include <isc/hash.h>
|
|
|
|
#include <isc/ht.h>
|
|
|
|
#include <isc/mem.h>
|
2016-05-26 12:36:17 -07:00
|
|
|
#include <isc/print.h>
|
2017-09-27 16:02:02 +10:00
|
|
|
#include <isc/string.h>
|
2016-05-26 21:23:19 +02:00
|
|
|
#include <isc/util.h>
|
|
|
|
|
|
|
|
static void *
|
|
|
|
default_memalloc(void *arg, size_t size) {
|
|
|
|
UNUSED(arg);
|
2018-10-24 01:13:13 -07:00
|
|
|
if (size == 0U) {
|
2016-05-26 21:23:19 +02:00
|
|
|
size = 1;
|
2018-10-24 01:13:13 -07:00
|
|
|
}
|
2016-05-26 21:23:19 +02:00
|
|
|
return (malloc(size));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
default_memfree(void *arg, void *ptr) {
|
|
|
|
UNUSED(arg);
|
|
|
|
free(ptr);
|
|
|
|
}
|
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
static void
|
|
|
|
test_ht_full(int bits, uintptr_t count) {
|
2016-05-26 21:23:19 +02:00
|
|
|
isc_ht_t *ht = NULL;
|
|
|
|
isc_result_t result;
|
|
|
|
isc_mem_t *mctx = NULL;
|
2017-10-20 16:04:59 +11:00
|
|
|
uintptr_t i;
|
2016-05-26 21:23:19 +02:00
|
|
|
|
2018-10-03 19:04:46 -07:00
|
|
|
result = isc_mem_createx(0, 0, default_memalloc, default_memfree,
|
|
|
|
NULL, &mctx, 0);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-05-26 21:23:19 +02:00
|
|
|
|
2017-10-19 13:08:31 +11:00
|
|
|
result = isc_ht_init(&ht, mctx, bits);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
assert_non_null(ht);
|
2017-10-19 13:08:31 +11:00
|
|
|
|
2016-05-26 21:23:19 +02:00
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
/*
|
2017-09-27 16:02:02 +10:00
|
|
|
* Note: snprintf() is followed with strlcat()
|
|
|
|
* to ensure we are always filling the 16 byte key.
|
2016-05-26 21:23:19 +02:00
|
|
|
*/
|
|
|
|
unsigned char key[16];
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_add(ht, key, 16, (void *) i);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
unsigned char key[16];
|
|
|
|
void *f = NULL;
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_find(ht, key, 16, &f);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
assert_ptr_equal((void *) i, (uintptr_t) f);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
unsigned char key[16];
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_add(ht, key, 16, (void *) i);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_EXISTS);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
char key[64];
|
2017-09-27 16:02:02 +10:00
|
|
|
/*
|
|
|
|
* Note: the key size is now strlen(key) which is bigger
|
|
|
|
* then the keys added above.
|
|
|
|
*/
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_add(ht, (const unsigned char *) key,
|
|
|
|
strlen(key), (void *) i);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
unsigned char key[16];
|
|
|
|
void *f = NULL;
|
2017-09-27 16:02:02 +10:00
|
|
|
/*
|
|
|
|
* Note: case of KEY is now in capitals,
|
|
|
|
*/
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " KEY of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_find(ht, key, 16, &f);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_NOTFOUND);
|
|
|
|
assert_null(f);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
char key[64];
|
|
|
|
void *f = NULL;
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_find(ht, (const unsigned char *) key,
|
|
|
|
strlen(key), &f);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
assert_ptr_equal(f, (void *) i);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
unsigned char key[16];
|
|
|
|
void *f = NULL;
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_delete(ht, key, 16);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_find(ht, key, 16, &f);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_NOTFOUND);
|
|
|
|
assert_null(f);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
unsigned char key[16];
|
2017-09-27 16:02:02 +10:00
|
|
|
/*
|
|
|
|
* Note: upper case KEY.
|
|
|
|
*/
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " KEY of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_add(ht, key, 16, (void *) i);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
char key[64];
|
|
|
|
void *f = NULL;
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_delete(ht, (const unsigned char *) key,
|
|
|
|
strlen(key));
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_find(ht, (const unsigned char *) key,
|
|
|
|
strlen(key), &f);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_NOTFOUND);
|
|
|
|
assert_null(f);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
unsigned char key[16];
|
|
|
|
void *f = NULL;
|
2017-09-27 16:02:02 +10:00
|
|
|
/*
|
|
|
|
* Note: case of KEY is now in capitals,
|
|
|
|
*/
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " KEY of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_find(ht, key, 16, &f);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
assert_ptr_equal((void *) i, (uintptr_t) f);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
unsigned char key[16];
|
|
|
|
void *f = NULL;
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_find(ht, key, 16, &f);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_NOTFOUND);
|
|
|
|
assert_null(f);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
isc_ht_destroy(&ht);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_null(ht);
|
|
|
|
|
|
|
|
isc_mem_detach(&mctx);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
static void
|
|
|
|
test_ht_iterator() {
|
2016-05-26 21:23:19 +02:00
|
|
|
isc_ht_t *ht = NULL;
|
|
|
|
isc_result_t result;
|
|
|
|
isc_mem_t *mctx = NULL;
|
2016-05-31 23:01:53 +02:00
|
|
|
isc_ht_iter_t * iter = NULL;
|
2017-10-20 16:04:59 +11:00
|
|
|
uintptr_t i;
|
|
|
|
uintptr_t count = 10000;
|
2018-03-28 14:19:37 +02:00
|
|
|
uint32_t walked;
|
2016-05-31 23:01:53 +02:00
|
|
|
unsigned char key[16];
|
|
|
|
size_t tksize;
|
2016-05-26 21:23:19 +02:00
|
|
|
|
2018-10-03 19:04:46 -07:00
|
|
|
result = isc_mem_createx(0, 0, default_memalloc, default_memfree,
|
|
|
|
NULL, &mctx, 0);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-05-26 21:23:19 +02:00
|
|
|
|
|
|
|
result = isc_ht_init(&ht, mctx, 16);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
assert_non_null(ht);
|
2016-05-26 21:23:19 +02:00
|
|
|
for (i = 1; i <= count; i++) {
|
|
|
|
/*
|
|
|
|
* Note that the string we're snprintfing is always > 16 bytes
|
|
|
|
* so we are always filling the key.
|
|
|
|
*/
|
2017-09-27 17:57:07 +10:00
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, "key of a raw hashtable!!", sizeof(key));
|
2016-05-26 21:23:19 +02:00
|
|
|
result = isc_ht_add(ht, key, 16, (void *) i);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
walked = 0;
|
2016-05-31 23:01:53 +02:00
|
|
|
result = isc_ht_iter_create(ht, &iter);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-05-26 21:23:19 +02:00
|
|
|
|
2016-05-31 23:01:53 +02:00
|
|
|
for (result = isc_ht_iter_first(iter);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = isc_ht_iter_next(iter))
|
|
|
|
{
|
2018-11-28 18:57:38 +11:00
|
|
|
unsigned char *tkey = NULL;
|
|
|
|
void *v = NULL;
|
|
|
|
|
2017-10-20 16:04:59 +11:00
|
|
|
isc_ht_iter_current(iter, &v);
|
2016-05-31 23:01:53 +02:00
|
|
|
isc_ht_iter_currentkey(iter, &tkey, &tksize);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(tksize, 16);
|
2017-10-20 16:04:59 +11:00
|
|
|
i = (uintptr_t)v;
|
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, "key of a raw hashtable!!", sizeof(key));
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_memory_equal(key, tkey, 16);
|
2016-05-31 23:01:53 +02:00
|
|
|
walked++;
|
|
|
|
}
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(walked, count);
|
|
|
|
assert_int_equal(result, ISC_R_NOMORE);
|
2016-05-26 21:23:19 +02:00
|
|
|
|
2016-05-31 23:01:53 +02:00
|
|
|
/* erase odd */
|
2016-05-26 21:23:19 +02:00
|
|
|
walked = 0;
|
2016-05-31 23:01:53 +02:00
|
|
|
result = isc_ht_iter_first(iter);
|
|
|
|
while (result == ISC_R_SUCCESS) {
|
2018-11-28 18:57:38 +11:00
|
|
|
unsigned char *tkey = NULL;
|
|
|
|
void *v = NULL;
|
|
|
|
|
2017-10-20 16:04:59 +11:00
|
|
|
isc_ht_iter_current(iter, &v);
|
2016-05-31 23:01:53 +02:00
|
|
|
isc_ht_iter_currentkey(iter, &tkey, &tksize);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(tksize, 16);
|
2017-10-20 16:04:59 +11:00
|
|
|
i = (uintptr_t)v;
|
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, "key of a raw hashtable!!", sizeof(key));
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_memory_equal(key, tkey, 16);
|
2017-10-20 16:04:59 +11:00
|
|
|
if ((uintptr_t)v % 2 == 0) {
|
2016-05-31 23:01:53 +02:00
|
|
|
result = isc_ht_iter_delcurrent_next(iter);
|
|
|
|
} else {
|
|
|
|
result = isc_ht_iter_next(iter);
|
|
|
|
}
|
|
|
|
walked++;
|
|
|
|
}
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_NOMORE);
|
|
|
|
assert_int_equal(walked, count);
|
2016-05-26 21:23:19 +02:00
|
|
|
|
2016-05-31 23:01:53 +02:00
|
|
|
/* erase even */
|
2016-05-26 21:23:19 +02:00
|
|
|
walked = 0;
|
2016-05-31 23:01:53 +02:00
|
|
|
result = isc_ht_iter_first(iter);
|
|
|
|
while (result == ISC_R_SUCCESS) {
|
2018-11-28 18:57:38 +11:00
|
|
|
unsigned char *tkey = NULL;
|
|
|
|
void *v = NULL;
|
|
|
|
|
2017-10-20 16:04:59 +11:00
|
|
|
isc_ht_iter_current(iter, &v);
|
2016-05-31 23:01:53 +02:00
|
|
|
isc_ht_iter_currentkey(iter, &tkey, &tksize);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(tksize, 16);
|
2017-10-20 16:04:59 +11:00
|
|
|
i = (uintptr_t)v;
|
|
|
|
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
2017-09-27 16:02:02 +10:00
|
|
|
strlcat((char *)key, "key of a raw hashtable!!", sizeof(key));
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_memory_equal(key, tkey, 16);
|
2017-10-20 16:04:59 +11:00
|
|
|
if ((uintptr_t)v % 2 == 1) {
|
2016-05-31 23:01:53 +02:00
|
|
|
result = isc_ht_iter_delcurrent_next(iter);
|
|
|
|
} else {
|
|
|
|
result = isc_ht_iter_next(iter);
|
|
|
|
}
|
|
|
|
walked++;
|
|
|
|
}
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_NOMORE);
|
|
|
|
assert_int_equal(walked, count/2);
|
2016-05-26 21:23:19 +02:00
|
|
|
|
|
|
|
walked = 0;
|
2016-05-31 23:01:53 +02:00
|
|
|
for (result = isc_ht_iter_first(iter);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = isc_ht_iter_next(iter))
|
|
|
|
{
|
|
|
|
walked++;
|
|
|
|
}
|
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_int_equal(result, ISC_R_NOMORE);
|
|
|
|
assert_int_equal(walked, 0);
|
|
|
|
|
|
|
|
isc_ht_iter_destroy(&iter);
|
|
|
|
assert_null(iter);
|
2016-05-26 21:23:19 +02:00
|
|
|
|
|
|
|
isc_ht_destroy(&ht);
|
2018-10-24 01:13:13 -07:00
|
|
|
assert_null(ht);
|
2016-05-26 21:23:19 +02:00
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
isc_mem_detach(&mctx);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
/* 20 bit, 200K elements test */
|
|
|
|
static void
|
|
|
|
isc_ht_20(void **state) {
|
|
|
|
UNUSED(state);
|
2018-03-08 23:31:22 -08:00
|
|
|
test_ht_full(20, 200000);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
/* 8 bit, 20000 elements crowded test */
|
|
|
|
static void
|
|
|
|
isc_ht_8(void **state) {
|
|
|
|
UNUSED(state);
|
2016-05-26 21:23:19 +02:00
|
|
|
test_ht_full(8, 20000);
|
|
|
|
}
|
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
/* 8 bit, 100 elements corner case test */
|
|
|
|
static void
|
|
|
|
isc_ht_1(void **state) {
|
|
|
|
UNUSED(state);
|
2016-05-26 21:23:19 +02:00
|
|
|
test_ht_full(1, 100);
|
|
|
|
}
|
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
/* test hashtable iterator */
|
|
|
|
static void
|
|
|
|
isc_ht_iterator_test(void **state) {
|
|
|
|
UNUSED(state);
|
|
|
|
test_ht_iterator();
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
int
|
|
|
|
main(void) {
|
|
|
|
const struct CMUnitTest tests[] = {
|
|
|
|
cmocka_unit_test(isc_ht_20),
|
|
|
|
cmocka_unit_test(isc_ht_8),
|
|
|
|
cmocka_unit_test(isc_ht_1),
|
|
|
|
cmocka_unit_test(isc_ht_iterator_test),
|
|
|
|
};
|
2016-05-26 21:23:19 +02:00
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
return (cmocka_run_group_tests(tests, NULL, NULL));
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
#else /* HAVE_CMOCKA */
|
2016-05-26 21:23:19 +02:00
|
|
|
|
2018-10-24 01:13:13 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main(void) {
|
|
|
|
printf("1..0 # Skipped: cmocka not available\n");
|
|
|
|
return (0);
|
2016-05-26 21:23:19 +02:00
|
|
|
}
|
2018-10-24 01:13:13 -07:00
|
|
|
|
|
|
|
#endif
|