]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Replace stat with PERL stat in kasp system test
authorMatthijs Mekking <matthijs@isc.org>
Mon, 16 May 2022 09:23:15 +0000 (11:23 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Mon, 16 May 2022 16:02:38 +0000 (18:02 +0200)
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)

bin/tests/system/kasp.sh
bin/tests/system/kasp/tests.sh

index f41911a68e178188ee58354d2950435715048479..785b69c770d03116517f83c7282d039e87675778 100644 (file)
@@ -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.
index 0607b8e9416d8724d4869a6af08bb2b5d26ceca4..650c961f4eb338b3ecd969687d69f3ccfd0e6d3e 100644 (file)
@@ -306,9 +306,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)"
@@ -322,9 +322,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)"