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 573545A026F for ; Tue, 27 Jun 2023 04:54:45 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Qqq7K0B7Pz4wqk; Tue, 27 Jun 2023 12:54:37 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1687834477; bh=eS7OMs/JFPOSNHWIFahunwU/JXvnrS12G631Wh/idaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iBXC33C8AwBdQuxrEI+wYikn7Tf/4eBnYtF0DvW/NTwJm4wZZGmWswWuZKNHTozM9 9NiPpLWUeFSFr+6pSYU9+FHNEx3JKXozFXtGGWj9thkKvifbb/efFJ6zNCtKMxgbpQ Kv8oGP/0LHVk1t9/8CwgDbpBVyY+gow4szBU2fms= From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 14/27] tasst: Add helper to get network interface names for a site Date: Tue, 27 Jun 2023 12:54:15 +1000 Message-ID: <20230627025429.2209702-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230627025429.2209702-1-david@gibson.dropbear.id.au> References: <20230627025429.2209702-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 7GNDFDGMDEJ3GLDGAE3GFW7OHE5DSL2B X-Message-ID-Hash: 7GNDFDGMDEJ3GLDGAE3GFW7OHE5DSL2B 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: crosa@redhat.com, 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 # Conflicts: # test/tasst/exesite.py --- test/tasst/exesite.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/tasst/exesite.py b/test/tasst/exesite.py index e69db8ad..811b670e 100644 --- a/test/tasst/exesite.py +++ b/test/tasst/exesite.py @@ -13,10 +13,13 @@ tasst/exesite.py - Manage simulated network sites for testing import contextlib +import json import avocado from avocado.utils.process import CmdError -from avocado_classless.test import assert_eq, assert_raises, test_output +from avocado_classless.test import ( + assert_eq, assert_in, assert_raises, test_output +) from tasst.typecheck import typecheck @@ -93,6 +96,11 @@ class Site(contextlib.AbstractContextManager): raise avocado.TestCancel( f"Missing commands {', '.join(missing)} on {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] + def test_site(sitefn): def test_true(s): @@ -143,9 +151,14 @@ def test_site(sitefn): ignore_status=True): pass + def test_has_lo(s): + with s as site: + assert_in('lo', site.ifs()) + return test_output(test_true, test_false, test_echo, test_timeout, test_bg_true, test_bg_false, test_bg_echo, - test_bg_timeout, test_bg_context_timeout)(sitefn) + test_bg_timeout, test_bg_context_timeout, + test_has_lo)(sitefn) class RealHost(Site): -- 2.41.0