]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: support ss as netstat replacement
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 13 Jan 2021 16:01:01 +0000 (17:01 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 14 Jan 2021 17:17:48 +0000 (18:17 +0100)
netstat is considered obsolete on Linux. It is replaced by ss from
iproute. Support both tools for the test port selection.

test/system/test.common

index 4e5fa0246b90dabd2120102d5072afc94d7bf3ea..905974b2cd57641317c3bdd41ce8b58f66b54a61 100644 (file)
@@ -89,7 +89,13 @@ chronyc=$(command -v chronyc)
 [ -x "$chronyd" ] || test_skip "chronyd not found"
 [ -x "$chronyc" ] || test_skip "chronyc not found"
 
-netstat -aln > /dev/null 2> /dev/null || test_skip "missing netstat"
+if netstat -aln > /dev/null 2> /dev/null; then
+       port_list_command="netstat -aln"
+elif ss -atun > /dev/null 2> /dev/null; then
+       port_list_command="ss -atun"
+else
+       test_skip "missing netstat or ss"
+fi
 
 # Default test testings
 default_minimal_config=0
@@ -180,7 +186,7 @@ get_free_port() {
 
        while true; do
                port=$((RANDOM % 10000 + 10000))
-               netstat -aln | grep -q '^\(tcp\|udp\).*[:.]'"$port " && continue
+               $port_list_command | grep -q '^\(tcp\|udp\).*[:.]'"$port " && continue
                break
        done