From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: Re: [PATCH 17/18] tests: Correct determination of host interface name in tests Date: Tue, 19 Jul 2022 16:20:45 +1000 Message-ID: In-Reply-To: <20220715052141.890703-18-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0242579824663688058==" --===============0242579824663688058== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Fri, Jul 15, 2022 at 03:21:40PM +1000, David Gibson wrote: > By default, passt itself attaches to the first host interface with a > default route. However, when determining the host interface name the tests > implicitly select the *last* host interface: they use a jq expression which > will list all interfaces with default routes, but the way output detection > works in the scripts, it will only pick up the last line. >=20 > If there are multiple interfaces with default routes on the host, and they > each have a different address, this can cause spurious test > failures. It seems this change is not enough to always fix the tests when there are multiple default routes. I'm still sometimes getting failures, now because passt itself doesn't seem to be picking the interface with the first default route. I'm wondering if this is because ip(8) is sorting the output, not just presenting it in the same order that the underlying netlink interface does. > Signed-off-by: David Gibson > --- > test/dhcp/passt | 2 +- > test/two_guests/basic | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/test/dhcp/passt b/test/dhcp/passt > index 3d2e939..f45227a 100644 > --- a/test/dhcp/passt > +++ b/test/dhcp/passt > @@ -16,7 +16,7 @@ htools ip jq sed tr head > =20 > test Interface name > gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type =3D=3D "ethe= r").ifname' > -hout HOST_IFNAME ip -j -4 route show|jq -rM '.[] | select(.dst =3D=3D "def= ault").dev' > +hout HOST_IFNAME ip -j -4 route show|jq -rM '[.[] | select(.dst =3D=3D "de= fault").dev] | .[0]' > check [ -n "__IFNAME__" ] > =20 > test DHCP: address > diff --git a/test/two_guests/basic b/test/two_guests/basic > index cf0b975..f7c016d 100644 > --- a/test/two_guests/basic > +++ b/test/two_guests/basic > @@ -18,7 +18,7 @@ htools ip jq md5sum cut > test Interface names > g1out IFNAME1 ip -j link show | jq -rM '.[] | select(.link_type =3D=3D "et= her").ifname' > g2out IFNAME2 ip -j link show | jq -rM '.[] | select(.link_type =3D=3D "et= her").ifname' > -hout HOST_IFNAME ip -j -4 route show|jq -rM '.[] | select(.dst =3D=3D "def= ault").dev' > +hout HOST_IFNAME ip -j -4 route show|jq -rM '[.[] | select(.dst =3D=3D "de= fault").dev] | .[0]' > check [ -n "__IFNAME1__" ] > check [ -n "__IFNAME2__" ] > =20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --===============0242579824663688058== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUVCQ0FBZEZpRUVvVUx4V3U0L1dz MGRCK1h0Z3lwWTRnRXdZU0lGQW1MV1RTa0FDZ2tRZ3lwWTRnRXcKWVNKdk5RLy9mVERFQ2I3RndQ ZGM2U0xpMEpKcEM2N2xsL0pqL3gyb2RzTVZ3NlR0M25ZZERHUFlMRGdwbGE0eApEUnliV2p4QVE5 bmNMQSt5YVl6VXJ2OXplQ0JJZTM1bDRnKzJ2ZmRiTkZXVk5FWUIzQ3BZRjBYRnY5NWJXcGkzCmJp ekRJS2tDd3lDNmtvRnM4M3h6dGxlcWlqWUFXZUxrbi9rei9tS1RYdVR3TjhXdEU2ckV5d0hZZ0hJ cTQ0K0gKZFMzK3ZaTVc3YklwVzFEOTZnVDVSUXRpbDFGbWFQOElnbDl0NTA0M2huMjlHaTAyR1VE YWpQelZheHIxZnNoRwpWQUJRbkovLzFuMTVTdytJOTBuaEVMZVdQZGdCbGNhNzl0QXY4VlVLaHJa YmpkWjYvZnpJR2F0QzdGUzhrV1l4CmkzZlUvNnZBQTZsc05sRnZKY3hlaHN4ZFlvaTlSNXVXQ1JH K0hWVGZrNWQvZGxtN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