]> 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:53:17 +0000 (18:53 +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 eccf33a2d36dd8b733b3b1f224bb11f32abfb383..05c00f1707cdac6d1b8c9667d786bacd1b39a728 100644 (file)
@@ -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)"