if (int(x) > int(interval))
exit (1);
}
- END { if (int(x) > int(interval) || int(x) < int(interval-10)) exit(1) }' interval=$2
- return $?
+ END { if (int(x) > int(interval) || int(x) < int(interval-10)) exit(1) }' interval=$2 || return $?
+ return 0
}
echo_i "checking automatic key reloading interval ($n)"
for i in 0 1 2 3 4 5 6 7 8 9; do
_ret=1
$DIG $DIGOPTS delzsk.example NSEC3PARAM @10.53.0.3 > dig.out.ns3.1.test$n 2>&1 || ret=1
- grep "NSEC3PARAM.*12345678" dig.out.ns3.1.test$n > /dev/null 2>&1
- if [ $? -eq 0 ]; then
+ { grep "NSEC3PARAM.*12345678" dig.out.ns3.1.test$n > /dev/null 2>&1; rc=$?; } || true
+ if [ $rc -eq 0 ]; then
$RNDCCMD 10.53.0.3 signing -list delzsk.example > signing.out.2.test$n 2>&1
- grep "Creating NSEC3 chain " signing.out.2.test$n > /dev/null 2>&1
- if [ $? -ne 0 ]; then
+ { grep "Creating NSEC3 chain " signing.out.2.test$n > /dev/null 2>&1; rc=$?; } || true
+ if [ $rc -ne 0 ]; then
_ret=0
break
fi
for i in 0 1 2 3 4 5 6 7 8 9; do
_ret=1
$RNDCCMD 10.53.0.3 signing -list delzsk.example > signing.out.3.test$n 2>&1
- grep "Signing " signing.out.3.test$n > /dev/null 2>&1
- if [ $? -ne 0 ]; then
+ { grep "Signing " signing.out.3.test$n > /dev/null 2>&1; rc=$?; } || true
+ if [ $rc -ne 0 ]; then
if [ $(grep "Done signing " signing.out.3.test$n | wc -l) -eq 2 ]; then
_ret=0
break
}
runcmd() {
- "$@" 1> out.$n 2> err.$n
- echo $?
+ ("$@" 1> out.$n 2> err.$n; echo $?) || true
}
testcase() {
n=$((n + 1))
echo_i "checking that named-checkconf detects error in $bad ($n)"
ret=0
- $CHECKCONF $bad > checkconf.out$n 2>&1
- if [ $? -ne 1 ]; then ret=1; fi
+ { $CHECKCONF $bad > checkconf.out$n 2>&1; rc=$?; } || true
+ if [ $rc -ne 1 ]; then ret=1; fi
grep "^$bad:[0-9]*: " < checkconf.out$n > /dev/null || ret=1
case $bad in
bad-update-policy[123].conf)
good-dot-*.conf) continue;;
esac
fi
- $CHECKCONF $good > checkconf.out$n 2>&1
- if [ $? -ne 0 ]; then echo_i "failed"; ret=1; fi
+ { $CHECKCONF $good > checkconf.out$n 2>&1; rc=$?; } || true
+ if [ $rc -ne 0 ]; then echo_i "failed"; ret=1; fi
status=$((status + ret))
done
n=$((n + 1))
ret=0
- $FEATURETEST --with-lmdb
- if [ $? -eq 0 ]; then
+ if $FEATURETEST --with-lmdb; then
echo_i "checking that named-checkconf detects no error in $lmdb ($n)"
- $CHECKCONF $lmdb > checkconf.out$n 2>&1
- if [ $? -ne 0 ]; then echo_i "failed"; ret=1; fi
+ { $CHECKCONF $lmdb > checkconf.out$n 2>&1; rc=$?; } || true
+ if [ $rc -ne 0 ]; then echo_i "failed"; ret=1; fi
else
echo_i "checking that named-checkconf detects error in $lmdb ($n)"
- $CHECKCONF $lmdb > checkconf.out$n 2>&1
- if [ $? -eq 0 ]; then echo_i "failed"; ret=1; fi
+ { $CHECKCONF $lmdb > checkconf.out$n 2>&1; rc=$?; } || true
+ if [ $rc -eq 0 ]; then echo_i "failed"; ret=1; fi
fi
status=$((status + ret))
done
$field 0;
};
EOF
- $CHECKCONF badzero.conf > checkconf.out$n.1 2>&1
- [ $? -eq 1 ] || { echo_i "options $field failed" ; ret=1; }
+ { $CHECKCONF badzero.conf > checkconf.out$n.1 2>&1; rc=$?; } || true
+ [ $rc -eq 1 ] || { echo_i "options $field failed" ; ret=1; }
cat > badzero.conf << EOF
view dummy {
$field 0;
};
EOF
- $CHECKCONF badzero.conf > checkconf.out$n.2 2>&1
- [ $? -eq 1 ] || { echo_i "view $field failed" ; ret=1; }
+ { $CHECKCONF badzero.conf > checkconf.out$n.2 2>&1; rc=$?; } || true
+ [ $rc -eq 1 ] || { echo_i "view $field failed" ; ret=1; }
cat > badzero.conf << EOF
options {
$field 0;
view dummy {
};
EOF
- $CHECKCONF badzero.conf > checkconf.out$n.3 2>&1
- [ $? -eq 1 ] || { echo_i "options + view $field failed" ; ret=1; }
+ { $CHECKCONF badzero.conf > checkconf.out$n.3 2>&1; rc=$?; } || true
+ [ $rc -eq 1 ] || { echo_i "options + view $field failed" ; ret=1; }
cat > badzero.conf << EOF
zone dummy {
type secondary;
$field 0;
};
EOF
- $CHECKCONF badzero.conf > checkconf.out$n.4 2>&1
- [ $? -eq 1 ] || { echo_i "zone $field failed" ; ret=1; }
+ { $CHECKCONF badzero.conf > checkconf.out$n.4 2>&1; rc=$?; } || true
+ [ $rc -eq 1 ] || { echo_i "zone $field failed" ; ret=1; }
done
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
}
digcomp() {
- output=`$PERL $TOP_SRCDIR/bin/tests/system/digcomp.pl "$@"`
- result=$?
+ { output=`$PERL $TOP_SRCDIR/bin/tests/system/digcomp.pl "$@"`; result=$?; } || true
[ -n "$output" ] && { echo "digcomp failed:"; echo "$output"; } | cat_i
return $result
}
case "$pos" in
"3")
- awk -v rrtype="$2" -v ttl="$3" '($4 == "IN" || $4 == "CLASS1" ) && $5 == rrtype { if ($3 <= ttl) { ok=1 } } END { exit(ok?0:1) }' < $file
+ { awk -v rrtype="$2" -v ttl="$3" '($4 == "IN" || $4 == "CLASS1" ) && $5 == rrtype { if ($3 <= ttl) { ok=1 } } END { exit(ok?0:1) }' < $file; result=$?; } || true
;;
*)
- awk -v rrtype="$2" -v ttl="$3" '($3 == "IN" || $3 == "CLASS1" ) && $4 == rrtype { if ($2 <= ttl) { ok=1 } } END { exit(ok?0:1) }' < $file
+ { awk -v rrtype="$2" -v ttl="$3" '($3 == "IN" || $3 == "CLASS1" ) && $4 == rrtype { if ($2 <= ttl) { ok=1 } } END { exit(ok?0:1) }' < $file; result=$?; } || true
;;
esac
- result=$?
[ $result -eq 0 ] || echo_i "ttl check failed"
return $result
}
< "$1" $PERL -e 'binmode STDIN;
read(STDIN, $input, 8);
($style, $version) = unpack("NN", $input);
- exit 1 if ($style != 2 || $version != 0);'
- return $?
+ exit 1 if ($style != 2 || $version != 0);' || return $?
}
# check that a zone file is raw format, version 1
< "$1" $PERL -e 'binmode STDIN;
read(STDIN, $input, 8);
($style, $version) = unpack("NN", $input);
- exit 1 if ($style != 2 || $version != 1);'
- return $?
+ exit 1 if ($style != 2 || $version != 1);' || return $?
}
# strip NS and RRSIG NS from input
/Start view/ { if (!empty) exit(1) }
/Secure roots:/ { if (empty) exit(1) }
/Negative trust anchors:/ { if (!empty) exit(1) }
- { empty=0 }' $1
- return $?
+ { empty=0 }' $1 || return $?
}
# Check that for a query against a validating resolver where the
then
echo_i "running DNSSEC update test"
ret=0
- output=$($PERL dnssec_update_test.pl -s 10.53.0.3 -p "$PORT" dynamic.example.)
- test "$?" -eq 0 || ret=1
+ { output=$($PERL dnssec_update_test.pl -s 10.53.0.3 -p "$PORT" dynamic.example.); rc=$?; } || true
+ test "$rc" -eq 0 || ret=1
echo "$output" | cat_i
[ $ret -eq 1 ] && status=1
else
do
ret=0
echo_i "checking that named-checkconf detects error in $bad"
- $CHECKCONF $bad > /dev/null 2>&1
- if [ $? != 1 ]; then echo_i "failed"; ret=1; fi
+ { $CHECKCONF $bad > /dev/null 2>&1; rc=$?; } || true
+ if [ $rc != 1 ]; then echo_i "failed"; ret=1; fi
status=$((status + ret))
done
do
ret=0
echo_i "checking that named-checkconf detects no error in $good"
- $CHECKCONF $good > /dev/null 2>&1
- if [ $? != 0 ]; then echo_i "failed"; ret=1; fi
+ { $CHECKCONF $good > /dev/null 2>&1; rc=$?; } || true
+ if [ $rc != 0 ]; then echo_i "failed"; ret=1; fi
status=$((status + ret))
done
echo_i "checking server quotas for both encrypted and unencrypted HTTP ($n)"
ret=0
if [ -x "$PYTHON" ]; then
- BINDHOST="10.53.0.1" "$PYTHON" "$TOP_SRCDIR/bin/tests/system/doth/stress_http_quota.py"
- ret=$?
+ BINDHOST="10.53.0.1" "$PYTHON" "$TOP_SRCDIR/bin/tests/system/doth/stress_http_quota.py" || ret=$?
else
echo_i "Python is not available. Skipping the test..."
fi
echo_i "$description ($n)"
ret=0
- $DIGCMD $2 $3 > dig.out.$n 2>&1
- if [ $? -ne 0 ]; then
+ { $DIGCMD $2 $3 > dig.out.$n 2>&1; rc=$?; } || true
+ if [ $rc -ne 0 ]; then
echo_i "failed: dig command returned non-zero status"
ret=1
else
echo_i "$description ($n)"
ret=0
- $DIGCMD $2 $3 > dig.out.$n 2>&1
- if [ $? -eq 0 ]; then
+ { $DIGCMD $2 $3 > dig.out.$n 2>&1; rc=$?; } || true
+ if [ $rc -eq 0 ]; then
echo_i "failed: dig command unexpectedly succeeded"
ret=1
fi
# Main test begins here
-$FEATURETEST --with-libidn2
-if [ $? -eq 0 ]; then
+if $FEATURETEST --with-libidn2; then
idna_enabled_test
else
idna_disabled_test
for i in 1 2 3 4 5 6 7 8 9 0
do
ret=1
- grep "ns2.$zone. . 10 20 20 1814400 3600" ns7/named.run > /dev/null 2>&1
- [ $? -eq 0 ] && ret=0 && break
+ { grep "ns2.$zone. . 10 20 20 1814400 3600" ns7/named.run > /dev/null 2>&1; rc=$?; } || true
+ [ $rc -eq 0 ] && ret=0 && break
sleep 1
done
if [ $ret != 0 ]; then echo_i "failed"; fi
n=$((n+1))
echo_i "testing ixfr-from-differences option ($n)"
# ns3 is primary; ns4 is secondary
-$CHECKZONE test. ns3/mytest.db > /dev/null 2>&1
-if [ $? -ne 0 ]
+{ $CHECKZONE test. ns3/mytest.db > /dev/null 2>&1; rc=$?; } || true
+if [ $rc -ne 0 ]
then
echo_i "named-checkzone returned failure on ns3/mytest.db"
fi
$PERL -e 'binmode STDIN;
read(STDIN, $input, 8);
($style, $version) = unpack("NN", $input);
- exit 1 if ($style != 2 || $version > 1);' < "$1"
- return $?
+ exit 1 if ($style != 2 || $version > 1);' < "$1" || return $?
}
isfull () {
# the compression disabled message should be at least twice as large as with
# compression disabled, but the content should be the same
echo_i "Checking if responses are identical other than in message size"
-diff dig.compdis.sorted.test dig.compen.sorted.test >/dev/null
-ret=$?
+{ diff dig.compdis.sorted.test dig.compen.sorted.test >/dev/null; ret=$?; } || true
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
(
while read cmd
do
- echo "$cmd" | $NSUPDATE > /dev/null 2>&1
- if test $? -gt 1 ; then
+ { echo "$cmd" | $NSUPDATE > /dev/null 2>&1; rc=$?; } || true
+ if test $rc -gt 1 ; then
echo_i "failed ($cmd)"
ret=1
fi
- echo "$cmd " | $NSUPDATE > /dev/null 2>&1
- if test $? -gt 1 ; then
+ { echo "$cmd " | $NSUPDATE > /dev/null 2>&1; rc=$?; } || true
+ if test $rc -gt 1 ; then
echo_i "failed ($cmd)"
ret=1
fi
echo_i "testing rndc buffer size limits (size=${i}) ($n)"
ret=0
$RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf testgen ${i} 2>&1 > rndc.out.$i.test$n || ret=1
- actual_size=`$GENCHECK rndc.out.$i.test$n`
- if [ "$?" = "0" ]; then
+ { actual_size=`$GENCHECK rndc.out.$i.test$n`; rc=$?; } || true
+ if [ "$rc" = "0" ]; then
expected_size=$((i+1))
if [ $actual_size != $expected_size ]; then ret=1; fi
else
for i in 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
do
- run_query 4$n $i
- c=`expr $c + $?`
+ run_query 4$n $i || c=$((c + 1))
done
skipped=$((33-c))
if [ $skipped != $ni ]; then
echo_i "verifying that named switches UID ($n)"
if [ "$(id -u)" -eq 0 ]; then
ret=0
- TEMP_NAMED_DIR=$(mktemp -d "$(pwd)/ns2/tmp.XXXXXXXX")
- if [ "$?" -eq 0 ]; then
+ { TEMP_NAMED_DIR=$(mktemp -d "$(pwd)/ns2/tmp.XXXXXXXX"); rc=$?; } || true
+ if [ "$rc" -eq 0 ]; then
copy_setports ns2/named-alt9.conf.in "${TEMP_NAMED_DIR}/named-alt9.conf"
chown -R nobody: "${TEMP_NAMED_DIR}"
chmod 0700 "${TEMP_NAMED_DIR}"
esac
file=`$PERL fetch.pl -p ${EXTRAPORT1} $path`
cp $file $file.$1.$3
- $PERL zones-${1}.pl $file $2 2>/dev/null | sort > zones.out.$3
- result=$?
+ { $PERL zones-${1}.pl $file $2 2>/dev/null | sort > zones.out.$3; result=$?; } || true
return $result
}
status=0
checkout() {
- case $? in
+ rc=$1
+ case $rc in
0) : ok ;;
*) echo_i "failed"
status=$((status + 1))
while read name hash
do
echo_i "checking $NSEC3HASH $name"
- out=`$NSEC3HASH $salt $algo $iters $name`
- checkout
+ { out=`$NSEC3HASH $salt $algo $iters $name`; rc=$?; } || true
+ checkout $rc
echo_i "checking $NSEC3HASH -r $name"
- out=`$NSEC3HASH -r $algo $flags $iters $salt $name`
- checkout
+ { out=`$NSEC3HASH -r $algo $flags $iters $salt $name`; rc=$?; } || true
+ checkout $rc
done <<EOF
*.w.example R53BQ7CC2UVMUBFU5OCMM6PERS9TK9EN
# test empty salt
checkempty() {
- hash=CK0POJMG874LJREF7EFN8430QVIT8BSM checkout &&
- hash=- checkout
+ rc=$1
+ hash=CK0POJMG874LJREF7EFN8430QVIT8BSM checkout $rc &&
+ hash=- checkout $rc
}
name=com algo=1 flags=1 iters=0
echo_i "checking $NSEC3HASH '' $name"
-out=`$NSEC3HASH '' $algo $iters $name`
-checkempty
+{ out=`$NSEC3HASH '' $algo $iters $name`; rc=$?; } || true
+checkempty $rc
echo_i "checking $NSEC3HASH - $name"
-out=`$NSEC3HASH - $algo $iters $name`
-checkempty
+{ out=`$NSEC3HASH - $algo $iters $name`; rc=$?; } || true
+checkempty $rc
echo_i "checking $NSEC3HASH -- '' $name"
-out=`$NSEC3HASH -- '' $algo $iters $name`
-checkempty
+{ out=`$NSEC3HASH -- '' $algo $iters $name`; rc=$?; } || true
+checkempty $rc
echo_i "checking $NSEC3HASH -- - $name"
-out=`$NSEC3HASH -- - $algo $iters $name`
-checkempty
+{ out=`$NSEC3HASH -- - $algo $iters $name`; rc=$?; } || true
+checkempty $rc
echo_i "checking $NSEC3HASH -r '' $name"
-out=`$NSEC3HASH -r $algo $flags $iters '' $name`
-checkempty
+{ out=`$NSEC3HASH -r $algo $flags $iters '' $name`; rc=$?; } || true
+checkempty $rc
echo_i "checking $NSEC3HASH -r - $name"
-out=`$NSEC3HASH -r $algo $flags $iters - $name`
-checkempty
+{ out=`$NSEC3HASH -r $algo $flags $iters - $name`; rc=$?; } || true
+checkempty $rc
checkfail() {
- case $? in
+ rc=$1
+ case $rc in
0) echo_i "failed to fail"
status=$((status + 1))
return 1 ;;
esac
}
echo_i "checking $NSEC3HASH missing args"
-out=`$NSEC3HASH 00 1 0 2>&1`
-checkfail
+{ out=`$NSEC3HASH 00 1 0 2>&1`; rc=$?; } || true
+checkfail $rc
echo_i "checking $NSEC3HASH extra args"
-out=`$NSEC3HASH 00 1 0 two names 2>&1`
-checkfail
+{ out=`$NSEC3HASH 00 1 0 two names 2>&1`; rc=$?; } || true
+checkfail $rc
echo_i "checking $NSEC3HASH bad option"
-out=`$NSEC3HASH -? 2>&1`
-checkfail
+{ out=`$NSEC3HASH -? 2>&1`; rc=$?; } || true
+checkfail $rc
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1