Merge branch 'michal/cmocka-future-proofing' into 'main'

cmocka future-proofing

See merge request isc-projects/bind9!7939
This commit is contained in:
Michał Kępień
2023-05-18 13:30:48 +00:00
67 changed files with 68 additions and 62 deletions
-1
View File
@@ -16,7 +16,6 @@ libisc_la_HEADERS = \
include/isc/base32.h \
include/isc/base64.h \
include/isc/buffer.h \
include/isc/cmocka.h \
include/isc/commandline.h \
include/isc/condition.h \
include/isc/counter.h \
-55
View File
@@ -1,55 +0,0 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* 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 https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
/*! \file isc/cmocka.h */
#pragma once
#include <cmocka.h>
#include <isc/lang.h>
ISC_LANG_BEGINDECLS
/*
* Copy the test identified by 'name' from 'tests' to 'selected'.
*/
#define cmocka_add_test_byname(tests, name, selected) \
_cmocka_add_test_byname(tests, sizeof(tests) / sizeof(tests[0]), name, \
selected, \
sizeof(selected) / sizeof(selected[0]))
static inline bool
_cmocka_add_test_byname(const struct CMUnitTest *tests, size_t ntests,
const char *name, struct CMUnitTest *selected,
size_t nselected) {
size_t i, j;
for (i = 0; i < ntests && tests[i].name != NULL; i++) {
if (strcmp(tests[i].name, name) != 0) {
continue;
}
for (j = 0; j < nselected && selected[j].name != NULL; j++) {
if (strcmp(tests[j].name, name) == 0) {
break;
}
}
if (j < nselected && selected[j].name == NULL) {
selected[j] = tests[i];
}
return (true);
}
return (false);
}
ISC_LANG_ENDDECLS
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1 -1
View File
@@ -12,11 +12,11 @@
*/
#include <assert.h>
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#define UNIT_TESTING
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+3 -1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
@@ -22,7 +23,8 @@
#define UNIT_TESTING
#include <isc/cmocka.h>
#include <cmocka.h>
#include <isc/commandline.h>
#include <isc/hex.h>
#include <isc/lex.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -13,6 +13,7 @@
#if HAVE_CMOCKA
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1 -1
View File
@@ -12,10 +12,10 @@
*/
#include <ctype.h>
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#define UNIT_TESTING
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -12,6 +12,7 @@
*/
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -13,6 +13,7 @@
/* ! \file */
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -12,6 +12,7 @@
*/
#include <errno.h>
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -12,6 +12,7 @@
*/
#include <fcntl.h>
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -13,6 +13,7 @@
/* ! \file */
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -13,6 +13,7 @@
/* ! \file */
#include <inttypes.h>
#include <math.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
+1
View File
@@ -13,6 +13,7 @@
/* ! \file */
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+2 -2
View File
@@ -65,7 +65,7 @@ test_ht_full(uint8_t init_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, (void *)f);
}
for (i = 1; i < count; i++) {
@@ -160,7 +160,7 @@ test_ht_full(uint8_t init_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, (void *)f);
}
for (i = 1; i < count; i++) {
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -12,6 +12,7 @@
*/
#include <fcntl.h>
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <signal.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -13,6 +13,7 @@
/* ! \file */
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <sched.h>
#include <setjmp.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -12,6 +12,7 @@
*/
#include <fcntl.h>
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <signal.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <signal.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <signal.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <signal.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <signal.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <signal.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1 -1
View File
@@ -11,11 +11,11 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
+1
View File
@@ -11,6 +11,7 @@
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <limits.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>