public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
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	[thread overview]
Message-ID: <20220818061358.1775944-7-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20220818061358.1775944-1-david@gibson.dropbear.id.au>

[-- Attachment #1: Type: text/plain, Size: 3869 bytes --]

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 <david(a)gibson.dropbear.id.au>
---
 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__" = "__HOST_ADDR__" ]
 
 test	DHCP: route
 gout	GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
-hout	HOST_GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
+hout	HOST_GW ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]'
 check	[ "__GW__" = "__HOST_GW__" ]
 
 test	DHCP: MTU
@@ -55,7 +55,7 @@ check	[ "__ADDR6__" = "__HOST_ADDR6__" ]
 
 test	DHCPv6: route
 gout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
-hout	HOST_GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
+hout	HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]'
 check	[ "__GW6__" = "__HOST_GW6__" ]
 
 # Strip interface specifier: interface names might differ between host and guest
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__ = __HOST_ADDR__ ]
 
 test	DHCP: route
 nsout	GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
-hout	HOST_GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
+hout	HOST_GW ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]'
 check	[ __GW__ = __HOST_GW__ ]
 
 test	DHCP: MTU
@@ -42,5 +42,5 @@ check	[ __ADDR6__ = __HOST_ADDR6__ ]
 
 test	DHCPv6: route
 nsout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
-hout	HOST_GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
+hout	HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]'
 check	[ __GW6__ = __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 == "ether").ifname'
 guest	ip link set dev __IFNAME__ up && sleep 2
-hout	HOST_IFNAME6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").dev'
+hout	HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]'
 check	[ -n "__IFNAME__" ]
 
 test	SLAAC: prefix
@@ -29,5 +29,5 @@ check	[ "__PREFIX6__" = "__HOST_PREFIX6__" ]
 
 test	SLAAC: route
 gout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
-hout	HOST_GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
+hout	HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]'
 check	[ __GW6__ = __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__" = "__HOST_PREFIX6__" ]
 
 test	SLAAC: route
 nsout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
-hout	HOST_GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
+hout	HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]'
 check	[ __GW6__ = __HOST_GW6__ ]
-- 
@@ -29,5 +29,5 @@ check	[ "__PREFIX6__" = "__HOST_PREFIX6__" ]
 
 test	SLAAC: route
 nsout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
-hout	HOST_GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
+hout	HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]'
 check	[ __GW6__ = __HOST_GW6__ ]
-- 
2.37.2


  parent reply	other threads:[~2022-08-18  6:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18  6:13 [PATCH 00/10] passt test fixes, batch 6 David Gibson
2022-08-18  6:13 ` [PATCH 01/10] test: Convert distro tests to use socat instead of nc/ncat David Gibson
2022-08-18  6:13 ` [PATCH 02/10] test: Split cppcheck and clang-tidy tests into different files David Gibson
2022-08-18  6:13 ` [PATCH 03/10] test: Remove unused *_XTERM variables David Gibson
2022-08-18  6:13 ` [PATCH 04/10] test: Ignore video processing temporary files David Gibson
2022-08-18  6:13 ` [PATCH 05/10] test: Split setup/teardown functions for build and distro tests David Gibson
2022-08-18  6:13 ` David Gibson [this message]
2022-08-18  6:13 ` [PATCH 07/10] test: Rename slightly misleading "valgrind" tests David Gibson
2022-08-18  6:13 ` [PATCH 08/10] test: Use shutdown test for pasta David Gibson
2022-08-18  6:13 ` [PATCH 09/10] test: Log debugging output from test script David Gibson
2022-08-18  6:13 ` [PATCH 10/10] test: Kill qemu by pidfile rather than ^C David Gibson
2022-08-21 20:23 ` [PATCH 00/10] passt test fixes, batch 6 Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220818061358.1775944-7-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).