]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Support compilation with cmocka 2.0.0+
authorNicki Křížek <nicki@isc.org>
Mon, 29 Dec 2025 12:37:34 +0000 (13:37 +0100)
committerNicki Křížek <nicki@isc.org>
Wed, 7 Jan 2026 10:17:42 +0000 (11:17 +0100)
The `assert_in_range()` function was deprecated in favor of
`assert_int_in_range()` and `assert_uint_in_range()`. Add compatibility
shims for cmocka<2.0.0 and use the new functions.

(cherry picked from commit 6843a4bd9afa0b06daac27091049427fcd5c601c)

tests/dns/db_test.c
tests/dns/ede_test.c
tests/dns/qp_test.c
tests/dns/resolver_test.c
tests/include/tests/isc.h
tests/isc/histo_test.c
tests/isc/mem_test.c

index 1ed7b381b1bfca653ec94b1ce26a0ce905323779..edd2b5eb83130085bb369dda184f6c9124ee59a3 100644 (file)
@@ -175,7 +175,7 @@ ISC_LOOP_TEST_IMPL(dns_dbfind_staleok) {
                count = 0;
                do {
                        count++;
-                       assert_in_range(count, 1, 21); /* loop sanity */
+                       assert_int_in_range(count, 1, 21); /* loop sanity */
                        assert_int_equal(rdataset.attributes &
                                                 DNS_RDATASETATTR_STALE,
                                         0);
@@ -210,7 +210,8 @@ ISC_LOOP_TEST_IMPL(dns_dbfind_staleok) {
                        count = 0;
                        do {
                                count++;
-                               assert_in_range(count, 0, 49); /* loop sanity */
+                               assert_int_in_range(count, 0, 49); /* loop
+                                                                     sanity */
                                assert_int_equal(result, ISC_R_SUCCESS);
                                assert_int_equal(rdataset.attributes &
                                                         DNS_RDATASETATTR_STALE,
@@ -229,7 +230,7 @@ ISC_LOOP_TEST_IMPL(dns_dbfind_staleok) {
                         * usleep(100000) can be slightly less than 10ms so
                         * allow the count to reach 11.
                         */
-                       assert_in_range(count, 1, 11);
+                       assert_int_in_range(count, 1, 11);
                        assert_int_equal(result, ISC_R_NOTFOUND);
                        break;
                case 2:
index 76761cfb8fb5ca6923934e847b695833f52465c3..b150da938d4eb29cf10343ebed236e30167de61d 100644 (file)
@@ -52,7 +52,7 @@ dns_ede_test_equals(const ede_test_expected_t *expected, size_t expected_count,
                uint16_t code;
                const unsigned char *txt;
 
-               assert_in_range(count, 0, expected_count);
+               assert_uint_in_range(count, 0, expected_count);
                assert_int_equal(edns->code, DNS_OPT_EDE);
 
                code = ISC_U8TO16_BE(edns->value);
index f8c0954beef2a0c55494f2bc8e79bcf789f1b9b0..16d474262c9455de008f61760c21335999acbfb6 100644 (file)
@@ -178,7 +178,7 @@ ISC_RUN_TEST_IMPL(qpkey_sort) {
 static void
 check_leaf(void *uctx, void *pval, uint32_t ival) {
        uint32_t *items = uctx;
-       assert_in_range(ival, 1, ITER_ITEMS - 1);
+       assert_uint_in_range(ival, 1, ITER_ITEMS - 1);
        assert_ptr_equal(items + ival, pval);
 }
 
@@ -250,7 +250,7 @@ ISC_RUN_TEST_IMPL(qpiter) {
                while (dns_qpiter_next(&qpi, NULL, &pval, &ival) ==
                       ISC_R_SUCCESS)
                {
-                       assert_in_range(ival, prev + 1, ITER_ITEMS - 1);
+                       assert_uint_in_range(ival, prev + 1, ITER_ITEMS - 1);
                        assert_int_equal(ival, item[ival]);
                        assert_ptr_equal(pval, &item[ival]);
                        order[inserted++] = ival;
index 200c20e1c197110c182267ee3fd8ee2e61ab8bc5..7524e0a36427b5f5ada6d047df882a0fb84a3661 100644 (file)
@@ -161,7 +161,7 @@ ISC_LOOP_TEST_IMPL(settimeout_belowmin) {
        dns_resolver_settimeout(resolver, 300);
 
        timeout = dns_resolver_gettimeout(resolver);
-       assert_in_range(timeout, default_timeout, 3999999);
+       assert_uint_in_range(timeout, default_timeout, 3999999);
 
        destroy_resolver(&resolver);
        isc_loopmgr_shutdown(loopmgr);
@@ -178,7 +178,7 @@ ISC_LOOP_TEST_IMPL(settimeout_overmax) {
        dns_resolver_settimeout(resolver, 4000000);
 
        timeout = dns_resolver_gettimeout(resolver);
-       assert_in_range(timeout, default_timeout, 3999999);
+       assert_uint_in_range(timeout, default_timeout, 3999999);
 
        destroy_resolver(&resolver);
        isc_loopmgr_shutdown(loopmgr);
index 338cdf8fa339679a861a4b06b3544deebf48a28c..db80233070d84f2d66ed20796c95a4519d37ee6c 100644 (file)
@@ -66,6 +66,16 @@ teardown_managers(void **state);
 #define TESTS_DIR "./"
 #endif
 
+/* cmocka<2.0.0 compatibility */
+#ifndef assert_int_in_range
+#define assert_int_in_range(value, min, max) \
+       assert_in_range((value), (min), (max))
+#endif
+#ifndef assert_uint_in_range
+#define assert_uint_in_range(value, min, max) \
+       assert_in_range((value), (min), (max))
+#endif
+
 /* clang-format off */
 /* Copied from cmocka */
 #define ISC_TEST_ENTRY(name)                           \
index 88c322f1601e85407e7a70a2dcd1fb9e039c256a..f8177b11d709aad0aae45b1c52aa93039d09047b 100644 (file)
@@ -213,9 +213,9 @@ ISC_RUN_TEST_IMPL(quantiles) {
                        uint i = (quantum + base - key) * 2;
 
                        /* check fenceposts */
-                       assert_in_range(value[i - 0], lomin, himin);
-                       assert_in_range(value[i - 1], lomid, himid);
-                       assert_in_range(value[i - 2], lomax, himax);
+                       assert_uint_in_range(value[i - 0], lomin, himin);
+                       assert_uint_in_range(value[i - 1], lomid, himid);
+                       assert_uint_in_range(value[i - 2], lomax, himax);
 
                        /* these tests can be slow */
                        if (isc_time_monotonic() > start + TIME_LIMIT) {
index 8775407bd5a72bdfd40e9937aa1622a9983569b2..7754488fb091393ae8957c39b1fc55fe07ab15ab 100644 (file)
@@ -470,7 +470,7 @@ ISC_RUN_TEST_IMPL(isc_mem_traceflag) {
        assert_non_null(p);
        p = strchr(p + 1, '\n');
        assert_non_null(p);
-       assert_in_range(p, 0, buf + sizeof(buf) - 3);
+       assert_uint_in_range(p, 0, buf + sizeof(buf) - 3);
        assert_memory_equal(p + 2, "ptr ", 4);
        p = strchr(p + 1, '\n');
        assert_non_null(p);