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. 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 <david(a)gibson.dropbear.id.au> --- test/dhcp/passt | 2 +- test/two_guests/basic | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 test Interface name gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -hout HOST_IFNAME ip -j -4 route show|jq -rM '.[] | select(.dst == "default").dev' +hout HOST_IFNAME ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' check [ -n "__IFNAME__" ] 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 == "ether").ifname' g2out IFNAME2 ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -hout HOST_IFNAME ip -j -4 route show|jq -rM '.[] | select(.dst == "default").dev' +hout HOST_IFNAME ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' check [ -n "__IFNAME1__" ] check [ -n "__IFNAME2__" ]-- 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