new: test: Add build-time check for unregistered rdata files

Fail at meson configure if an rdata source file in lib/dns/rdata is not
registered in dns_header_depfiles, so edits no longer silently skip
header regeneration (as happened with brid, dsync, hhit, and wallet).

Assisted-by: Claude:claude-opus-4-8

Merge branch 'mnowak/check-rdata-registration' into 'main'

See merge request isc-projects/bind9!12219
This commit is contained in:
Michal Nowak 2026-06-30 19:20:11 +02:00
commit 219f23cb80
2 changed files with 57 additions and 0 deletions

View file

@ -689,6 +689,9 @@ misc:
- sh util/check-gitignore.sh
- sh util/check-trailing-whitespace.sh
- bash util/unused-headers.sh
# Check that every rdata source file is registered for header generation
- meson setup build
- bash util/check-rdata-registration.sh build
# Check dangling symlinks in the repository
- if find . -xtype l | grep .; then exit 1; fi
- muon-meson analyze -Werror

View file

@ -0,0 +1,54 @@
#!/bin/bash
# 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.
# Fail if an rdata source file under lib/dns/rdata is not registered as an
# input of the generated lib/dns/code.h header, i.e. missing from
# dns_header_depfiles in the relevant meson.build. An unregistered file is
# still compiled into BIND 9 (gen.c scans the directories directly), but
# editing it does not trigger regeneration of code.h.
#
# Usage: check-rdata-registration.sh [BUILDDIR] (BUILDDIR defaults to "build")
set -euo pipefail
builddir=${1:-build}
registered=$(mktemp)
ondisk=$(mktemp)
trap 'rm -f "$registered" "$ondisk"' EXIT
# Registered files: the inputs lib/dns/code.h is generated from, reduced to
# repo-relative lib/dns/rdata/<class>/<file> paths.
ninja -C "$builddir" -t inputs lib/dns/code.h \
| sed -n 's@^.*\(lib/dns/rdata/[^/]*/[^/]*\)$@\1@p' \
| sort -u >"$registered"
# rdata-type source files on disk (e.g. soa_6.c, nsap-ptr_23.h). Skeleton
# files such as proforma.c are not type-named and are skipped, mirroring
# gen.c's filename filter.
printf '%s\n' lib/dns/rdata/*/*.c lib/dns/rdata/*/*.h \
| grep -E '/[-0-9a-z]+_[0-9]+\.[ch]$' \
| sort -u >"$ondisk"
unregistered=$(comm -23 "$ondisk" "$registered")
if [ -n "$unregistered" ]; then
echo "$unregistered" | while read -r file; do
echo "Rdata file $file is not registered for header" \
"generation (add it to dns_header_depfiles in the" \
"meson.build)" >&2
done
exit 1
fi
exit 0