Handle non-zero return codes in rootkeysentinel tests

(cherry picked from commit d203681a75)
This commit is contained in:
Tom Krizek 2023-06-28 11:12:13 +02:00
parent 17f6a849ab
commit 02edc985cf
No known key found for this signature in database
GPG key ID: 01623B9B652A20A7
2 changed files with 8 additions and 13 deletions

View file

@ -11,13 +11,10 @@
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
# leave as expr as expr treats arguments with leading 0's as base 10
# handle exit code 1 from expr when the result is 0
oldid=${1:-00000}
newid=$(expr \( ${oldid} + 1000 \) % 65536 || true)
newid=$(expr "0000${newid}" : '.*\(.....\)$') # prepend leading 0's
badid=$(expr \( ${oldid} + 7777 \) % 65536 || true)
badid=$(expr "0000${badid}" : '.*\(.....\)$') # prepend leading 0's
oldid=$(echo ${1:-0} | sed 's/^0*//')
newid=$(printf '%05u' $(((oldid + 1000) % 65536)))
badid=$(printf '%05u' $(((oldid + 7777) % 65536)))
oldid=$(printf '%05u' $((oldid + 0)))
. ../../conf.sh

View file

@ -38,12 +38,10 @@ newtest() {
newtest "get test ids"
$DIG $DIGOPTS . dnskey +short +rrcomm @10.53.0.1 > dig.out.ns1.test$n || ret=1
oldid=`sed -n 's/.*key id = //p' < dig.out.ns1.test$n`
oldid=`expr "0000${oldid}" : '.*\(.....\)$'`
newid=`expr \( ${oldid} + 1000 \) % 65536`
newid=`expr "0000${newid}" : '.*\(.....\)$'`
badid=`expr \( ${oldid} + 7777 \) % 65536`
badid=`expr "0000${badid}" : '.*\(.....\)$'`
oldid=$(sed -n 's/.*key id = //p' < dig.out.ns1.test$n)
newid=$(printf "%05u" $(((oldid + 1000) % 65536)))
badid=$(printf "%05u" $(((oldid + 7777) % 65536)))
oldid=$(printf "%05u" $((oldid + 0)))
echo_i "test id: oldid=${oldid} (configured)"
echo_i "test id: newid=${newid} (not configured)"
echo_i "test id: badid=${badid}"