From 45abc5d01f1d7c56ad920d27403c3b4ba7ebc7e7 Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Mon, 25 May 2026 08:17:02 +0000 Subject: [PATCH 1/2] Register orphaned diff and skr unit tests in meson build Both test files existed on disk but were never added to the meson test list when the build system switched from autoconf. skr_test.c also had a spurious #include for a header that never existed in this repo -- no symbols from it were used. Removing the include is the only fix needed; the test itself is correct and passes. Assisted-by: Claude:claude-opus-4-7 --- tests/dns/meson.build | 2 ++ tests/dns/skr_test.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/dns/meson.build b/tests/dns/meson.build index a13482f9d9..3808c559bc 100644 --- a/tests/dns/meson.build +++ b/tests/dns/meson.build @@ -18,6 +18,7 @@ dns_tests = [ 'dbiterator', 'dbversion', 'deleg', + 'diff', 'dispatch', 'dns64', 'dst', @@ -40,6 +41,7 @@ dns_tests = [ 'resolver', 'rsa', 'sigs', + 'skr', 'time', 'transport', 'tsig', diff --git a/tests/dns/skr_test.c b/tests/dns/skr_test.c index 55b533dc52..8f29f304f3 100644 --- a/tests/dns/skr_test.c +++ b/tests/dns/skr_test.c @@ -40,7 +40,6 @@ #include #include #include -#include #include "zone_p.h" From 9597012c1739aea300a68fd938f000620da658f7 Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Sun, 24 May 2026 18:12:53 +0000 Subject: [PATCH 2/2] Add build-time check for unregistered unit test files Fail at meson configure time if a *_test.c file exists in a test directory but is not listed in the corresponding test array. This prevents test files from being silently orphaned when added without updating meson.build, as happened with diff_test.c and skr_test.c. Assisted-by: Claude:claude-opus-4-7 --- .gitattributes | 1 + tests/dns/meson.build | 8 ++++++++ tests/isc/meson.build | 8 ++++++++ tests/isccfg/meson.build | 11 ++++++++++- tests/meson.build | 2 ++ tests/ns/meson.build | 6 +++++- util/check_test_registration.py | 28 ++++++++++++++++++++++++++++ 7 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 util/check_test_registration.py diff --git a/.gitattributes b/.gitattributes index e2a0641fbf..79c472aba8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -32,4 +32,5 @@ dangerfile.py export-ignore /util/dtrace.sh -export-ignore /util/meson.build -export-ignore /util/meson-system-test-init.sh -export-ignore +/util/check_test_registration.py -export-ignore /util/meson-dist-package.sh -export-ignore diff --git a/tests/dns/meson.build b/tests/dns/meson.build index 3808c559bc..36294a0629 100644 --- a/tests/dns/meson.build +++ b/tests/dns/meson.build @@ -53,6 +53,14 @@ dns_tests = [ 'zt', ] +_all_dns_tests = dns_tests + ['geoip', 'dnstap'] +run_command( + check_test_registration, + meson.current_source_dir(), + _all_dns_tests, + check: true, +) + if config.has('HAVE_GEOIP2') dns_tests += 'geoip' endif diff --git a/tests/isc/meson.build b/tests/isc/meson.build index 81955d759d..7790181941 100644 --- a/tests/isc/meson.build +++ b/tests/isc/meson.build @@ -62,6 +62,14 @@ flaky_isc_test = [ is_el8 = run_command('grep', '-q', '-F', 'platform:el8', '/etc/os-release', check: false).returncode() == 0 +_all_isc_test = isc_test + ['doh'] +run_command( + check_test_registration, + meson.current_source_dir(), + _all_isc_test, + check: true, +) + if config.has('HAVE_LIBNGHTTP2') and not is_el8 isc_test += 'doh' endif diff --git a/tests/isccfg/meson.build b/tests/isccfg/meson.build index 0055f42f43..66adda5ccd 100644 --- a/tests/isccfg/meson.build +++ b/tests/isccfg/meson.build @@ -9,11 +9,20 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -foreach unit : [ +isccfg_tests = [ 'duration', 'grammar', 'parser', ] + +run_command( + check_test_registration, + meson.current_source_dir(), + isccfg_tests, + check: true, +) + +foreach unit : isccfg_tests test_bin = executable( unit, files(f'@unit@_test.c'), diff --git a/tests/meson.build b/tests/meson.build index e62cf01de3..7b7cb9f9c8 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -52,6 +52,8 @@ if not cmocka_dep.found() subdir_done() endif +check_test_registration = [python, files('../util/check_test_registration.py')] + subdir('bench') subdir('dns') subdir('isc') diff --git a/tests/ns/meson.build b/tests/ns/meson.build index 75c5260223..452c7ea05f 100644 --- a/tests/ns/meson.build +++ b/tests/ns/meson.build @@ -9,11 +9,15 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -foreach unit : [ +ns_tests = [ 'notify', 'plugin', 'query', ] + +run_command(check_test_registration, meson.current_source_dir(), ns_tests, check: true) + +foreach unit : ns_tests test_bin = executable( unit, files(f'@unit@_test.c', 'netmgr_wrap.c'), diff --git a/util/check_test_registration.py b/util/check_test_registration.py new file mode 100644 index 0000000000..1bde17ef77 --- /dev/null +++ b/util/check_test_registration.py @@ -0,0 +1,28 @@ +# 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. + + +import glob +import os +import sys + +test_dir = sys.argv[1] +registered = sys.argv[2:] + +for path in sorted(glob.glob(os.path.join(test_dir, "*_test.c"))): + name = os.path.basename(path).removesuffix("_test.c") + if name not in registered: + print( + f"Unit test file {os.path.basename(path)} is not registered" + f" (add '{name}' to the list)", + file=sys.stderr, + ) + sys.exit(1)