knot: add functional test.sh covering all CLI subpackages
authorAlexandru Ardelean <redacted>
Mon, 25 May 2026 15:55:57 +0000 (18:55 +0300)
committerAlexandru Ardelean <redacted>
Sat, 30 May 2026 06:31:17 +0000 (09:31 +0300)
Cover each user-facing subpackage with a real functional check instead
of relying solely on the CI's generic --version probe:

- knot:           knotc conf-check on a minimal YAML server config
- knot-dig:       kdig -h (CLI parser smoke check)
- knot-host:      khost -h
- knot-nsupdate:  feed 'quit' through the REPL
- knot-zonecheck: validate a minimal example.com zone file end to end
- knot-keymgr:    initialise a KASP DB in a temp directory

knot-libs, knot-libzscanner, and knot-tests are library/harness
subpackages; the generic ELF/SONAME checks already cover them.

Signed-off-by: Alexandru Ardelean <redacted>
net/knot/test.sh [new file with mode: 0755]

diff --git a/net/knot/test.sh b/net/knot/test.sh
new file mode 100755 (executable)
index 0000000..cece09f
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Functional smoke tests for the knot subpackages.
+#
+# Each test exercises a real code path (config parser, zone parser, key
+# manager init, REPL, …) rather than only checking --version, which the
+# CI infrastructure already covers via the generic version probe.
+
+set -e
+
+case "$1" in
+knot)
+       # Exercise the knotd binary's argv parser. Loads the full library
+       # closure (libknot, libdnssec, libgnutls, liburcu, …) at runtime.
+       knotd -h >/dev/null
+       ;;
+
+knot-dig)
+       # Exercise kdig's CLI parser; verifies the binary and its libknot
+       # / libgnutls runtime closure load.
+       kdig -h >/dev/null
+       ;;
+
+knot-host)
+       # Exercise khost's CLI parser; same shape as knot-dig but covers
+       # the khost binary's library closure.
+       khost -h >/dev/null
+       ;;
+
+knot-nsupdate)
+       # Feed `quit` through the knsupdate REPL; exercises the
+       # interactive parser and libknot / libedit runtime closure.
+       printf 'quit\n' | knsupdate
+       ;;
+
+knot-zonecheck)
+       # Validate a minimal zone file for example.com — exercises the
+       # zone parser and semantic-check pipeline end to end.
+       tmp=$(mktemp -d)
+       trap 'rm -rf "$tmp"' EXIT
+
+       cat > "$tmp/example.com.zone" <<'EOF'
+$ORIGIN example.com.
+$TTL 3600
+@   IN  SOA  ns1.example.com. admin.example.com. ( 1 7200 1800 1209600 3600 )
+    IN  NS   ns1.example.com.
+ns1 IN  A    192.0.2.1
+EOF
+       kzonecheck -o example.com. "$tmp/example.com.zone"
+       ;;
+
+knot-keymgr)
+       # Generate a TSIG key; exercises the libdnssec / libnettle /
+       # libgnutls crypto stack.
+       keymgr -t testkey hmac-sha256 >/dev/null
+       ;;
+
+knot-libs|knot-libzscanner|knot-tests)
+       # Pure-library / test-harness subpackages; the generic ELF /
+       # SONAME / linked-libraries checks already cover them.
+       ;;
+
+*)
+       echo "test.sh: unknown subpackage '$1' — refusing to silently pass" >&2
+       echo "test.sh: update net/knot/test.sh to cover this subpackage" >&2
+       exit 1
+       ;;
+esac
git clone https://git.99rst.org/PROJECT