summaryrefslogtreecommitdiffstats
path: root/net/knot/test.sh
blob: cece09fad1c51c0e60929c7acb3f460a0de77f55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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