From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 0AC1B5A027A for ; Wed, 31 May 2023 03:59:05 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4QWC9S34Ljz4x4Q; Wed, 31 May 2023 11:58:52 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1685498332; bh=Pa2jUjpiAa093Gtlst5u6PSYhsrWoMzGW+ymbO2pVZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PWWbJ5zyHO7LWAOMBpiQyIKjZeFXrfzmdakkeAxCGqCbVFhxEX7/yjwQDlkdYvPOk lZ6L2n/bdhn/0pSKYlXt+utPDPcxA5Wq6cAYd3X5IwZufkK6x2U1JjVvX0qjkJcva0 wBDbm8D5IKaHE06/cmoetE+NQlWHHgmnebPQFviA= From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v3 08/20] avocado/tasst: Add helper to get network interface names for a site Date: Wed, 31 May 2023 11:58:37 +1000 Message-Id: <20230531015849.3229596-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230531015849.3229596-1-david@gibson.dropbear.id.au> References: <20230531015849.3229596-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: DYCX3RXXOY4K3EKBZUJCJZZ23LSI3B5F X-Message-ID-Hash: DYCX3RXXOY4K3EKBZUJCJZZ23LSI3B5F X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Cleber Rosa , jarichte@redhat.com, David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Start adding convenience functions for handling sites as places with network setup with a simple helper which lists the network interface names for a site. Signed-off-by: David Gibson --- avocado/tasst/site.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/avocado/tasst/site.py b/avocado/tasst/site.py index 6aa83c4..6450944 100644 --- a/avocado/tasst/site.py +++ b/avocado/tasst/site.py @@ -11,6 +11,7 @@ # Author: David Gibson import contextlib +import json import avocado from avocado.utils.process import CmdError @@ -50,6 +51,11 @@ class Site(contextlib.AbstractContextManager): raise avocado.TestCancel("Missing commands {} on {}" .format(', '.join(missing), self.name)) + def ifs(self): + self.require_cmds('ip') + info = json.loads(self.output('ip -j link show')) + return [i['ifname'] for i in info] + class SiteTasst(Tasst): """ @@ -90,6 +96,10 @@ class SiteTasst(Tasst): status = proc.wait() self.assertNotEquals(status, 0) + def test_has_lo(self): + with self.setup_site() as site: + self.assertIn('lo', site.ifs()) + # Represents the host on which the tests are running, as opposed to # some simulated host created by the tests -- 2.40.1