return 0
}
+wait_for_named() {
+ retries=10
+ while [ "$retries" -gt 0 ]; do
+ if grep "$@" >/dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+ retries=$((retries-1))
+ done
+ if [ "$retries" -eq 0 ]; then
+ return 1
+ fi
+ return 0
+}
+
status=0
n=0
n=$((n+1))
echo_i "verifying that named checks for conflicting named processes ($n)"
ret=0
-(cd ns2 && $NAMED -c named-alt2.conf -D runtime-ns2-extra-2 -X named.lock -m record,size,mctx -d 99 -g -U 4 >> named3.run 2>&1 & )
-sleep 2
-grep "another named process" ns2/named3.run > /dev/null || ret=1
+(cd ns2 && $NAMED -c named-alt2.conf -D runtime-ns2-extra-2 -X named.lock -m record,size,mctx -d 99 -g -U 4 >> named$n.run 2>&1 & )
+wait_for_named "another named process" ns2/named$n.run || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "verifying that 'lock-file none' disables process check ($n)"
ret=0
-(cd ns2 && $NAMED -c named-alt3.conf -D runtime-ns2-extra-3 -m record,size,mctx -d 99 -g -U 4 >> named4.run 2>&1 & )
-sleep 2
-grep "another named process" ns2/named4.run > /dev/null && ret=1
+(cd ns2 && $NAMED -c named-alt3.conf -D runtime-ns2-extra-3 -m record,size,mctx -d 99 -g -U 4 >> named$n.run 2>&1 & )
+wait_for_named "running$" ns2/named$n.run || ret=1
+grep "another named process" ns2/named$n.run > /dev/null && ret=1
kill_named ns2/named-alt3.pid || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that named refuses to start if working directory is not writable ($n)"
ret=0
-(cd ns2 && $NAMED -c named-alt4.conf -D runtime-ns2-extra-4 -d 99 -g > named4.run 2>&1 &)
-sleep 2
-grep "[^-]directory './nope' is not writable" ns2/named4.run > /dev/null 2>&1 || ret=1
-grep "exiting (due to fatal error)" ns2/named4.run > /dev/null || ret=1
+(cd ns2 && $NAMED -c named-alt4.conf -D runtime-ns2-extra-4 -d 99 -g > named$n.run 2>&1 &)
+wait_for_named "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
kill_named ns2/named.pid && ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that named refuses to start if managed-keys-directory is not writable ($n)"
ret=0
-(cd ns2 && $NAMED -c named-alt5.conf -D runtime-ns2-extra-5 -d 99 -g > named5.run 2>&1 &)
-sleep 2
-grep "managed-keys-directory './nope' is not writable" ns2/named5.run > /dev/null 2>&1 || ret=1
-grep "exiting (due to fatal error)" ns2/named5.run > /dev/null || ret=1
+(cd ns2 && $NAMED -c named-alt5.conf -D runtime-ns2-extra-5 -d 99 -g > named$n.run 2>&1 &)
+wait_for_named "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
kill_named named.pid && ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that named refuses to start if new-zones-directory is not writable ($n)"
ret=0
-(cd ns2 && $NAMED -c named-alt6.conf -D runtime-ns2-extra-6 -d 99 -g > named6.run 2>&1 &)
-sleep 2
-grep "new-zones-directory './nope' is not writable" ns2/named6.run > /dev/null 2>&1 || ret=1
-grep "exiting (due to fatal error)" ns2/named6.run > /dev/null || ret=1
+(cd ns2 && $NAMED -c named-alt6.conf -D runtime-ns2-extra-6 -d 99 -g > named$n.run 2>&1 &)
+wait_for_named "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
kill_named ns2/named.pid && ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status+ret))
SPEC_DIR=$(cat ctrl-char-dir-name)
mkdir "ns2/${SPEC_DIR}"
copy_setports ns2/named-alt7.conf.in "ns2/${SPEC_DIR}/named.conf"
-(cd ns2 && $NAMED -c "${SPEC_DIR}/named.conf" -d 99 -g > named7.run 2>&1 &)
-sleep 2
-grep 'running as.*\\177\\033' ns2/named7.run > /dev/null || ret=1
+(cd ns2 && $NAMED -c "${SPEC_DIR}/named.conf" -d 99 -g > named$n.run 2>&1 &)
+wait_for_named "running$" ns2/named$n.run || ret=1
+grep 'running as.*\\177\\033' ns2/named$n.run > /dev/null || ret=1
kill_named ns2/named.pid || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status+ret))
SPEC_DIR="$;"
mkdir "ns2/${SPEC_DIR}"
copy_setports ns2/named-alt7.conf.in "ns2/${SPEC_DIR}/named.conf"
-(cd ns2 && $NAMED -c "${SPEC_DIR}/named.conf" -d 99 -g > named8.run 2>&1 &)
-sleep 2
-grep 'running as.*\\$\\;' ns2/named8.run > /dev/null || ret=1
+(cd ns2 && $NAMED -c "${SPEC_DIR}/named.conf" -d 99 -g > named$n.run 2>&1 &)
+wait_for_named "running$" ns2/named$n.run || ret=1
+grep 'running as.*\\$\\;' ns2/named$n.run > /dev/null || ret=1
kill_named ns2/named.pid || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status+ret))
LONG_CMD_LINE=$(cat long-cmd-line)
copy_setports ns2/named-alt7.conf.in "ns2/named-alt7.conf"
# shellcheck disable=SC2086
-(cd ns2 && $NAMED $LONG_CMD_LINE -c "named-alt7.conf" -g > named9.run 2>&1 &)
-sleep 2
-#grep "running as.*\.\.\.$" ns2/named9.run > /dev/null || ret=1
+(cd ns2 && $NAMED $LONG_CMD_LINE -c "named-alt7.conf" -g > named$n.run 2>&1 &)
+wait_for_named "running$" ns2/named$n.run || ret=1
+#grep "running as.*\.\.\.$" ns2/named$n.run > /dev/null || ret=1
echo_i "skipped - the ellipsis is currently not printed"
kill_named ns2/named.pid || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi