Commit 060dda8a5d for bind

commit 060dda8a5d2fa8db3ef3c7361db429cf854d4c61
Author: Aram Sargsyan <aram@isc.org>
Date:   Thu Oct 15 16:54:49 2026 +0000

    Add a unit test for isccc_cc_checkdup()

diff --git a/tests/isccc/checkdup_test.c b/tests/isccc/checkdup_test.c
new file mode 100644
index 0000000000..6cb3529473
--- /dev/null
+++ b/tests/isccc/checkdup_test.c
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+#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>
+#include <unistd.h>
+
+#define UNIT_TESTING
+#include <cmocka.h>
+
+#include <isc/buffer.h>
+#include <isc/lib.h>
+#include <isc/log.h>
+#include <isc/mem.h>
+#include <isc/symtab.h>
+#include <isc/types.h>
+#include <isc/util.h>
+
+#include <isccc/alist.h>
+#include <isccc/cc.h>
+#include <isccc/sexpr.h>
+
+#include <tests/isc.h>
+
+ISC_SETUP_TEST_IMPL(group) {
+	isc_logconfig_t *logconfig = isc_logconfig_get();
+	isc_log_createandusechannel(
+		logconfig, "default_stderr", ISC_LOG_TOFILEDESC,
+		ISC_LOG_DYNAMIC, ISC_LOGDESTINATION_STDERR, 0,
+		ISC_LOGCATEGORY_DEFAULT, ISC_LOGMODULE_DEFAULT);
+
+	return 0;
+}
+
+/* test isccc_cc_checkdup() */
+ISC_RUN_TEST_IMPL(checkdup) {
+	isc_symtab_t *symtab = NULL;
+	const isc_stdtime_t start = isc_stdtime_now();
+	const uint32_t lifetime = 5;
+	const uint32_t serial = 0xdeadcafe;
+	bool first = true;
+
+	isccc_cc_createsymtab(isc_g_mctx, &symtab);
+
+	while (true) {
+		isc_stdtime_t now = isc_stdtime_now();
+		isccc_sexpr_t *request = isccc_alist_create();
+		isc_result_t result;
+
+		assert_non_null(request);
+
+		isccc_sexpr_t *_ctrl = isccc_alist_create();
+		assert_non_null(_ctrl);
+		assert_non_null(isccc_alist_define(request, "_ctrl", _ctrl));
+		assert_non_null(isccc_cc_defineuint32(_ctrl, "_ser", serial));
+		assert_non_null(isccc_cc_defineuint32(_ctrl, "_tim", start));
+
+		isccc_cc_cleansymtab(symtab, now);
+		result = isccc_cc_checkdup(symtab, request, now + lifetime);
+
+		isccc_sexpr_free(&request);
+
+		if (first) {
+			first = false;
+			/* First one should go in successfully. */
+			assert_true(result == ISC_R_SUCCESS);
+		} else if (now - start < lifetime) {
+			/*
+			 * Until the lifetime of the inserted entry has passed,
+			 * it should live and no new entry should enter.
+			 */
+			assert_true(result == ISC_R_EXISTS);
+		} else {
+			/*
+			 * When lifetime has passed, the isccc_cc_cleansymtab()
+			 * call above should have cleaned up the entry, so the
+			 * new one should enter successfully again, and the test
+			 * is over.
+			 */
+			assert_true(result == ISC_R_SUCCESS);
+			break;
+		}
+
+		uv_sleep(10);
+	}
+
+	isc_symtab_destroy(&symtab);
+}
+
+ISC_TEST_LIST_START
+
+ISC_TEST_ENTRY(checkdup)
+
+ISC_TEST_LIST_END
+
+ISC_TEST_MAIN_CUSTOM(setup_test_group, NULL)
diff --git a/tests/isccc/meson.build b/tests/isccc/meson.build
new file mode 100644
index 0000000000..1f823c54fc
--- /dev/null
+++ b/tests/isccc/meson.build
@@ -0,0 +1,49 @@
+# 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.
+
+isccc_tests = [
+    'checkdup',
+]
+
+run_command(
+    check_test_registration,
+    meson.current_source_dir(),
+    isccc_tests,
+    check: true,
+)
+
+foreach unit : isccc_tests
+    test_bin = executable(
+        unit,
+        files(f'@unit@_test.c'),
+        build_by_default: false,
+        export_dynamic: true,
+        install: false,
+        sources: default_sanitize_options,
+        dependencies: [
+            libdns_dep,
+            libisc_dep,
+            libisccc_dep,
+            libtest_dep,
+
+            cmocka_dep,
+        ],
+    )
+
+    test(
+        unit,
+        test_bin,
+        env: test_env,
+        suite: ['isccc', 'cmocka'],
+        timeout: 300,
+        workdir: meson.current_source_dir(),
+    )
+endforeach
diff --git a/tests/meson.build b/tests/meson.build
index 01321b3188..8840929d82 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -29,6 +29,7 @@ libtest = shared_library(
     dependencies: [
         libdns_dep,
         libisc_dep,
+        libisccc_dep,
         libisccfg_dep,
         libns_dep,
     ],
@@ -59,5 +60,6 @@ check_test_registration = [python, files('../util/check_test_registration.py')]
 subdir('bench')
 subdir('dns')
 subdir('isc')
+subdir('isccc')
 subdir('isccfg')
 subdir('ns')