From: Nicki Křížek Date: Fri, 5 Dec 2025 14:12:29 +0000 (+0100) Subject: Use jinja2 templates in runtime test X-Git-Tag: v9.21.17~46^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f3b0afb09410f7473fa65491d50d6da58ca82bd;p=thirdparty%2Fbind9.git Use jinja2 templates in runtime test - Replace named-altX.conf.in with namedX.conf.j2 to stick with the same naming convention across the entire code base. Note than due to named1.conf being the first (default) config, the numbers for the altX are incremented. - Turn alt9 into named7 to stick with the same number sequence. Adjust the related file names accordingly. --- diff --git a/bin/tests/system/runtime/ns2/named.conf.j2 b/bin/tests/system/runtime/ns2/named.conf.j2 new file mode 120000 index 00000000000..96e5f1dcd12 --- /dev/null +++ b/bin/tests/system/runtime/ns2/named.conf.j2 @@ -0,0 +1 @@ +named1.conf.j2 \ No newline at end of file diff --git a/bin/tests/system/runtime/ns2/named1.conf.in b/bin/tests/system/runtime/ns2/named1.conf.j2 similarity index 100% rename from bin/tests/system/runtime/ns2/named1.conf.in rename to bin/tests/system/runtime/ns2/named1.conf.j2 diff --git a/bin/tests/system/runtime/ns2/named-alt1.conf.in b/bin/tests/system/runtime/ns2/named2.conf.j2 similarity index 100% rename from bin/tests/system/runtime/ns2/named-alt1.conf.in rename to bin/tests/system/runtime/ns2/named2.conf.j2 diff --git a/bin/tests/system/runtime/ns2/named-alt2.conf.in b/bin/tests/system/runtime/ns2/named3.conf.j2 similarity index 100% rename from bin/tests/system/runtime/ns2/named-alt2.conf.in rename to bin/tests/system/runtime/ns2/named3.conf.j2 diff --git a/bin/tests/system/runtime/ns2/named-alt3.conf.in b/bin/tests/system/runtime/ns2/named4.conf.j2 similarity index 100% rename from bin/tests/system/runtime/ns2/named-alt3.conf.in rename to bin/tests/system/runtime/ns2/named4.conf.j2 diff --git a/bin/tests/system/runtime/ns2/named-alt4.conf.in b/bin/tests/system/runtime/ns2/named5.conf.j2 similarity index 100% rename from bin/tests/system/runtime/ns2/named-alt4.conf.in rename to bin/tests/system/runtime/ns2/named5.conf.j2 diff --git a/bin/tests/system/runtime/ns2/named-alt5.conf.in b/bin/tests/system/runtime/ns2/named6.conf.j2 similarity index 100% rename from bin/tests/system/runtime/ns2/named-alt5.conf.in rename to bin/tests/system/runtime/ns2/named6.conf.j2 diff --git a/bin/tests/system/runtime/ns2/named-alt9.conf.in b/bin/tests/system/runtime/ns2/named7.conf.j2 similarity index 95% rename from bin/tests/system/runtime/ns2/named-alt9.conf.in rename to bin/tests/system/runtime/ns2/named7.conf.j2 index f0ebcd34627..b90d680b767 100644 --- a/bin/tests/system/runtime/ns2/named-alt9.conf.in +++ b/bin/tests/system/runtime/ns2/named7.conf.j2 @@ -13,7 +13,7 @@ options { port @PORT@; - pid-file "named9.pid"; + pid-file "named7.pid"; listen-on { 10.53.0.2; }; listen-on-v6 { none; }; recursion no; diff --git a/bin/tests/system/runtime/setup.sh b/bin/tests/system/runtime/setup.sh index a0fc0d08b5a..6237472b1de 100644 --- a/bin/tests/system/runtime/setup.sh +++ b/bin/tests/system/runtime/setup.sh @@ -13,13 +13,5 @@ . ../conf.sh -copy_setports ns2/named1.conf.in ns2/named.conf - -copy_setports ns2/named-alt1.conf.in ns2/named-alt1.conf -copy_setports ns2/named-alt2.conf.in ns2/named-alt2.conf -copy_setports ns2/named-alt3.conf.in ns2/named-alt3.conf -copy_setports ns2/named-alt4.conf.in ns2/named-alt4.conf -copy_setports ns2/named-alt5.conf.in ns2/named-alt5.conf - mkdir ns2/nope chmod 555 ns2/nope diff --git a/bin/tests/system/runtime/tests.sh b/bin/tests/system/runtime/tests.sh index 29438e24d3a..06b56830d9b 100644 --- a/bin/tests/system/runtime/tests.sh +++ b/bin/tests/system/runtime/tests.sh @@ -80,7 +80,7 @@ status=$((status + ret)) n=$((n + 1)) echo_i "checking that named refuses to reconfigure if working directory is not writable ($n)" ret=0 -copy_setports ns2/named-alt1.conf.in ns2/named.conf +cp ns2/named2.conf ns2/named.conf $RNDCCMD 10.53.0.2 reconfig >rndc.out.$n 2>&1 && ret=1 grep "failed: permission denied" rndc.out.$n >/dev/null 2>&1 || ret=1 sleep 1 @@ -91,7 +91,7 @@ status=$((status + ret)) n=$((n + 1)) echo_i "checking that named refuses to reconfigure if managed-keys-directory is not writable ($n)" ret=0 -copy_setports ns2/named-alt2.conf.in ns2/named.conf +cp ns2/named3.conf ns2/named.conf $RNDCCMD 10.53.0.2 reconfig >rndc.out.$n 2>&1 && ret=1 grep "failed: permission denied" rndc.out.$n >/dev/null 2>&1 || ret=1 sleep 1 @@ -102,7 +102,7 @@ status=$((status + ret)) n=$((n + 1)) echo_i "checking that named refuses to reconfigure if new-zones-directory is not writable ($n)" ret=0 -copy_setports ns2/named-alt3.conf.in ns2/named.conf +cp ns2/named4.conf ns2/named.conf $RNDCCMD 10.53.0.2 reconfig >rndc.out.$n 2>&1 && ret=1 grep "failed: permission denied" rndc.out.$n >/dev/null 2>&1 || ret=1 sleep 1 @@ -113,7 +113,7 @@ status=$((status + ret)) n=$((n + 1)) echo_i "checking that named recovers when configuration file is valid again ($n)" ret=0 -copy_setports ns2/named1.conf.in ns2/named.conf +cp ns2/named1.conf ns2/named.conf $RNDCCMD 10.53.0.2 reconfig >rndc.out.$n 2>&1 || ret=1 [ -s ns2/named.pid ] || ret=1 kill_named ns2/named.pid || ret=1 @@ -123,7 +123,7 @@ status=$((status + ret)) n=$((n + 1)) echo_i "checking that named refuses to start if working directory is not writable ($n)" ret=0 -testpid=$(run_named ns2 named$n.run -c named-alt1.conf -D runtime-ns2-extra-4) +testpid=$(run_named ns2 named$n.run -c named2.conf -D runtime-ns2-extra-4) test -n "$testpid" || ret=1 retry_quiet 10 check_named_log "exiting (due to fatal error)" ns2/named$n.run || ret=1 grep "[^-]directory './nope' is not writable" ns2/named$n.run >/dev/null 2>&1 || ret=1 @@ -135,7 +135,7 @@ status=$((status + ret)) n=$((n + 1)) echo_i "checking that named refuses to start if managed-keys-directory is not writable ($n)" ret=0 -testpid=$(run_named ns2 named$n.run -c named-alt2.conf -D runtime-ns2-extra-5) +testpid=$(run_named ns2 named$n.run -c named3.conf -D runtime-ns2-extra-5) test -n "$testpid" || ret=1 retry_quiet 10 check_named_log "exiting (due to fatal error)" ns2/named$n.run || ret=1 grep "managed-keys-directory './nope' is not writable" ns2/named$n.run >/dev/null 2>&1 || ret=1 @@ -147,7 +147,7 @@ status=$((status + ret)) n=$((n + 1)) echo_i "checking that named refuses to start if new-zones-directory is not writable ($n)" ret=0 -testpid=$(run_named ns2 named$n.run -c named-alt3.conf -D runtime-ns2-extra-6) +testpid=$(run_named ns2 named$n.run -c named4.conf -D runtime-ns2-extra-6) test -n "$testpid" || ret=1 retry_quiet 10 check_named_log "exiting (due to fatal error)" ns2/named$n.run || ret=1 grep "new-zones-directory './nope' is not writable" ns2/named$n.run >/dev/null 2>&1 || ret=1 @@ -160,7 +160,7 @@ n=$((n + 1)) echo_i "checking that named logs control characters in octal notation ($n)" ret=0 INSTANCE_NAME="runtime-ns2-extra-7-$(cat ctrl-chars)" -testpid=$(run_named ns2 named$n.run -c named-alt4.conf -D "${INSTANCE_NAME}") +testpid=$(run_named ns2 named$n.run -c named5.conf -D "${INSTANCE_NAME}") test -n "$testpid" || ret=1 retry_quiet 60 check_named_log "running$" ns2/named$n.run || ret=1 grep 'running as.*\\177\\033' ns2/named$n.run >/dev/null || ret=1 @@ -173,7 +173,7 @@ n=$((n + 1)) echo_i "checking that named escapes special characters in the logs ($n)" ret=0 INSTANCE_NAME="runtime-ns2-extra-8-$;" -testpid=$(run_named ns2 named$n.run -c named-alt4.conf -D "${INSTANCE_NAME}") +testpid=$(run_named ns2 named$n.run -c named5.conf -D "${INSTANCE_NAME}") test -n "$testpid" || ret=1 retry_quiet 60 check_named_log "running$" ns2/named$n.run || ret=1 grep 'running as.*\\$\\;' ns2/named$n.run >/dev/null || ret=1 @@ -187,7 +187,7 @@ echo_i "checking that named logs an ellipsis when the command line is larger tha ret=0 LONG_CMD_LINE=$(cat long-cmd-line) # shellcheck disable=SC2086 -testpid=$(run_named ns2 named$n.run $LONG_CMD_LINE -c "named-alt4.conf") +testpid=$(run_named ns2 named$n.run $LONG_CMD_LINE -c "named5.conf") test -n "$testpid" || ret=1 retry_quiet 60 check_named_log "running$" ns2/named$n.run || ret=1 grep "running as.*\.\.\.$" ns2/named$n.run >/dev/null || ret=1 @@ -200,7 +200,7 @@ n=$((n + 1)) echo_i "checking that named log missing IPv4 primaries in -4 mode ($n)" ret=0 INSTANCE_NAME="missing-primaries-ipv4-only-mode" -testpid=$(run_named ns2 named$n.run -c named-alt5.conf -D "${INSTANCE_NAME}" -4) +testpid=$(run_named ns2 named$n.run -c named6.conf -D "${INSTANCE_NAME}" -4) test -n "$testpid" || ret=1 retry_quiet 60 check_named_log "running$" ns2/named$n.run || ret=1 grep "IPv6 disabled and no IPv4 primaries" ns2/named$n.run >/dev/null || ret=1 @@ -213,7 +213,7 @@ n=$((n + 1)) echo_i "checking that named log missing IPv6 primaries in -6 mode ($n)" ret=0 INSTANCE_NAME="missing-primaries-ipv4-only-mode" -testpid=$(run_named ns2 named$n.run -c named-alt5.conf -D "${INSTANCE_NAME}" -6) +testpid=$(run_named ns2 named$n.run -c named6.conf -D "${INSTANCE_NAME}" -6) test -n "$testpid" || ret=1 retry_quiet 60 check_named_log "running$" ns2/named$n.run || ret=1 grep "IPv4 disabled and no IPv6 primaries" ns2/named$n.run >/dev/null || ret=1 @@ -231,15 +231,15 @@ if [ "$(id -u)" -eq 0 ]; then rc=$? } || true if [ "$rc" -eq 0 ]; then - copy_setports ns2/named-alt9.conf.in "${TEMP_NAMED_DIR}/named-alt9.conf" + cp ns2/named7.conf "${TEMP_NAMED_DIR}/named7.conf" chown -R nobody: "${TEMP_NAMED_DIR}" chmod 0700 "${TEMP_NAMED_DIR}" - testpid=$(run_named "${TEMP_NAMED_DIR}" "${TEMP_NAMED_DIR}/named$n.run" -u nobody -c named-alt9.conf) + testpid=$(run_named "${TEMP_NAMED_DIR}" "${TEMP_NAMED_DIR}/named$n.run" -u nobody -c named7.conf) test -n "$testpid" || ret=1 retry_quiet 60 check_named_log "running$" "${TEMP_NAMED_DIR}/named$n.run" || ret=1 - [ -s "${TEMP_NAMED_DIR}/named9.pid" ] || ret=1 + [ -s "${TEMP_NAMED_DIR}/named7.pid" ] || ret=1 grep "loading configuration: permission denied" "${TEMP_NAMED_DIR}/named$n.run" >/dev/null && ret=1 - kill_named "${TEMP_NAMED_DIR}/named9.pid" || ret=1 + kill_named "${TEMP_NAMED_DIR}/named7.pid" || ret=1 test -n "$testpid" || ret=1 test -n "$testpid" && retry_quiet 10 check_pid $testpid || ret=1 else