From: Matthijs Mekking Date: Mon, 16 May 2022 09:23:15 +0000 (+0200) Subject: Replace stat with PERL stat in kasp system test X-Git-Tag: v9.16.30~18^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=f922dd3e70033a1270b1a67b4cea220245c39f94;p=thirdparty%2Fbind9.git Replace stat with PERL stat in kasp system test 7249bad7 introduced the -c option to stat(1) command, but BSD systems do not know about it. Replace the stat(1) command with a PERL script that achieves the same. Why PERL? For consistency purposes, there are more places in the system test where we use the same method. (cherry picked from commit fe601c5915a2c19c5bdc475476d81b01267e2417) --- diff --git a/bin/tests/system/kasp.sh b/bin/tests/system/kasp.sh index f41911a68e1..785b69c770d 100644 --- a/bin/tests/system/kasp.sh +++ b/bin/tests/system/kasp.sh @@ -80,6 +80,10 @@ key_set() { eval "$(key_key "$1" "$2")='$3'" } +key_stat() { + $PERL -e 'print((stat @ARGV[0])[9] . "\n");' "$1" +} + # Save certain values in the KEY array. key_save() { @@ -90,9 +94,9 @@ key_save() # Save creation date. key_set "$1" CREATED "${KEY_CREATED}" # Save key change time. - key_set "$1" PRIVKEY_STAT $(stat -c '%Z' "${BASE_FILE}.private") - key_set "$1" PUBKEY_STAT $(stat -c '%Z' "${BASE_FILE}.key") - key_set "$1" STATE_STAT $(stat -c '%Z' "${BASE_FILE}.state") + key_set "$1" PRIVKEY_STAT $(key_stat "${BASE_FILE}.private") + key_set "$1" PUBKEY_STAT $(key_stat "${BASE_FILE}.key") + key_set "$1" STATE_STAT $(key_stat "${BASE_FILE}.state") } # Clear key state. diff --git a/bin/tests/system/kasp/tests.sh b/bin/tests/system/kasp/tests.sh index eccf33a2d36..05c00f1707c 100644 --- a/bin/tests/system/kasp/tests.sh +++ b/bin/tests/system/kasp/tests.sh @@ -307,9 +307,9 @@ state_stat=$(key_get KEY1 STATE_STAT) nextpart $DIR/named.run > /dev/null rndccmd 10.53.0.3 loadkeys "$ZONE" > /dev/null || log_error "rndc loadkeys zone ${ZONE} failed" wait_for_log 3 "keymgr: $ZONE done" $DIR/named.run -privkey_stat2=$(stat -c '%Z' "${basefile}.private") -pubkey_stat2=$(stat -c '%Z' "${basefile}.key") -state_stat2=$(stat -c '%Z' "${basefile}.state") +privkey_stat2=$(key_stat "${basefile}.private") +pubkey_stat2=$(key_stat "${basefile}.key") +state_stat2=$(key_stat "${basefile}.state") test "$privkey_stat" = "$privkey_stat2" || log_error "wrong private key file stat (expected $privkey_stat got $privkey_stat2)" test "$pubkey_stat" = "$pubkey_stat2" || log_error "wrong public key file stat (expected $pubkey_stat got $pubkey_stat2)" test "$state_stat" = "$state_stat2" || log_error "wrong state file stat (expected $state_stat got $state_stat2)" @@ -323,9 +323,9 @@ ret=0 nextpart $DIR/named.run > /dev/null rndccmd 10.53.0.3 loadkeys "$ZONE" > /dev/null || log_error "rndc loadkeys zone ${ZONE} failed" wait_for_log 3 "keymgr: done" $DIR/named.run -privkey_stat2=$(stat -c '%Z' "${basefile}.private") -pubkey_stat2=$(stat -c '%Z' "${basefile}.key") -state_stat2=$(stat -c '%Z' "${basefile}.state") +privkey_stat2=$(key_stat "${basefile}.private") +pubkey_stat2=$(key_stat "${basefile}.key") +state_stat2=$(key_stat "${basefile}.state") test "$privkey_stat" = "$privkey_stat2" || log_error "wrong private key file stat (expected $privkey_stat got $privkey_stat2)" test "$pubkey_stat" = "$pubkey_stat2" || log_error "wrong public key file stat (expected $pubkey_stat got $pubkey_stat2)" test "$state_stat" = "$state_stat2" || log_error "wrong state file stat (expected $state_stat got $state_stat2)"