]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check for unregistered rdata files in CI 12219/head
authorMichal Nowak <mnowak@isc.org>
Tue, 9 Jun 2026 16:11:51 +0000 (16:11 +0000)
committerMichal Nowak <mnowak@isc.org>
Tue, 30 Jun 2026 17:19:37 +0000 (19:19 +0200)
Verify in the misc CI job that every rdata source file under
lib/dns/rdata is an input of the generated lib/dns/code.h, i.e.
registered in dns_header_depfiles.  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.

Assisted-by: Claude:claude-opus-4-8
.gitlab-ci.yml
util/check-rdata-registration.sh [new file with mode: 0755]

index a4ad6a697e04228d1553884daa1580b60e01bad7..ce1094b9d8e090eb86cc7e519096166166bcc042 100644 (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
diff --git a/util/check-rdata-registration.sh b/util/check-rdata-registration.sh
new file mode 100755 (executable)
index 0000000..2048e26
--- /dev/null
@@ -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