]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make the statschannel system test portable
authorAram Sargsyan <aram@isc.org>
Tue, 10 Oct 2023 10:41:07 +0000 (10:41 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Thu, 12 Oct 2023 08:37:15 +0000 (08:37 +0000)
The usage of the newline in the replacement part of the 'sed' call
works in GNU systems, but not in OpenBSD. Use 'awk' instead.

Also use the extended syntax of regular expressions for 'grep', which
is similarly more portable across the supported systems.

bin/tests/system/statschannel/tests.sh

index afe941e2da5335d9c4be0916779a0e81946e91da..b13e33022f1af09248526820c8ef97554f1b9d7a 100644 (file)
@@ -714,10 +714,10 @@ n=$((n + 1))
 _wait_for_transfers() {
     getxfrins xml x$n || return 1
     getxfrins json j$n || return 1
-    # XML is encoded in one line, use sed to separate each transfer
-    count=$(sed 's/<xfrin /\n<xfrin /g' xfrins.xml.x$n | grep -c '<state>\(Zone Transfer Request\|First Data\|Receiving AXFR Data\)</state>')
+    # XML is encoded in one line, use awk to separate each transfer with a newline
+    count=$(awk '{ gsub("<xfrin ", "\n<xfrin ") } 1' xfrins.xml.x$n | grep -c -E '<state>(Zone Transfer Request|First Data|Receiving AXFR Data)</state>')
     if [ $count != 3 ]; then return 1; fi
-    count=$(grep -c '"state":"\(Zone Transfer Request\|First Data\|Receiving AXFR Data\)"' xfrins.json.j$n)
+    count=$(grep -c -E '"state":"(Zone Transfer Request|First Data|Receiving AXFR Data)"' xfrins.json.j$n)
     if [ $count != 3 ]; then return 1; fi
 }