From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: [PATCH 06/10] test: Only select a single interface or gateway in tests Date: Thu, 18 Aug 2022 16:13:54 +1000 Message-ID: <20220818061358.1775944-7-david@gibson.dropbear.id.au> In-Reply-To: <20220818061358.1775944-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6072396889979300880==" --===============6072396889979300880== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The queries we use in the test scripts to locate the external interface or gateway can return multiple results. We get away with this because the way we parse command output only looks at the last line. It's not really correct, though, and improvements to our handling of command output will mean it breaks. Signed-off-by: David Gibson --- test/dhcp/passt | 4 ++-- test/dhcp/pasta | 4 ++-- test/ndp/passt | 4 ++-- test/ndp/pasta | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/dhcp/passt b/test/dhcp/passt index 11e0eb3..37bf6b5 100644 --- a/test/dhcp/passt +++ b/test/dhcp/passt @@ -28,7 +28,7 @@ check [ "__ADDR__" =3D "__HOST_ADDR__" ] =20 test DHCP: route gout GW ip -j -4 route show|jq -rM '.[] | select(.dst =3D=3D "default").gate= way' -hout HOST_GW ip -j -4 route show|jq -rM '.[] | select(.dst =3D=3D "default")= .gateway' +hout HOST_GW ip -j -4 route show|jq -rM '[.[] | select(.dst =3D=3D "default"= ).gateway] | .[0]' check [ "__GW__" =3D "__HOST_GW__" ] =20 test DHCP: MTU @@ -55,7 +55,7 @@ check [ "__ADDR6__" =3D "__HOST_ADDR6__" ] =20 test DHCPv6: route gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst =3D=3D "default").gat= eway' -hout HOST_GW6 ip -j -6 route show|jq -rM '.[] | select(.dst =3D=3D "default"= ).gateway' +hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst =3D=3D "default= ").gateway] | .[0]' check [ "__GW6__" =3D "__HOST_GW6__" ] =20 # Strip interface specifier: interface names might differ between host and g= uest diff --git a/test/dhcp/pasta b/test/dhcp/pasta index 076ec8d..d1e9611 100644 --- a/test/dhcp/pasta +++ b/test/dhcp/pasta @@ -26,7 +26,7 @@ check [ __ADDR__ =3D __HOST_ADDR__ ] =20 test DHCP: route nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst =3D=3D "default").gat= eway' -hout HOST_GW ip -j -4 route show|jq -rM '.[] | select(.dst =3D=3D "default")= .gateway' +hout HOST_GW ip -j -4 route show|jq -rM '[.[] | select(.dst =3D=3D "default"= ).gateway] | .[0]' check [ __GW__ =3D __HOST_GW__ ] =20 test DHCP: MTU @@ -42,5 +42,5 @@ check [ __ADDR6__ =3D __HOST_ADDR6__ ] =20 test DHCPv6: route nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst =3D=3D "default").ga= teway' -hout HOST_GW6 ip -j -6 route show|jq -rM '.[] | select(.dst =3D=3D "default"= ).gateway' +hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst =3D=3D "default= ").gateway] | .[0]' check [ __GW6__ =3D __HOST_GW6__ ] diff --git a/test/ndp/passt b/test/ndp/passt index 8ef15e7..c73fd4d 100644 --- a/test/ndp/passt +++ b/test/ndp/passt @@ -17,7 +17,7 @@ htools ip jq sipcalc grep cut test Interface name gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type =3D=3D "ether"= ).ifname' guest ip link set dev __IFNAME__ up && sleep 2 -hout HOST_IFNAME6 ip -j -6 route show|jq -rM '.[] | select(.dst =3D=3D "defa= ult").dev' +hout HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst =3D=3D "def= ault").dev] | .[0]' check [ -n "__IFNAME__" ] =20 test SLAAC: prefix @@ -29,5 +29,5 @@ check [ "__PREFIX6__" =3D "__HOST_PREFIX6__" ] =20 test SLAAC: route gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst =3D=3D "default").gat= eway' -hout HOST_GW6 ip -j -6 route show|jq -rM '.[] | select(.dst =3D=3D "default"= ).gateway' +hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst =3D=3D "default= ").gateway] | .[0]' check [ __GW6__ =3D __HOST_GW6__ ] diff --git a/test/ndp/pasta b/test/ndp/pasta index 28fdd72..d776055 100644 --- a/test/ndp/pasta +++ b/test/ndp/pasta @@ -29,5 +29,5 @@ check [ "__PREFIX6__" =3D "__HOST_PREFIX6__" ] =20 test SLAAC: route nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst =3D=3D "default").ga= teway' -hout HOST_GW6 ip -j -6 route show|jq -rM '.[] | select(.dst =3D=3D "default"= ).gateway' +hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst =3D=3D "default= ").gateway] | .[0]' check [ __GW6__ =3D __HOST_GW6__ ] --=20 2.37.2 --===============6072396889979300880==--