]> 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 09:38:45 +0000 (10:38 +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.

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
tests/isccfg/parser_test.c

index 59635d4fcc28f449ec0bf0790c498f23c612f439..57a0075e46bf9ae1882d65392356a489b6751776 100644 (file)
@@ -178,7 +178,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.stale, false);
                        assert_true(rdataset.ttl > 0);
                        dns_db_detachnode(&node);
@@ -211,7 +211,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.stale,
                                                 true);
@@ -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 09eb7c9d3732a59a324e866be649cb1c6f275c69..4efad9e525f073be89524dd7d15c08d09272830f 100644 (file)
@@ -54,7 +54,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 fdfa07b8cbd7ca4a179ba3d719ca3597a4a0fc90..945c19901f63af930017c111428e2f9957440344 100644 (file)
@@ -283,7 +283,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);
 }
 
@@ -353,7 +353,7 @@ ISC_RUN_TEST_IMPL(qpiter) {
                uint32_t prev = 0;
                dns_qpiter_init(qp, &qpi);
                while (dns_qpiter_next(&qpi, &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 12054d97679dfc7b80ff318edc35beb4255238ef..ef54b53a2cd86094bdd1c5ff3ded0df9a102c502 100644 (file)
@@ -163,7 +163,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();
@@ -180,7 +180,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();
index 3e77f7f1b56f5e17a9db9c1c8a7e0684a367e92a..bb4e0b99e97ca53d542454cb4217a1ce0215db25 100644 (file)
@@ -72,6 +72,16 @@ file_path_to_groupname(const char *path, char *out, size_t outlen);
 #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 547c094baf5f66987cdb67befeb215e307f5f8c1..df61df4ed57353f29de33230e0c7d0548111cce1 100644 (file)
@@ -214,9 +214,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 7cb7e06a8d3b71621214666799c9a6978805f84b..772448893504cb063e618a24de383a2839c502db 100644 (file)
@@ -474,7 +474,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);
index 90a5a3d94097a2837104e84170ab0a1679ebeb10..25d46ff7e7f5bdcb389e574909cc63d3033fa4f7 100644 (file)
@@ -149,7 +149,7 @@ ISC_RUN_TEST_IMPL(parse_buffer) {
 
        /* Check log values (and, specifically, line numbers). */
        logfilelen = ftell(logfile);
-       assert_in_range(logfilelen, 0, sizeof(logfilebuf));
+       assert_uint_in_range(logfilelen, 0, sizeof(logfilebuf));
 
        fresult = fseek(logfile, 0, SEEK_SET);
        assert_int_equal(fresult, 0);