Merge branch '46-just-use-clang-format-to-reformat-sources' into 'master'
Reformat source code with clang-format Closes #46 See merge request isc-projects/bind9!2156 (cherry picked from commit7099e79a9b)4c3b063eImport Linux kernel .clang-format with small modificationsf50b1e06Use clang-format to reformat the source files11341c76Update the definition files for Windowsdf6c1f76Remove tkey_test (which is no-op anyway)
This commit is contained in:
@@ -11,12 +11,11 @@
|
||||
|
||||
#if HAVE_CMOCKA
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <sched.h> /* IWYU pragma: keep */
|
||||
#include <setjmp.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -34,7 +33,8 @@
|
||||
#include "isctest.h"
|
||||
|
||||
static int
|
||||
_setup(void **state) {
|
||||
_setup(void **state)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(state);
|
||||
@@ -46,7 +46,8 @@ _setup(void **state) {
|
||||
}
|
||||
|
||||
static int
|
||||
_teardown(void **state) {
|
||||
_teardown(void **state)
|
||||
{
|
||||
UNUSED(state);
|
||||
|
||||
isc_test_end();
|
||||
@@ -54,12 +55,12 @@ _teardown(void **state) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_ht_full(int bits, uintptr_t count) {
|
||||
isc_ht_t *ht = NULL;
|
||||
test_ht_full(int bits, uintptr_t count)
|
||||
{
|
||||
isc_ht_t * ht = NULL;
|
||||
isc_result_t result;
|
||||
uintptr_t i;
|
||||
uintptr_t i;
|
||||
|
||||
result = isc_ht_init(&ht, test_mctx, bits);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
@@ -73,25 +74,25 @@ test_ht_full(int bits, uintptr_t count) {
|
||||
unsigned char key[16];
|
||||
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
||||
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_add(ht, key, 16, (void *) i);
|
||||
result = isc_ht_add(ht, key, 16, (void *)i);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
for (i = 1; i < count; i++) {
|
||||
unsigned char key[16];
|
||||
void *f = NULL;
|
||||
void * f = NULL;
|
||||
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
||||
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_find(ht, key, 16, &f);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
assert_ptr_equal((void *) i, (uintptr_t) f);
|
||||
assert_ptr_equal((void *)i, (uintptr_t)f);
|
||||
}
|
||||
|
||||
for (i = 1; i < count; i++) {
|
||||
unsigned char key[16];
|
||||
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
||||
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_add(ht, key, 16, (void *) i);
|
||||
result = isc_ht_add(ht, key, 16, (void *)i);
|
||||
assert_int_equal(result, ISC_R_EXISTS);
|
||||
}
|
||||
|
||||
@@ -103,14 +104,14 @@ test_ht_full(int bits, uintptr_t count) {
|
||||
*/
|
||||
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
||||
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_add(ht, (const unsigned char *) key,
|
||||
strlen(key), (void *) i);
|
||||
result = isc_ht_add(ht, (const unsigned char *)key, strlen(key),
|
||||
(void *)i);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
for (i = 1; i < count; i++) {
|
||||
unsigned char key[16];
|
||||
void *f = NULL;
|
||||
void * f = NULL;
|
||||
/*
|
||||
* Note: case of KEY is now in capitals,
|
||||
*/
|
||||
@@ -122,19 +123,19 @@ test_ht_full(int bits, uintptr_t count) {
|
||||
}
|
||||
|
||||
for (i = 1; i < count; i++) {
|
||||
char key[64];
|
||||
char key[64];
|
||||
void *f = NULL;
|
||||
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
||||
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_find(ht, (const unsigned char *) key,
|
||||
result = isc_ht_find(ht, (const unsigned char *)key,
|
||||
strlen(key), &f);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
assert_ptr_equal(f, (void *) i);
|
||||
assert_ptr_equal(f, (void *)i);
|
||||
}
|
||||
|
||||
for (i = 1; i < count; i++) {
|
||||
unsigned char key[16];
|
||||
void *f = NULL;
|
||||
void * f = NULL;
|
||||
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
||||
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_delete(ht, key, 16);
|
||||
@@ -151,28 +152,27 @@ test_ht_full(int bits, uintptr_t count) {
|
||||
*/
|
||||
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
||||
strlcat((char *)key, " KEY of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_add(ht, key, 16, (void *) i);
|
||||
result = isc_ht_add(ht, key, 16, (void *)i);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
for (i = 1; i < count; i++) {
|
||||
char key[64];
|
||||
char key[64];
|
||||
void *f = NULL;
|
||||
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
||||
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_delete(ht, (const unsigned char *) key,
|
||||
result = isc_ht_delete(ht, (const unsigned char *)key,
|
||||
strlen(key));
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = isc_ht_find(ht, (const unsigned char *) key,
|
||||
result = isc_ht_find(ht, (const unsigned char *)key,
|
||||
strlen(key), &f);
|
||||
assert_int_equal(result, ISC_R_NOTFOUND);
|
||||
assert_null(f);
|
||||
}
|
||||
|
||||
|
||||
for (i = 1; i < count; i++) {
|
||||
unsigned char key[16];
|
||||
void *f = NULL;
|
||||
void * f = NULL;
|
||||
/*
|
||||
* Note: case of KEY is now in capitals,
|
||||
*/
|
||||
@@ -180,12 +180,12 @@ test_ht_full(int bits, uintptr_t count) {
|
||||
strlcat((char *)key, " KEY of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_find(ht, key, 16, &f);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
assert_ptr_equal((void *) i, (uintptr_t) f);
|
||||
assert_ptr_equal((void *)i, (uintptr_t)f);
|
||||
}
|
||||
|
||||
for (i = 1; i < count; i++) {
|
||||
unsigned char key[16];
|
||||
void *f = NULL;
|
||||
void * f = NULL;
|
||||
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
||||
strlcat((char *)key, " key of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_find(ht, key, 16, &f);
|
||||
@@ -198,15 +198,16 @@ test_ht_full(int bits, uintptr_t count) {
|
||||
}
|
||||
|
||||
static void
|
||||
test_ht_iterator() {
|
||||
isc_ht_t *ht = NULL;
|
||||
isc_result_t result;
|
||||
isc_ht_iter_t * iter = NULL;
|
||||
uintptr_t i;
|
||||
uintptr_t count = 10000;
|
||||
uint32_t walked;
|
||||
unsigned char key[16];
|
||||
size_t tksize;
|
||||
test_ht_iterator()
|
||||
{
|
||||
isc_ht_t * ht = NULL;
|
||||
isc_result_t result;
|
||||
isc_ht_iter_t *iter = NULL;
|
||||
uintptr_t i;
|
||||
uintptr_t count = 10000;
|
||||
uint32_t walked;
|
||||
unsigned char key[16];
|
||||
size_t tksize;
|
||||
|
||||
result = isc_ht_init(&ht, test_mctx, 16);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
@@ -218,7 +219,7 @@ test_ht_iterator() {
|
||||
*/
|
||||
snprintf((char *)key, sizeof(key), "%u", (unsigned int)i);
|
||||
strlcat((char *)key, "key of a raw hashtable!!", sizeof(key));
|
||||
result = isc_ht_add(ht, key, 16, (void *) i);
|
||||
result = isc_ht_add(ht, key, 16, (void *)i);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -226,12 +227,10 @@ test_ht_iterator() {
|
||||
result = isc_ht_iter_create(ht, &iter);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
for (result = isc_ht_iter_first(iter);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = isc_ht_iter_next(iter))
|
||||
{
|
||||
for (result = isc_ht_iter_first(iter); result == ISC_R_SUCCESS;
|
||||
result = isc_ht_iter_next(iter)) {
|
||||
unsigned char *tkey = NULL;
|
||||
void *v = NULL;
|
||||
void * v = NULL;
|
||||
|
||||
isc_ht_iter_current(iter, &v);
|
||||
isc_ht_iter_currentkey(iter, &tkey, &tksize);
|
||||
@@ -250,7 +249,7 @@ test_ht_iterator() {
|
||||
result = isc_ht_iter_first(iter);
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
unsigned char *tkey = NULL;
|
||||
void *v = NULL;
|
||||
void * v = NULL;
|
||||
|
||||
isc_ht_iter_current(iter, &v);
|
||||
isc_ht_iter_currentkey(iter, &tkey, &tksize);
|
||||
@@ -274,7 +273,7 @@ test_ht_iterator() {
|
||||
result = isc_ht_iter_first(iter);
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
unsigned char *tkey = NULL;
|
||||
void *v = NULL;
|
||||
void * v = NULL;
|
||||
|
||||
isc_ht_iter_current(iter, &v);
|
||||
isc_ht_iter_currentkey(iter, &tkey, &tksize);
|
||||
@@ -291,13 +290,11 @@ test_ht_iterator() {
|
||||
walked++;
|
||||
}
|
||||
assert_int_equal(result, ISC_R_NOMORE);
|
||||
assert_int_equal(walked, count/2);
|
||||
assert_int_equal(walked, count / 2);
|
||||
|
||||
walked = 0;
|
||||
for (result = isc_ht_iter_first(iter);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = isc_ht_iter_next(iter))
|
||||
{
|
||||
for (result = isc_ht_iter_first(iter); result == ISC_R_SUCCESS;
|
||||
result = isc_ht_iter_next(iter)) {
|
||||
walked++;
|
||||
}
|
||||
|
||||
@@ -313,35 +310,39 @@ test_ht_iterator() {
|
||||
|
||||
/* 20 bit, 200K elements test */
|
||||
static void
|
||||
isc_ht_20(void **state) {
|
||||
isc_ht_20(void **state)
|
||||
{
|
||||
UNUSED(state);
|
||||
test_ht_full(20, 200000);
|
||||
}
|
||||
|
||||
|
||||
/* 8 bit, 20000 elements crowded test */
|
||||
static void
|
||||
isc_ht_8(void **state) {
|
||||
isc_ht_8(void **state)
|
||||
{
|
||||
UNUSED(state);
|
||||
test_ht_full(8, 20000);
|
||||
}
|
||||
|
||||
/* 8 bit, 100 elements corner case test */
|
||||
static void
|
||||
isc_ht_1(void **state) {
|
||||
isc_ht_1(void **state)
|
||||
{
|
||||
UNUSED(state);
|
||||
test_ht_full(1, 100);
|
||||
}
|
||||
|
||||
/* test hashtable iterator */
|
||||
static void
|
||||
isc_ht_iterator_test(void **state) {
|
||||
isc_ht_iterator_test(void **state)
|
||||
{
|
||||
UNUSED(state);
|
||||
test_ht_iterator();
|
||||
}
|
||||
|
||||
int
|
||||
main(void) {
|
||||
main(void)
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(isc_ht_20),
|
||||
cmocka_unit_test(isc_ht_8),
|
||||
@@ -357,7 +358,8 @@ main(void) {
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(void) {
|
||||
main(void)
|
||||
{
|
||||
printf("1..0 # Skipped: cmocka not available\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user